-
Notifications
You must be signed in to change notification settings - Fork 905
GODRIVER-3181 Read server responses in the background after op timeout. #1719
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
GODRIVER-3181 Read server responses in the background after op timeout. #1719
Conversation
@@ -1620,7 +1620,7 @@ func (op Operation) addClusterTime(dst []byte, desc description.SelectedServer) | |||
// if the ctx is a Timeout context. If the context is not a Timeout context, it uses the | |||
// operation's MaxTimeMS if set. If no MaxTimeMS is set on the operation, and context is | |||
// not a Timeout context, calculateMaxTimeMS returns 0. | |||
func (op Operation) calculateMaxTimeMS(ctx context.Context, rttMin time.Duration, rttStats string) (uint64, error) { | |||
func (op Operation) calculateMaxTimeMS(ctx context.Context, rttMin time.Duration, rttStats string) (int64, error) { |
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.
Change maxTimeMS
to use int64
since that's the wire protocol data type, preventing unnecessary conversions.
// | ||
// Deprecated: BGReadTimeout is intended for internal use only and may be | ||
// removed or modified at any time. | ||
BGReadTimeout = 400 * time.Millisecond |
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.
Use a lower timeout value here (400ms) compared to v1.15 (1s) because users have observed increased database load caused by this feature in some circumstances. Reducing the timeout value reduces the amount of time that server-side operations will continue after a client-side timeout, mitigating the increased database load.
b00d350
to
3b54b57
Compare
40c3d54
to
0864944
Compare
I rebased this to resolve the merge conflicts. |
API Change Report./v2/x/mongo/driver/operationcompatible changes(*Aggregate).OmitMaxTimeMS: added ./v2/x/mongo/driver/topologycompatible changesBGReadCallback: added |
Confirmed that the race detector tests currently fail intermittently in |
@matthewdale I'm seeing panics in a Goroutine sporadically killing our program after this change. |
GODRIVER-3181
Summary
Read server responses in the background after op timeout.
Background & Motivation
Ports #1589 to
master
.