Bucket inserted into non-owning shard in a sharded viewless timeseries collection

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • ALL
    • Hide
      import {getTimeseriesCollForDDLOps} from "jstests/core/timeseries/libs/viewless_timeseries_util.js";
      
      // Minimized from bucket_unpacking_with_sort_extended_range.js
      // Place this test in jstests/core/timeseries (_This is important_! resmoke treats those specially)
      // Run in sharded_collections_jscore_passthrough_viewless_timeseries
      
      db.dropDatabase();
      
      // Create a timeseries collection sharded on time. Create chunks so that
      // times until year 2000 are in shard-rs1, times after year 2000 are in shard-rs0
      assert.commandWorked(db.adminCommand({enableSharding: db.getName(), primaryShard: "shard-rs0"}));
      const coll = db.mycoll;
      coll.drop();
      assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: 't'}}));
      
      assert.commandWorked(sh.splitAt(getTimeseriesCollForDDLOps(db, coll).getFullName(),
                                      {'control.min.t': ISODate('2000-01-01')}));
      assert.commandWorked(sh.moveChunk(getTimeseriesCollForDDLOps(db, coll).getFullName(),
                                        {'control.min.t': ISODate('1980-01-01')},
                                        "shard-rs1"));
      assert.commandWorked(sh.moveChunk(getTimeseriesCollForDDLOps(db, coll).getFullName(),
                                        {'control.min.t': ISODate('2000-01-01')},
                                        "shard-rs0"));
      
      // This insert should go to shard-rs0, but it goes to shard-rs1!
      coll.insert({t: new Date('2002-01-01')});
      
      // This fails I assume because it looks in shard-rs0 and the bucket isn't there
      assert.eq(1, coll.find().toArray().length);
      
      // After the test completes CheckOrphansDeleted fails because it finds the document in shard-rs1
      
      Show
      import {getTimeseriesCollForDDLOps} from "jstests/core/timeseries/libs/viewless_timeseries_util.js"; // Minimized from bucket_unpacking_with_sort_extended_range.js // Place this test in jstests/core/timeseries (_This is important_! resmoke treats those specially) // Run in sharded_collections_jscore_passthrough_viewless_timeseries db.dropDatabase(); // Create a timeseries collection sharded on time. Create chunks so that // times until year 2000 are in shard-rs1, times after year 2000 are in shard-rs0 assert.commandWorked(db.adminCommand({enableSharding: db.getName(), primaryShard: "shard-rs0"})); const coll = db.mycoll; coll.drop(); assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: 't'}})); assert.commandWorked(sh.splitAt(getTimeseriesCollForDDLOps(db, coll).getFullName(), {'control.min.t': ISODate('2000-01-01')})); assert.commandWorked(sh.moveChunk(getTimeseriesCollForDDLOps(db, coll).getFullName(), {'control.min.t': ISODate('1980-01-01')}, "shard-rs1")); assert.commandWorked(sh.moveChunk(getTimeseriesCollForDDLOps(db, coll).getFullName(), {'control.min.t': ISODate('2000-01-01')}, "shard-rs0")); // This insert should go to shard-rs0, but it goes to shard-rs1! coll.insert({t: new Date('2002-01-01')}); // This fails I assume because it looks in shard-rs0 and the bucket isn't there assert.eq(1, coll.find().toArray().length); // After the test completes CheckOrphansDeleted fails because it finds the document in shard-rs1
    • CAR Team 2025-07-07
    • None
    • 3
    • TBD
    • 🟩 Routing and Topology
    • None
    • None
    • None
    • None
    • None
    • None

      In the attached steps to reproduce, a viewless timeseries collection is sharded on time, and chunks are placed on specific shards.

      However when inserting a measurement, the bucket is persisted in a shard that does not own the expected chunk, so it immediately becomes an orphan.

      Investigate and fix why this is ocurring.

            Assignee:
            Tommaso Tocci
            Reporter:
            Joan Bruguera Micó
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: