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-3392): enable snapshot reads on secondaries #2897

Merged
merged 16 commits into from
Jul 12, 2021

Conversation

dariakp
Copy link
Contributor

@dariakp dariakp commented Jul 8, 2021

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.

@dariakp dariakp changed the title chore: move non-unified sessions tests to legacy folder; fix readme feat(NODE-3392): snapshot sessions Jul 9, 2021
Copy link
Contributor

@nbbeeken nbbeeken left a 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:

src/sessions.ts Outdated Show resolved Hide resolved
src/sessions.ts Outdated Show resolved Hide resolved
src/sessions.ts Outdated Show resolved Hide resolved
src/sessions.ts Outdated Show resolved Hide resolved
src/sessions.ts Outdated Show resolved Hide resolved
@dariakp dariakp force-pushed the NODE-3392/snapshot-reads-on-secondaries branch from 2d6c3d4 to e89a431 Compare July 9, 2021 19:32
@dariakp dariakp force-pushed the NODE-3392/snapshot-reads-on-secondaries branch from 3ed05eb to 73378fa Compare July 12, 2021 14:59
@@ -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'));
Copy link
Contributor Author

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?

Copy link
Contributor

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(
Copy link
Contributor Author

@dariakp dariakp Jul 12, 2021

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');
Copy link
Contributor Author

@dariakp dariakp Jul 12, 2021

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?

@dariakp dariakp added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 12, 2021
src/sessions.ts Outdated Show resolved Hide resolved
@@ -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'));
Copy link
Contributor

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.

@dariakp dariakp requested a review from nbbeeken July 12, 2021 19:05
@nbbeeken nbbeeken requested a review from emadum July 12, 2021 19:06
@nbbeeken nbbeeken removed the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 12, 2021
@nbbeeken nbbeeken added the Team Review Needs review from team label Jul 12, 2021
@nbbeeken nbbeeken marked this pull request as ready for review July 12, 2021 19:28
@nbbeeken nbbeeken changed the title feat(NODE-3392): snapshot sessions feat(NODE-3392): enable snapshot reads on secondaries Jul 12, 2021
@nbbeeken nbbeeken merged commit 523e05c into 4.0 Jul 12, 2021
@nbbeeken nbbeeken deleted the NODE-3392/snapshot-reads-on-secondaries branch July 12, 2021 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants