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

    • Type: Icon: Bug Bug
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Sharding
    • Server Development Platform
    • Fully Compatible
    • ALL

      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.

            Assignee:
            backlog-server-devplatform [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
            Reporter:
            matthew.saltz@mongodb.com Matthew Saltz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: