ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • 200
    • 2
    • 🟩 Routing and Topology
    • None
    • None
    • None
    • None
    • None
    • None

      FLE2 tests were sporadically failing though we disabled them.
      This ticket is about reenabling the tests.
      corresponding BF: BF-42674

      The issue is coming from the fact that for some reason in these tests the einsert calls throw an exception instead of returning the error as value.
      Since the test infrastructure expects a value in order to test retriability, nobody catches that exception, so the tests are failing.

      minimal repro:

      /**
       * Reproduces a stale-mongos failure for FLE inserts during shard removal.
       *
       * The test intentionally:
       * 1) Creates an encrypted collection on shard0.
       * 2) Warms routing metadata on mongos0.
       * 3) Moves the database primary off shard0, then removes shard0 using mongos1.
       * 4) Issues an encrypted insert via stale mongos0 and expects ShardNotFound.
       */
      import {EncryptedClient} from "jstests/fle2/libs/encrypted_client_util.js";
      // import {configureFailPoint} from "jstests/libs/fail_point_util.js";
      // import {funWithArgs} from "jstests/libs/parallel_shell_helpers.js";
      import {ShardingTest} from "jstests/libs/shardingtest.js";
      import {removeShard} from "jstests/sharding/libs/remove_shard_util.js";
      
      const st = new ShardingTest({shards: 2, mongos: 2, config: 1});
      try {
          const staleMongos = st.s0;
          const controlMongos = st.s1;
          const dbName = jsTestName();
          const collName = "enc";
      
          assert.commandWorked(controlMongos.adminCommand({enableSharding: dbName, primaryShard: st.shard0.shardName}));
      
          const client = new EncryptedClient(staleMongos, dbName);
          assert.commandWorked(
              client.createEncryptionCollection(collName, {
                  encryptedFields: {
                      fields: [
                          {
                              path: "a",
                              bsonType: "string",
                              queries: {queryType: "equality"},
                          },
                      ],
                  },
              }),
          );
      
          const edb = client.getDB();
          assert.commandWorked(edb[collName].einsert({_id: 0, a: "seed"}));
      
          // Ensure mongos0 caches this database's routing info before shard removal.
          assert.commandWorked(staleMongos.getDB(dbName).runCommand({listCollections: 1, nameOnly: true}));
      
          const dbEntryBefore = controlMongos.getDB("config").databases.findOne({_id: dbName});
          assert.eq(dbEntryBefore.primary, st.shard0.shardName, tojson(dbEntryBefore));
      
          // Move all unsharded data in this db (including FLE state collections) away from shard0 so
          // removeShard can complete.
          controlMongos.getDB(dbName).dropDatabase();
      
          const kSessionsColl = "config.system.sessions";
          let sessionCollEntry = controlMongos.getDB("config").collections.findOne({_id: kSessionsColl});
      
          controlMongos
              .getDB("config")
              .chunks.find({uuid: sessionCollEntry.uuid, shard: st.shard0.shardName})
              .forEach((chunkEntry) => {
                  assert.commandWorked(
                      controlMongos.adminCommand({
                          moveChunk: kSessionsColl,
                          find: chunkEntry.min,
                          to: st.shard1.shardName,
                          _waitForDelete: true,
                      }),
                  );
              });
      
          assert.commandWorked(controlMongos.adminCommand({enableSharding: dbName, primaryShard: st.shard1.shardName}));
          const client2 = new EncryptedClient(controlMongos, dbName);
          assert.commandWorked(
              client2.createEncryptionCollection(collName, {
                  encryptedFields: {
                      fields: [
                          {
                              path: "a",
                              bsonType: "string",
                              queries: {queryType: "equality"},
                          },
                      ],
                  },
              }),
          );
      
          removeShard(controlMongos.getDB("admin"), st.shard0.shardName);
      
          assert.commandWorked(
              staleMongos.getDB(dbName)[collName].einsert({
                  _id: 1,
                  a: "post-remove",
              }),
          );
      } finally {
          st.stop();
      }
      

            Assignee:
            Unassigned
            Reporter:
            Wolfee Farkas
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: