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

Upsert operations does not respect maxTimeMS in the presence of a Write Conflict

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.0.17, 6.0.21, 8.0.6
    • Component/s: None
    • Query Execution
    • ALL
    • Hide

      The following test code hangs on the CRUD upsert operation even when maxTimeMs was used:

      const dbName = "test";
      const collName = "write_conflicts_with_non_txns";
      const testDB = db.getSiblingDB(dbName);
      const testColl = testDB[collName];
      
      const sessionOptions = {
      causalConsistency: false
      };
      const session = db.getMongo().startSession(sessionOptions);
      const sessionDb = session.getDatabase(dbName);
      const sessionColl = sessionDb[collName];
      
      // Clean up and create test collection.
      testDB.runCommand({drop: collName, writeConcern: {w: "majority"}});
      assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}}));
      
      const txnOp = {
      update: collName,
      updates: [{q: {_id: 1}, u: {$set: {t1: 1}}, upsert: true}]
      };
      const nonTxnOp = {
      update: collName,
      updates: [{q: {_id: 1}, u: {$set: {t2: 1}}, upsert: true}],
      maxTimeMS: 100,
      };
      
      session.startTransaction();
      assert.commandWorked(sessionColl.runCommand(txnOp));
      assert.commandFailedWithCode(testColl.runCommand(nonTxnOp), ErrorCodes.MaxTimeMSExpired) // It hangs here
      Show
      The following test code hangs on the CRUD upsert operation even when maxTimeMs was used: const dbName = "test" ; const collName = "write_conflicts_with_non_txns" ; const testDB = db.getSiblingDB(dbName); const testColl = testDB[collName]; const sessionOptions = { causalConsistency: false }; const session = db.getMongo().startSession(sessionOptions); const sessionDb = session.getDatabase(dbName); const sessionColl = sessionDb[collName]; // Clean up and create test collection. testDB.runCommand({drop: collName, writeConcern: {w: "majority" }}); assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority" }})); const txnOp = { update: collName, updates: [{q: {_id: 1}, u: {$set: {t1: 1}}, upsert: true }] }; const nonTxnOp = { update: collName, updates: [{q: {_id: 1}, u: {$set: {t2: 1}}, upsert: true }], maxTimeMS: 100, }; session.startTransaction(); assert.commandWorked(sessionColl.runCommand(txnOp)); assert.commandFailedWithCode(testColl.runCommand(nonTxnOp), ErrorCodes.MaxTimeMSExpired) // It hangs here
    • None
    • None
    • None
    • None
    • None
    • None
    • None

          Assignee:
          Unassigned Unassigned
          Reporter:
          ernesto.rodriguez@mongodb.com Ernesto Rodriguez Reina
          Votes:
          0 Vote for this issue
          Watchers:
          7 Start watching this issue

            Created:
            Updated:
            None
            None
            None
            None