Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NODE-6231): Add CSOT behaviour for retryable reads and writes #4186

Merged
merged 13 commits into from
Aug 1, 2024
Next Next commit
Add CSOT infinite retry
  • Loading branch information
W-A-James committed Jul 29, 2024
commit f160cd47902f9036ade9e872dd73d9d66a67ac86
9 changes: 5 additions & 4 deletions src/operations/execute_operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,10 @@ async function tryOperation<
session.incrementTransactionNumber();
}

// TODO(NODE-6231): implement infinite retry within CSOT timeout here
const maxTries = willRetry ? 2 : 1;
const maxTries = willRetry ? (timeoutContext.csotEnabled() ? Infinity : 2) : 1;
let previousOperationError: MongoError | undefined;
let previousServer: ServerDescription | undefined;

// TODO(NODE-6231): implement infinite retry within CSOT timeout here
for (let tries = 0; tries < maxTries; tries++) {
if (previousOperationError) {
if (hasWriteAspect && previousOperationError.code === MMAPv1_RETRY_WRITES_ERROR_CODE) {
Expand Down Expand Up @@ -277,7 +275,6 @@ async function tryOperation<
return await operation.execute(server, session, timeoutContext);
} catch (operationError) {
if (!(operationError instanceof MongoError)) throw operationError;

if (
previousOperationError != null &&
operationError.hasErrorLabel(MongoErrorLabel.NoWritesPerformed)
Expand All @@ -286,6 +283,10 @@ async function tryOperation<
}
previousServer = server.description;
previousOperationError = operationError;

// Reset timeouts
timeoutContext.serverSelectionTimeout?.clear();
timeoutContext.connectionCheckoutTimeout?.clear();
Comment on lines +288 to +289
Copy link
Contributor Author

Choose a reason for hiding this comment

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

clear timeouts to ensure correct setting of the serverSelectionTimeoutMS value

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
const enabled = [
'override-collection-timeoutMS',
'override-database-timeoutMS',
'override-operation-timeoutMS'
'override-operation-timeoutMS',
'retryability-legacy-timeouts',
'retryability-timeoutMS'
];

const cursorOperations = [
Expand Down