diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php b/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
index 08a1013..f2fd757 100644
--- a/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
@@ -24,14 +24,18 @@ class Comment extends DrupalSqlBase {
    * {@inheritdoc}
    */
   public function query() {
-    $query = $this->select('comments', 'c')
-      ->fields('c', array('cid', 'pid', 'nid', 'uid', 'subject',
-        'comment', 'hostname', 'timestamp', 'status', 'thread', 'name',
-        'mail', 'homepage', 'format'));
+    $query = $this->select('comments', 'c')->fields('c');
     $query->innerJoin('node', 'n', 'c.nid = n.nid');
-    $query->fields('n', array('type'));
-    $query->orderBy('c.timestamp');
-    return $query;
+
+    return $query
+      ->fields('n', array('type'))
+      // Ordering by thread ensures that parent comments will migrate before
+      // their children. This helps prevent fatal errors.
+      // @see https://www.drupal.org/node/2558923
+      ->orderBy('thread')
+      // Timestamp is a high-water property to allow continuous/rolling
+      // migrations.
+      ->orderBy('timestamp');
   }
 
   /**
diff --git a/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php b/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php
index fbc47f4..d35aabc 100755
--- a/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php
+++ b/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php
@@ -27,8 +27,15 @@ public function query() {
     $query = $this->select('comment', 'c')->fields('c');
     $query->innerJoin('node', 'n', 'c.nid = n.nid');
     $query->addField('n', 'type', 'node_type');
-    $query->orderBy('c.created');
-    return $query;
+
+    return $query
+      // Ordering by thread ensures that parent comments will migrate before
+      // their children. This helps prevent fatal errors.
+      // @see https://www.drupal.org/node/2558923
+      ->orderBy('thread')
+      // Changed time is a high-water property to allow continuous/rolling
+      // migrations.
+      ->orderBy('changed');
   }
 
   /**
diff --git a/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php b/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php
index 0458c54..b70e55d 100644
--- a/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php
+++ b/core/modules/comment/src/Tests/Migrate/d6/MigrateCommentTest.php
@@ -9,6 +9,8 @@
 
 use Drupal\comment\Tests\CommentTestTrait;
 use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
+use Drupal\node\Entity\Node;
+use Drupal\node\Entity\NodeType;
 
 /**
  * Upgrade comments.
@@ -19,7 +21,15 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
 
   use CommentTestTrait;
 
-  static $modules = array('node', 'comment', 'text', 'filter');
+  static $modules = array(
+    'comment',
+    'filter',
+    'node',
+    // The RDF module is not actually used by the test, but enabling it will
+    // reproduce the fatal error addressed in issue #2558923.
+    'rdf',
+    'text',
+  );
 
   /**
    * {@inheritdoc}
@@ -27,13 +37,16 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->installSchema('system', ['router']);
     $this->installEntitySchema('node');
     $this->installEntitySchema('comment');
     $this->installSchema('comment', ['comment_entity_statistics']);
     $this->installConfig(['node', 'comment']);
+    // Define the entity.node.canonical route, which RDF will need.
+    \Drupal::service('router.builder')->rebuild();
 
-    entity_create('node_type', array('type' => 'page'))->save();
-    entity_create('node_type', array('type' => 'story'))->save();
+    NodeType::create(['type' => 'page'])->save();
+    NodeType::create(['type' => 'story'])->save();
     $this->addDefaultCommentField('node', 'story');
     $this->container->get('entity.manager')->getStorage('comment_type')->create(array(
       'id' => 'comment_no_subject',
@@ -42,7 +55,7 @@ protected function setUp() {
     ))->save();
     \Drupal::service('comment.manager')->addBodyField('comment_no_subject');
 
-    $node = entity_create('node', array(
+    $node = Node::create(array(
       'type' => 'story',
       'nid' => 1,
       'title' => $this->randomString(),
