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

Using readPreference: secondary in multi-statement transaction returns NotMaster error with TransientTransactionError label

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Sharding
    • Labels:
      None

      Description

      I just ran into the following scenario:
      1) Start a transaction
      2) Do an update. This targets shard A.
      3) Send a find command with readPreference: secondary. This targets the secondary of shard B.
      4) NotMaster is returned with a TransientTransactionError.
      5) The transaction gets retried over and over again with the same behavior.

      Our docs for readPreference say "Multi-document transactions that contain read operations must use read preference primary." (https://docs.mongodb.com/manual/core/read-preference/) but given the above scenario, I'm wondering if we should do better and instead have the router throw some different, non-transient error if it notices that a statement in a multi-shard transaction is sent with readConcern: secondary. Alternatively the router could always upgrade the readPreference to be primary for commands running in a transaction.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: