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

findOneAndUpdate with no-op update does not seem to work against stale reads

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 5.0.18
    • Component/s: None
    • Server Triage
    • ALL
    • Hide

      There's no code snippet at this point, but the idea is:

      1. Start 2 transactions with [write: majority, read: primary, snapshot, causal consistency: true]
      2. Make each of them "read" one document using "fake" findOneAndUpdate
      3. Make each of them update the document another transaction has just "read"
      4. No write conflict happens

      And if we change the step 2 so that findOneAndUpdate actually changes the document, step 4 works as intended, and one of the transactions fails. 

      Show
      There's no code snippet at this point, but the idea is: Start 2 transactions with [write: majority, read: primary, snapshot, causal consistency: true] Make each of them "read" one document using "fake" findOneAndUpdate Make each of them update the document another transaction has just "read" No write conflict happens And if we change the step 2 so that findOneAndUpdate actually changes the document, step 4 works as intended, and one of the transactions fails. 

      The's this part of a documentation:

      https://www.mongodb.com/docs/manual/core/transactions-production-consideration/#in-progress-transactions-and-stale-reads

      However, when we tried to use this trick, it only proved to be working as intended if the update actually changes something in the document.

      Otherwise, despite being used exactly as in the example, such operation did not, in the test scenario, trigger a write conflict that would trigger a retry for a transaction.

       

      Could some other factors be relevant which are absent from the documentation? I'm willing to provide as full a context as I can.

            Assignee:
            backlog-server-triage [HELP ONLY] Backlog - Triage Team
            Reporter:
            petr.ivanov.s@gmail.com Peter Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: