Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-90808

Time-series version 3 buckets cause queries to throw a user assertion in earlier versions

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • ALL
    • v7.3
    • Hide

      Test file location: jstests/multiVersion/genericBinVersion/timeseries_v3_buckets.js

      Code:

      import "jstests/multiVersion/libs/multi_rs.js";
      
      const oldVersion = "7.0";
      const latestVersion = "latest";
      
      const dbName = "test";
      const collName = jsTestName();
      const timeFieldName = "t";
      const metaFieldName = "m";
      
      let rst = new ReplSetTest({nodes: {n1: {binVersion: latestVersion}}});
      rst.startSet();
      rst.initiate();
      
      let primary = rst.getPrimary();
      let db = primary.getDB(dbName);
      
      assert.commandWorked(db.createCollection(
          collName, {timeseries: {timeField: timeFieldName, metaField: metaFieldName}}));
      let coll = db.getCollection(collName);
      
      // Create a v3 bucket.
      const datePrefix = 1680912440;
      assert.commandWorked(coll.insert({[[timeFieldName]]: new Date(datePrefix), [[metaFieldName]]: 1}));
      assert.commandWorked(
          coll.insert({[[timeFieldName]]: new Date(datePrefix - 1), [[metaFieldName]]: 1}));
      
      let buckets = db.getCollection("system.buckets." + collName).find().toArray();
      assert.eq(1, buckets.length);
      assert.eq(3, buckets[0].control.version);
      
      assert.commandWorked(
          db.adminCommand({"setFeatureCompatibilityVersion": oldVersion, confirm: true}));
      
      jsTest.log("Downgrading replica set from latest to " + oldVersion);
      rst.upgradeSet({binVersion: oldVersion});
      jsTest.log("Replica set downgraded.");
      
      primary = rst.getPrimary();
      db = primary.getDB(dbName);
      coll = db.getCollection(collName);
      
      assert.commandWorked(coll.insert({[[timeFieldName]]: new Date(datePrefix), [[metaFieldName]]: 1}));
      
      // Compressed buckets cannot be re-opened in version <= 7.0.
      let stats = coll.stats().timeseries;
      assert.eq(2, stats.bucketCount);
      assert.eq(1, stats.numBucketInserts);
      assert.eq(0, stats.numBucketsReopened);
      
      // Throws 5857900, "Invalid bucket version".
      let measurements = coll.find().toArray();
      jsTestLog(measurements);
      
      rst.stopSet();
      
      
      Show
      Test file location: jstests/multiVersion/genericBinVersion/timeseries_v3_buckets.js Code: import "jstests/multiVersion/libs/multi_rs.js" ; const oldVersion = "7.0" ; const latestVersion = "latest" ; const dbName = "test" ; const collName = jsTestName(); const timeFieldName = "t" ; const metaFieldName = "m" ; let rst = new ReplSetTest({nodes: {n1: {binVersion: latestVersion}}}); rst.startSet(); rst.initiate(); let primary = rst.getPrimary(); let db = primary.getDB(dbName); assert .commandWorked(db.createCollection( collName, {timeseries: {timeField: timeFieldName, metaField: metaFieldName}})); let coll = db.getCollection(collName); // Create a v3 bucket. const datePrefix = 1680912440; assert .commandWorked(coll.insert({[[timeFieldName]]: new Date(datePrefix), [[metaFieldName]]: 1})); assert .commandWorked( coll.insert({[[timeFieldName]]: new Date(datePrefix - 1), [[metaFieldName]]: 1})); let buckets = db.getCollection( "system.buckets." + collName).find().toArray(); assert .eq(1, buckets.length); assert .eq(3, buckets[0].control.version); assert .commandWorked( db.adminCommand({ "setFeatureCompatibilityVersion" : oldVersion, confirm: true })); jsTest.log( "Downgrading replica set from latest to " + oldVersion); rst.upgradeSet({binVersion: oldVersion}); jsTest.log( "Replica set downgraded." ); primary = rst.getPrimary(); db = primary.getDB(dbName); coll = db.getCollection(collName); assert .commandWorked(coll.insert({[[timeFieldName]]: new Date(datePrefix), [[metaFieldName]]: 1})); // Compressed buckets cannot be re-opened in version <= 7.0. let stats = coll.stats().timeseries; assert .eq(2, stats.bucketCount); assert .eq(1, stats.numBucketInserts); assert .eq(0, stats.numBucketsReopened); // Throws 5857900, "Invalid bucket version" . let measurements = coll.find().toArray(); jsTestLog(measurements); rst.stopSet();

      There was investigation work done for this in SERVER-86319 but we didn't think about the downgrade implications of version 3 buckets.

      One option is to backport a change so that the query system treats version 3 buckets the same as version 2, as the sorted by time-field property is not used in earlier server versions. I believe we'll need to release version 7.0 with this change before 8.0 is released so that users can downgrade if needed. But we should also do something for 5.0 and 6.0.

                  uncaught exception: Error: error: {
                      "ok" : 0,
                      "errmsg" : "PlanExecutor error during aggregation :: caused by :: Invalid bucket version",
                      "code" : 5857900,
                      "codeName" : "Location5857900",
                      "$clusterTime" : {
                              "clusterTime" : Timestamp(1716427644, 9),
                              "signature" : {
                                      "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                                      "keyId" : NumberLong(0)
      

            Assignee:
            arun.banala@mongodb.com Arun Banala
            Reporter:
            gregory.wlodarek@mongodb.com Gregory Wlodarek
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: