$_internalApplyOplogUpdate does not allow shard key updates outside of txns

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

      1. Enable retryWrites in a client.
      2) Perform a shard key update via internalApplyOplogUpdate (outside a txn) to move a document across shards.
      3) Check that it fails with `write exception: write errors: [Must run update to shard key field in a multi-statement transaction or with retryWrites: true.].`

      Show
      1. Enable retryWrites in a client. 2) Perform a shard key update via internalApplyOplogUpdate (outside a txn) to move a document across shards. 3) Check that it fails with `write exception: write errors: [Must run update to shard key field in a multi-statement transaction or with retryWrites: true.] .`
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 0

      Problem
      Currently, the server returns this error:

      write exception: write errors: [Must run update to shard key field in a multi-statement transaction or with retryWrites: true.]
      

      even if a user performs a shard key update outside a txn with $_internalApplyOplogUpdate with retryWrites enabled. A normal updateOne() command (ex: executed by the Go driver) does not encounter the error in the same circumstances.

      mihai.andrei@mongodb.com notes:
      I think this is a bug in DocumentSourceInternalApplyOplogUpdate. In particular, when performing an update, we populate the value of _allowShardKeyUpdatesWithoutFullShardKeyInQuery and obtain it from an UpdateRequest. It's not clear whether we actually have an UpdateRequest set up in DocumentSourceInternalApplyOplogUpdate that could supply this information.

      This seems to affect 8.0. It could affect other versions too.

      Impact
      Fixing this bug ensures that shard key updates performed with $_internalApplyOplogUpdate can be run outside txns. This impacts C2C because mongosync relies on this operator. C2C is trying to stop using txns to boost performance.

            Assignee:
            Unassigned
            Reporter:
            Ajay Vijayakumar
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: