Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5925

Don't Allow non-Primary Read Preference in Transaction

    • 2
    • 0
    • Not Needed
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      In the Transactions spec unified test, we get this error because we allow a read preference of secondary to be supplied to the default transaction options:

      [2024/02/12 13:40:07.660]   6) Transactions Spec Unified Tests
      [2024/02/12 13:40:07.660]        transaction-options
      [2024/02/12 13:40:07.660]          readPreference inherited from defaultTransactionOptions:
      [2024/02/12 13:40:07.660]      AssertionError: Operation find succeeded but was not supposed to
      [2024/02/12 13:40:07.660]       at executeOperationAndCheck (test/tools/unified-spec-runner/operations.ts:932:12)
      [2024/02/12 13:40:07.660]       at processTicksAndRejections (node:internal/process/task_queues:95:5)
      [2024/02/12 13:40:07.660]       at async runUnifiedTest (test/tools/unified-spec-runner/runner.ts:197:9)
      [2024/02/12 13:40:07.660]       at async Context.<anonymous> (test/tools/unified-spec-runner/runner.ts:288:11)

      Use Case

      As a... Node.js Driver User
      I want... (what is the desired change)
      So that... (why is the change desired)

      User Impact

      • Small

      Dependencies

      • N/A

      Unknowns

      • How to figure out when a read operation is attempted within a transaction? (Spec says we only throw this error when a read is attempted, not when the transaction is created)
        • Solution: Create CommandisReadOperation boolean helper
        • e.g. command.find || command.count || command.aggregate || command.distinct
        • ^^ Unsure if these are all the read operations, will confirm in kickoff

      Acceptance Criteria

      Implementation Requirements

      • The driver currently always sets the read preference to primary, it needs to be updated to raise an error if not.
        • The spec states: If a read is attempted and the transaction’s read preference is not Primary drivers MUST raise an error containing the string "read preference in a transaction must be primary"

      Testing Requirements

      • Unskip transactions unified spec test marked with TODO(NODE-5925)

      Documentation Requirements

      Follow Up Requirements

      • N/A

       

            Assignee:
            aditi.khare@mongodb.com Aditi Khare
            Reporter:
            durran.jordan@mongodb.com Durran Jordan
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: