Draft
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Mongo::Error::PoolTimeout does not exist; replace with StandardError which covers all connection-related errors (SocketError, pool checkout timeouts, NoServerAvailable, etc.).
Per DRIVERS-3391 / transactions-convenient-api spec, withTransaction must propagate a TimeoutError (wrapping the last transient error as .cause) when the CSOT deadline is exhausted, instead of re-raising the raw error. Changes to lib/mongo/session.rb: - Callback raises TransientTransactionError + deadline expired: raise TimeoutError in CSOT mode, re-raise original in non-CSOT mode. - Commit raises UnknownTransactionCommitResult + deadline expired: same. - Commit raises TransientTransactionError + deadline expired: same. - Backoff (regular and overload) would exceed deadline: use new make_timeout_error_from helper — CSOT wraps last_error with cause, non-CSOT raises last_error directly (fixes incorrect TimeoutError that was raised in non-CSOT mode before this change). - Commit overload backoff would exceed deadline: raise TimeoutError in CSOT mode, re-raise in non-CSOT mode. - Add make_timeout_error_from private helper implementing the makeTimeoutError(lastError) pseudocode from the spec. Uses an inner begin/rescue to wire .cause when called outside a rescue block. New spec/mongo/session/with_transaction_timeout_spec.rb covers all eight code paths as unit tests with stubbed time control (no real server needed).
The test expected TimeoutError from a non-CSOT with_transaction call. Per the spec, non-CSOT mode re-raises the original error directly. Add timeout_ms: 5000 to enable CSOT so the test matches its intent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.