-
Notifications
You must be signed in to change notification settings - Fork 918
GODRIVER-2348 Make CSOT feature-gated behavior the default #1515
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
+1,977
−2,067
Merged
Changes from 74 commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
76fe99a
GODRIVER-2762 Use minimum RTT for CSOT maxTimeMS calculation instead …
prestonvasquez c96883a
GODRIVER-2762 Clean up rtt monitor code
prestonvasquez 88e9f0d
GODRIVER-2762 Add command-execution.yml
prestonvasquez 85812f6
GODRIVER-2762 Fix typo
prestonvasquez 1a0517c
Merge branch 'master' into GODRIVER-2762
prestonvasquez 49298ee
GODRIVER-2762 PR requests
prestonvasquez 04aeb6d
GODRIVER-2762 Remove reference to RTT90 in max time calc
prestonvasquez 2d61660
GODRIVER-2348 connectTimeoutMS to cover all blocking operations durin…
prestonvasquez 0ba0d69
GODRIVER-2762 Fix rounding, cleanup deadline exceeded error
prestonvasquez bccb529
Merge branch 'master' into GODRIVER-2762
prestonvasquez f7d8111
GODRIVER-2348 merge master
prestonvasquez 698e4e0
GODRIVER-2762 Use args in wait event
prestonvasquez 8b10b54
Merge branch 'GODRIVER-2762' of github.com:prestonvasquez/mongo-go-dr…
prestonvasquez ce0c7c2
Update x/mongo/driver/topology/rtt_monitor.go
prestonvasquez 6095151
Merge branch 'master' into GODRIVER-2762
prestonvasquez a2f0c9a
GODRIVER-2348 Merge 2762
prestonvasquez d10ced0
GODRIVER-2348 merge master
prestonvasquez 9cb8028
Merge branch 'master' into GODRIVER-2348
prestonvasquez 4669d9b
GODRIVER-2466 Implement assertEventCount
prestonvasquez 7aa63f0
GODRIVER-2466 Fix typo
prestonvasquez 45c6725
Merge remote-tracking branch 'origin/GODRIVER-2466' into GODRIVER-2348
prestonvasquez 998b725
GODRIVER-2466 Remove duplicate failpoint warning
prestonvasquez 15c6d42
Merge remote-tracking branch 'origin/GODRIVER-2466' into GODRIVER-2348
prestonvasquez 9af952f
GODRIVER-2348 Update connectTimeoutMS to cover all blocking operation…
prestonvasquez 2d53d6a
GODRIVER-2348 Deprecate socketTimeoutMS
prestonvasquez d2b8c50
Merge branch 'master' into GODRIVER-2348
prestonvasquez 9c17094
Merge branch 'master' into GODRIVER-2348
prestonvasquez d9d61f4
GODRIVER-2348 Remove rw connection timeouts
prestonvasquez 51d6c1b
Merge branch 'GODRIVER-2348' of github.com:prestonvasquez/mongo-go-dr…
prestonvasquez 25368d6
Merge branch 'master' into GODRIVER-2348
prestonvasquez c32af34
GODRIVER-2348 Deprecate wtimeout
prestonvasquez 54abbc5
GODRIVER-2348 Deprecate maxTimeMS
prestonvasquez a4c7211
Merge branch 'master' into GODRIVER-2348
prestonvasquez 49427b3
GODRIVER-2348 Deprecate maxCommitTimeMS
prestonvasquez 4a55e76
GODRIVER-2348 Cont. Deprecating MaxTimeMS
prestonvasquez 9293b84
GODRIVER-2348 Implement server selection logic
prestonvasquez 023a1d1
Merge branch 'master' into GODRIVER-2348
prestonvasquez f6a4f97
Merge branch 'master' into GODRIVER-2348
prestonvasquez 2501fe8
GODRIVER-2348 Cont. implementing Server Selection req
prestonvasquez a56844e
GODRIVER-2348 Remove unused topology struct
prestonvasquez 7b64cee
GODRIVER-2348 Rename maxTimeMS for cursor to maxAwaitTimeMS
prestonvasquez 11d1f3b
GODRIVER-2348 Add retryability-legacy-timeouts back to UST
prestonvasquez 6892b1f
GODRIVER-2348 Resolve connstring merge conflicts
prestonvasquez 15d80e0
GODRIVER-2348 Implement change stream CSOT conditions
prestonvasquez 99b4389
GODRIVER-2348 Remove CSOT-specific context opts
prestonvasquez 9f4a8e5
GODRIVER-2348 Remove debug tools
prestonvasquez e69bc0a
GODRIVER-2348 Extend test coverage for csot
prestonvasquez 16f1027
GODRIVER-2348 Resolve race condition
prestonvasquez 818f7d1
GODRIVER-2348 Resolve merge conflict
prestonvasquez 27ae440
GODRIVER-2348 Refine csot logic
prestonvasquez 2c94bd9
GODRIVER-2348 Fix linting errors
prestonvasquez f65fb19
GODRIVER-2348 Remove lingering comments
prestonvasquez 75e44e2
Merge branch 'master' into GODRIVER-2348
prestonvasquez 4424192
GODRIVER-2348 Fix network error pool test
prestonvasquez 9a5df59
Merge branch 'master' into GODRIVER-2348
prestonvasquez 3043a64
GODRIVER-2348 Resolve PR conversations
prestonvasquez b2e8844
Update internal/csot/csot.go
prestonvasquez 884f2ba
Merge branch 'master' into GODRIVER-2348
prestonvasquez db69938
GODRIVER-2348 Resolve merge conflict
prestonvasquez 058b343
Merge branch 'GODRIVER-2348' of github.com:prestonvasquez/mongo-go-dr…
prestonvasquez 00fb9da
GODRIVER-2348 Do not set transactional wtimeout
prestonvasquez b191ec7
GODRIVER-2348 Merge master
prestonvasquez 755204f
Update mongo/client.go
prestonvasquez 8e26315
Update x/mongo/driver/topology/topology_test.go
prestonvasquez 2aff850
GODRIVER-2348 Resolve various PR issues
prestonvasquez 731aca7
Merge branch 'GODRIVER-2348' of github.com:prestonvasquez/mongo-go-dr…
prestonvasquez 3b40fa4
GODRIVER-2348 Resolve build failure
prestonvasquez 1620f92
GODRIVER-2348 Resolve merge conflicts
prestonvasquez a719b0a
GODRIVER-2348 Merge master
prestonvasquez c58c276
GODRIVER-2348 Use context listener to cancel HB check
prestonvasquez c9475c7
GODRIVER-2348 Use context listener for conn cancelation
prestonvasquez 6d1b1ff
GODRIVER-2348 Resolve merge conflicts
prestonvasquez 6c0fff9
GODRIVER-2348 Update change stream error
prestonvasquez 8725fca
Update internal/integration/index_view_test.go
prestonvasquez dfac280
Merge branch 'master' into GODRIVER-2348
prestonvasquez 62a3216
GODRIVER-2348 Check arch-dependent int max
prestonvasquez 7638477
GODRIVER-2348 Check arch-dependent int max
prestonvasquez 15a0dde
Merge branch 'master' into GODRIVER-2348
prestonvasquez 22a1fba
GODRIVER-2348 Update error phrasing
prestonvasquez 19be315
Merge branch 'GODRIVER-2348' of github.com:prestonvasquez/mongo-go-dr…
prestonvasquez ca9d771
GODRIVER-2348 Fix inequality in max check
prestonvasquez 91c94d6
GODRIVER-2348 Resolve merge conflicts
prestonvasquez 5055c66
Merge branch 'master' into GODRIVER-2348
prestonvasquez 1598385
GODRIVER-2348 defer closing connection context
prestonvasquez 4d1a681
Merge branch 'GODRIVER-2348' of github.com:prestonvasquez/mongo-go-dr…
prestonvasquez fcb2a0a
Merge branch 'master' into GODRIVER-2348
prestonvasquez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,249 @@ | ||
| // Copyright (C) MongoDB, Inc. 2024-present. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| // not use this file except in compliance with the License. You may obtain | ||
| // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| package csot | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "go.mongodb.org/mongo-driver/internal/assert" | ||
| "go.mongodb.org/mongo-driver/internal/ptrutil" | ||
| ) | ||
|
|
||
| func newTestContext(t *testing.T, timeout time.Duration) context.Context { | ||
| ctx, cancel := context.WithTimeout(context.Background(), timeout) | ||
| t.Cleanup(cancel) | ||
|
|
||
| return ctx | ||
| } | ||
|
|
||
| func TestWithServerSelectionTimeout(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| parent context.Context | ||
| serverSelectionTimeout time.Duration | ||
| wantTimeout time.Duration | ||
| wantOk bool | ||
| }{ | ||
| { | ||
| name: "no context deadine and ssto is zero", | ||
| parent: context.Background(), | ||
| serverSelectionTimeout: 0, | ||
| wantTimeout: 0, | ||
| wantOk: false, | ||
| }, | ||
| { | ||
| name: "no context deadline and ssto is positive", | ||
| parent: context.Background(), | ||
| serverSelectionTimeout: 1, | ||
| wantTimeout: 1, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "no context deadline and ssto is negative", | ||
| parent: context.Background(), | ||
| serverSelectionTimeout: -1, | ||
| wantTimeout: 0, | ||
| wantOk: false, | ||
| }, | ||
| { | ||
| name: "context deadline is zero and ssto is positive", | ||
| parent: newTestContext(t, 0), | ||
| serverSelectionTimeout: 1, | ||
| wantTimeout: 1, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "context deadline is zero and ssto is negative", | ||
| parent: newTestContext(t, 0), | ||
| serverSelectionTimeout: -1, | ||
| wantTimeout: 0, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "context deadline is negative and ssto is zero", | ||
| parent: newTestContext(t, -1), | ||
| serverSelectionTimeout: 0, | ||
| wantTimeout: -1, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "context deadline is negative and ssto is positive", | ||
| parent: newTestContext(t, -1), | ||
| serverSelectionTimeout: 1, | ||
| wantTimeout: 1, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "context deadline is negative and ssto is negative", | ||
| parent: newTestContext(t, -1), | ||
| serverSelectionTimeout: -1, | ||
| wantTimeout: -1, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "context deadline is positive and ssto is zero", | ||
| parent: newTestContext(t, 1), | ||
| serverSelectionTimeout: 0, | ||
| wantTimeout: 1, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "context deadline is positive and equal to ssto", | ||
| parent: newTestContext(t, 1), | ||
| serverSelectionTimeout: 1, | ||
| wantTimeout: 1, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "context deadline is positive lt ssto", | ||
| parent: newTestContext(t, 1), | ||
| serverSelectionTimeout: 2, | ||
| wantTimeout: 2, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "context deadline is positive gt ssto", | ||
| parent: newTestContext(t, 2), | ||
| serverSelectionTimeout: 1, | ||
| wantTimeout: 2, | ||
| wantOk: true, | ||
| }, | ||
| { | ||
| name: "context deadline is positive and ssto is negative", | ||
| parent: newTestContext(t, -1), | ||
| serverSelectionTimeout: -1, | ||
| wantTimeout: 1, | ||
| wantOk: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| test := test // Capture the range variable | ||
|
|
||
| t.Run(test.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| ctx, cancel := WithServerSelectionTimeout(test.parent, test.serverSelectionTimeout) | ||
| t.Cleanup(cancel) | ||
|
|
||
| deadline, gotOk := ctx.Deadline() | ||
| assert.Equal(t, test.wantOk, gotOk) | ||
|
|
||
| if gotOk { | ||
| delta := time.Until(deadline) - test.wantTimeout | ||
| tolerance := 10 * time.Millisecond | ||
|
|
||
| assert.True(t, delta > -1*tolerance, "expected delta=%d > %d", delta, -1*tolerance) | ||
| assert.True(t, delta <= tolerance, "expected delta=%d <= %d", delta, tolerance) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestWithTimeout(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| parent context.Context | ||
| timeout *time.Duration | ||
| wantTimeout time.Duration | ||
| wantDeadline bool | ||
| wantValues []interface{} | ||
| }{ | ||
| { | ||
| name: "deadline set with non-zero timeout", | ||
| parent: newTestContext(t, 1), | ||
| timeout: ptrutil.Ptr(time.Duration(2)), | ||
| wantTimeout: 1, | ||
| wantDeadline: true, | ||
| wantValues: []interface{}{}, | ||
| }, | ||
| { | ||
| name: "deadline set with zero timeout", | ||
| parent: newTestContext(t, 1), | ||
| timeout: ptrutil.Ptr(time.Duration(0)), | ||
| wantTimeout: 1, | ||
| wantDeadline: true, | ||
| wantValues: []interface{}{}, | ||
| }, | ||
| { | ||
| name: "deadline set with nil timeout", | ||
| parent: newTestContext(t, 1), | ||
| timeout: nil, | ||
| wantTimeout: 1, | ||
| wantDeadline: true, | ||
| wantValues: []interface{}{}, | ||
| }, | ||
| { | ||
| name: "deadline unset with non-zero timeout", | ||
| parent: context.Background(), | ||
| timeout: ptrutil.Ptr(time.Duration(1)), | ||
| wantTimeout: 1, | ||
| wantDeadline: true, | ||
| wantValues: []interface{}{}, | ||
| }, | ||
| { | ||
| name: "deadline unset with zero timeout", | ||
| parent: context.Background(), | ||
| timeout: ptrutil.Ptr(time.Duration(0)), | ||
| wantTimeout: 0, | ||
| wantDeadline: false, | ||
| wantValues: []interface{}{clientLevel{}}, | ||
| }, | ||
| { | ||
| name: "deadline unset with nil timeout", | ||
| parent: context.Background(), | ||
| timeout: nil, | ||
| wantTimeout: 0, | ||
| wantDeadline: false, | ||
| wantValues: []interface{}{}, | ||
| }, | ||
| { | ||
| // If "clientLevel" has been set, but a new timeout is applied | ||
| // to the context, then the constructed context should retain the old | ||
| // timeout. To simplify the code, we assume the first timeout is static. | ||
| name: "deadline unset with non-zero timeout at clientLevel", | ||
| parent: context.WithValue(context.Background(), clientLevel{}, true), | ||
| timeout: ptrutil.Ptr(time.Duration(1)), | ||
| wantTimeout: 0, | ||
| wantDeadline: false, | ||
| wantValues: []interface{}{}, | ||
| }, | ||
| } | ||
|
|
||
| for _, test := range tests { | ||
| test := test // Capture the range variable | ||
|
|
||
| t.Run(test.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| ctx, cancel := WithTimeout(test.parent, test.timeout) | ||
| t.Cleanup(cancel) | ||
|
|
||
| deadline, gotDeadline := ctx.Deadline() | ||
| assert.Equal(t, test.wantDeadline, gotDeadline) | ||
|
|
||
| if gotDeadline { | ||
| delta := time.Until(deadline) - test.wantTimeout | ||
| tolerance := 10 * time.Millisecond | ||
|
|
||
| assert.True(t, delta > -1*tolerance, "expected delta=%d > %d", delta, -1*tolerance) | ||
| assert.True(t, delta <= tolerance, "expected delta=%d <= %d", delta, tolerance) | ||
| } | ||
|
|
||
| for _, wantValue := range test.wantValues { | ||
| assert.NotNil(t, ctx.Value(wantValue), "expected context to have value %v", wantValue) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.