Skip to content

DRIVERS-3391: Clarify withTransaction CSOT timeout error with backoff+jitter#1890

Open
nhachicha wants to merge 3 commits intomongodb:masterfrom
nhachicha:nh/backpressure/withTransaction/csot_timeout_error
Open

DRIVERS-3391: Clarify withTransaction CSOT timeout error with backoff+jitter#1890
nhachicha wants to merge 3 commits intomongodb:masterfrom
nhachicha:nh/backpressure/withTransaction/csot_timeout_error

Conversation

@nhachicha
Copy link
Contributor

@nhachicha nhachicha commented Feb 4, 2026

As discussed in https://mongodb.slack.com/archives/C09M7C9EGF4/p1770144090977949

  • Added new prose tests in Client Side Operations Timeout (CSOT) specification.
  • Clarified transactions convenient API behaviour for timeout error handling during backpressure scenarios.

@nhachicha nhachicha self-assigned this Feb 4, 2026
@nhachicha nhachicha changed the title Add prose test to clarify backpressure timeout error logic Clarify withTransaction csot timeout error under backpressure Feb 4, 2026
@nhachicha nhachicha changed the title Clarify withTransaction csot timeout error under backpressure Clarify withTransaction CSOT timeout error under backpressure Feb 4, 2026
@nhachicha nhachicha marked this pull request as ready for review February 4, 2026 03:57
@nhachicha nhachicha requested review from a team as code owners February 4, 2026 03:57
@nhachicha nhachicha requested review from durran and removed request for a team February 4, 2026 03:57
@dariakp
Copy link
Contributor

dariakp commented Feb 5, 2026

@nhachicha @baileympearson Can we add a DRIVERS ticket to the backpressure epic to track and communicate these changes?

@baileympearson baileympearson changed the title Clarify withTransaction CSOT timeout error under backpressure DRIVERS-3391: Clarify withTransaction CSOT timeout error with backoff+jitter Feb 5, 2026

Tests in this section MUST only run against replica sets and sharded clusters with server versions 4.4 or higher.

It is recommended that drivers run these tests with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you seeing flakiness with these tests? Node hasn't had issues and we've had these changes merged for ~2 months, and I don't know that Python has either (@sleepyStick ?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think python has noticed any issues with this

1. `command_started` and `command_failed` events for an `insert` command.
2. `command_started` and `command_failed` events for an `abortTransaction` command.

#### withTransaction applies a single timeout across retries due to transient errors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test fundamentally any different from the unified test timeoutMS is not refreshed for each operation in the callback in transactions-convenient.yml? If there is a difference and we do need a new test - would it be possible to write this as a unified test?

Comment on lines +254 to +257
if (Date.now() - startTime >= timeout) {
throw getCSOTTimeoutIfSet() != null ? createCSOTMongoTimeoutException(error) : createLegacyMongoTimeoutException(e);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (Date.now() - startTime >= timeout) {
throw getCSOTTimeoutIfSet() != null ? createCSOTMongoTimeoutException(error) : createLegacyMongoTimeoutException(e);
}
if (Date.now() - startTime >= timeout) {
throw makeTimeoutError(error);
}

and then maybe define makeTimeoutError above similar to this?

function makeTimeoutError() {
  return getCSOTTimeoutIfSet() != null ? createCSOTMongoTimeoutException(error) : createLegacyMongoTimeoutException(e);
}

We can then just call this wherever we raise timeout errors (there are three places in the pseudocode, I think).

@@ -220,9 +220,12 @@ withTransaction(callback, options) {
this.abortTransaction();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is out of diff: but we also need to raise to clarify the error handling behavior on line 206.

@@ -220,9 +220,12 @@ withTransaction(callback, options) {
this.abortTransaction();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also out of diff, but can you also update the prose description accordingly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants