-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-4034 Allow snapshot reads through sessions #807
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
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.
A few comments after an initial read. Functionality looks sound, just a few minor suggestions regarding the API.
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.
This is looking like a great start!
I have not done a line-by-line review, but I have high level questions about:
- Can we hide the API for setting
atClusterTime
on a read concern? - Can we handle
atClusterTime
similarly toafterClusterTime
to simplify how the read concern is appended?
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.
Refactored slightly to append snapshot to read_concern in _mongoc_client_session_append_read_concern
. This seems simpler and more accurate to me; thanks for the suggestion @kevinAlbs.
Implemented the one prose test, too (CDRIVER-4037). I had mentioned offline there may be Evergreen changes for the test to set minSnapshotHistoryWindowInSeconds
on the server, but I'm unsure if this is strictly necessary.
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.
I still need to review the prose test, but this is looking great. Modeling this from causal consistency seems much simpler!
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.
Looks like the prose test no longer requires that we set minSnapshotHistoryWindowInSeconds
, so it should be all set to review.
MONGOC_ERROR_TRANSACTION_INVALID_STATE, | ||
"Transactions are not supported in snapshot sessions"); | ||
ret = false; | ||
GOTO (done); |
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.
This new error is an alteration to the spec accompanied by a new spec test "StartTransaction fails in snapshot session".
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.
Fantastic work. LGTM with a minor test tweak. Let's wait until https://github.com/mongodb/specifications/pull/1022/files/dfb2472e96e1e3f4f374eb526c5190c8282239b0..e1e0672414ff7756de2a2fb9a5d4b7ddea7c1066 is merged to merge this in case there are any spec / test changes to add.
is_snapshot = | ||
is_read_command && mongoc_session_opts_get_snapshot (&cs->opts); | ||
is_snapshot = is_find_aggregate_distinct && | ||
txn_state == MONGOC_INTERNAL_TRANSACTION_NONE && |
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.
No need to change. But IIUC, this transaction check should be unnecessary. It is impossible to start a transaction on a session with snapshot enabled.
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.
Yep! Now that we explicitly error in mongoc_client_session_start_transaction
when snapshot is enabled on the session, I believe this check is pointless. Removed.
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.
LGTM besides what @kevinAlbs mentioned
CDRIVER-4034
Adds
MONGOC_SESSION_SNAPSHOT
flag option tomongoc_session_opt_t
. Setting this flag will mean:atClusterTime
in the reply cursoratClusterTime
will be stored as new fieldssnapshot_time_timestamp
andsnapshot_time_increment
on themongoc_client_session_t
atClusterTime
set to thesnapshot_time
stored on the client session.These changes will allow users to read from a single point in time (a snapshot) during a session.
Adds new
at_cluster_time_timestamp
andat_cluster_time_increment
fields to read concern (along with getters) and a newmongoc_read_concern_set_at_cluster_time
setter. Allows settingMONGOC_SESSION_SNAPSHOT
withisSnapshot
in the unified test runner. Syncs sessions spec tests.