-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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-3392): enable snapshot reads on secondaries #2897
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving some notes from out meeting:
2d6c3d4
to
e89a431
Compare
…ests for snapshot-sessions
… error sessions spec tests
3ed05eb
to
73378fa
Compare
@@ -86,6 +86,8 @@ export function executeOperation< | |||
session = topology.startSession({ owner, explicit: false }); | |||
} else if (session.hasEnded) { | |||
return cb(new MongoDriverError('Use of expired sessions is not permitted')); | |||
} else if (session.snapshotEnabled && !topology.capabilities.supportsSnapshotReads) { | |||
return cb(new MongoDriverError('Snapshot reads require MongoDB 5.0 or later')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to use a more specific error here now that they are available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compat and InvalidArgument are still not available so I think leaving the DriverError in there would make sense for now.
if (options.snapshot === true) { | ||
this[kSnapshotEnabled] = true; | ||
if (options.causalConsistency === true) { | ||
throw new MongoDriverError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to use a more specific error here now that they are available?
@@ -257,6 +280,10 @@ class ClientSession extends TypedEventEmitter<ClientSessionEvents> { | |||
* @param options - Options for the transaction | |||
*/ | |||
startTransaction(options?: TransactionOptions): void { | |||
if (this[kSnapshotEnabled]) { | |||
throw new MongoDriverError('Transactions are not allowed with snapshot sessions'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to use a more specific error here now that they are available?
@@ -86,6 +86,8 @@ export function executeOperation< | |||
session = topology.startSession({ owner, explicit: false }); | |||
} else if (session.hasEnded) { | |||
return cb(new MongoDriverError('Use of expired sessions is not permitted')); | |||
} else if (session.snapshotEnabled && !topology.capabilities.supportsSnapshotReads) { | |||
return cb(new MongoDriverError('Snapshot reads require MongoDB 5.0 or later')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compat and InvalidArgument are still not available so I think leaving the DriverError in there would make sense for now.
Description
A base implementation of snapshot sessions per latest spec (NODE-3392, NODE-3393 and NODE-3394).
NOTE: Some spec tests are skipped due to test runner issues with session setup.