Skip to content

GODRIVER-2277 Remove causal consistency prose test #10 #879

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

Merged
merged 9 commits into from
Mar 22, 2022
Merged

GODRIVER-2277 Remove causal consistency prose test #10 #879

merged 9 commits into from
Mar 22, 2022

Conversation

prestonvasquez
Copy link
Member

@prestonvasquez prestonvasquez commented Mar 18, 2022

GODRIVER-2277

Prose Test no. 10 in the Causal Consistency Specification, to validate nil operation time when executed in a client session, is outdated per SPEC-1019 which "prohibit[s] unack'd writes in a session".

The work to implement the change in SPEC-1019 for the GODRIVER team was completed by the work done on GODRIVER-52, specifically with PR#77.

Add a TestSessions subtest to ensure that mongo-go-driver errors on unacknowledged writes (i.e. a 0-number write concern) during a session.

Question(s)

  • I've verified through our prose test no. 10 that we get an error when trying to submit an unacknowledged write through a session. Instead of removing the test entirely, do we want to tweak the test to assert that doing an unacknowledged write within a session results in an error?

@prestonvasquez prestonvasquez marked this pull request as draft March 18, 2022 23:29
@@ -193,21 +192,6 @@ func TestCausalConsistency_Supported(t *testing.T) {
assert.NotNil(mt, sentOptime, "expected operation time on command, got nil")
assert.True(mt, currOptime.Equal(*sentOptime), "expected operation time %v, got %v", currOptime, sentOptime)
})
unackWcOpts := options.Collection().SetWriteConcern(writeconcern.New(writeconcern.W(0)))
mt.RunOpts("unacknowledged write", mtest.NewOptions().CollectionOptions(unackWcOpts), func(mt *mtest.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, in what situations does this test fail? It does not fail locally for me against a 5.0 replica set.

do we want to tweak the test to assert that doing an unacknowledged write within a session results in an error?

If this is client-side error (thrown within the driver), then that could be a valuable test. If the server just doesn't support unacknowledged writes with explicit sessions, then I don't think we need to test that behavior on our side.

Copy link
Member Author

@prestonvasquez prestonvasquez Mar 21, 2022

Choose a reason for hiding this comment

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

The test should fail if the 0-number write concern being sent over the wire is acknowledged, which should request[s] no acknowledgment of the write operation.

The error itself is thrown by the *mongo.Collection.InsertOne method, specifically whenever the wire message flag is moreToCome. I can see how we determine this message from the code base, but have no idea why the relationship between unacknowledged writes and moreToCome is 1-1. The server does not explicitly create an error for this and it is technically recommended behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed offline, the moreToCome bit is set on every unacknowledged write when we are not actively batching. As you mentioned, we throw ErrUnacknowledgedWrite here according to the recommended behavior in the spec.

@prestonvasquez prestonvasquez marked this pull request as ready for review March 21, 2022 20:24
Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

Looks good 👍 with one suggestion.

Copy link
Contributor

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

Awesome thanks for the test replacement to maintain coverage 👍

@@ -193,21 +192,6 @@ func TestCausalConsistency_Supported(t *testing.T) {
assert.NotNil(mt, sentOptime, "expected operation time on command, got nil")
assert.True(mt, currOptime.Equal(*sentOptime), "expected operation time %v, got %v", currOptime, sentOptime)
})
unackWcOpts := options.Collection().SetWriteConcern(writeconcern.New(writeconcern.W(0)))
mt.RunOpts("unacknowledged write", mtest.NewOptions().CollectionOptions(unackWcOpts), func(mt *mtest.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed offline, the moreToCome bit is set on every unacknowledged write when we are not actively batching. As you mentioned, we throw ErrUnacknowledgedWrite here according to the recommended behavior in the spec.

@prestonvasquez prestonvasquez merged commit 6ca8e2d into mongodb:master Mar 22, 2022
@prestonvasquez prestonvasquez deleted the GODRIVER-2277.removeCausalConsistencyProseTest10 branch March 22, 2022 00:38
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