Oplogs of non-replicated recordIds containing rid can lead to data corruption

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Execution
    • Fully Compatible
    • ALL
    • Hide
      const collName = "applyOpsCollName";
      const coll = db.getCollection(collName);
      coll.drop();
      
      assert.commandWorked(coll.runCommand({create: collName}));
      assert.commandWorked(coll.insertOne({_id: 1}));
      
      assert.commandWorked(db.runCommand({
          applyOps: [
          {
            op : "i",
            ns : coll.getFullName(),
            o : {_id: 34},
            o2 : { _id : 34 },
            rid: NumberLong(1)
          }
        ]
      }));
      assert.eq({_id: 1}, coll.findOne({_id: 1}));
      
      Show
      const collName = "applyOpsCollName" ; const coll = db.getCollection(collName); coll.drop(); assert .commandWorked(coll.runCommand({create: collName})); assert .commandWorked(coll.insertOne({_id: 1})); assert .commandWorked(db.runCommand({ applyOps: [ { op : "i" , ns : coll.getFullName(), o : {_id: 34}, o2 : { _id : 34 }, rid: NumberLong(1) } ] })); assert .eq({_id: 1}, coll.findOne({_id: 1}));
    • Storage Execution 2025-12-8, Storage Execution 2025-12-22
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Non-clustered collections utilizing non-replicated recordIds should not generate oplog entries containing the rid field. The presence of the rid field in the oplog for these collections can lead to data corruption.

      Context

      When the overwrite parameter is set to true (the default for non-clustered collections), an insert oplog containing a rid that points to a document with a different _id than the one in the oplog can result in data corruption. The existing document is replaced, but the indexes, such as the _id index and the index on other fields, incorrectly retain additional entries referencing the overwritten document. These entries point to the new document but the content of the document doesn't match the data on the index.

      Proposed Solution:

      Add an assert to ensure the rid field is not included in oplogs of non-replicated recordIds collections.

            Assignee:
            Yuhong Zhang
            Reporter:
            Ernesto Rodriguez Reina
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: