-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Transactions
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
- Change Node.js Transactions readPreference page to reflect the fact that we currently only support primary as the readPreference for transactions
Follow Up Requirements
- N/A
- is related to
-
NODE-5924 Improper Modification of Read Concern in Command Post Send
- Backlog