-
Notifications
You must be signed in to change notification settings - Fork 915
GODRIVER-3172 Read response in the background after an op timeout. #1589
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
Changes from 2 commits
cc0711c
77023e6
552158c
c4f3abb
9eca4f4
69502a1
49d7f3d
9c4a0cb
832e502
baa75c5
3dbf254
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -377,7 +377,9 @@ func (e Error) NamespaceNotFound() bool { | |
|
||
// ExtractErrorFromServerResponse extracts an error from a server response bsoncore.Document | ||
// if there is one. Also used in testing for SDAM. | ||
func ExtractErrorFromServerResponse(doc bsoncore.Document) error { | ||
// | ||
// Set isCSOT to true if "timeoutMS" is set on the Client. | ||
func ExtractErrorFromServerResponse(doc bsoncore.Document, isCSOT bool) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest not using a bool here and instead pass in the context and use csot.IsTimeoutContext(ctx) within decodeResult. This ensures that the source of CSOT-ness is derived from a context. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, will do. |
||
var errmsg, codeName string | ||
var code int32 | ||
var labels []string | ||
|
@@ -514,14 +516,28 @@ func ExtractErrorFromServerResponse(doc bsoncore.Document) error { | |
errmsg = "command failed" | ||
} | ||
|
||
return Error{ | ||
err := Error{ | ||
Code: code, | ||
Message: errmsg, | ||
Name: codeName, | ||
Labels: labels, | ||
TopologyVersion: tv, | ||
Raw: doc, | ||
} | ||
|
||
// If CSOT is enabled and we get a MaxTimeMSExpired error, assume that | ||
// the error was caused by setting "maxTimeMS" on the command based on | ||
// the context deadline or on "timeoutMS". In that case, make the error | ||
// wrap context.DeadlineExceeded so that users can always check | ||
// | ||
// errors.Is(err, context.DeadlineExceeded) | ||
// | ||
// for either client-side or server-side timeouts. | ||
if isCSOT && err.Code == 50 { | ||
err.Wrapped = context.DeadlineExceeded | ||
} | ||
|
||
return err | ||
} | ||
|
||
if len(wcError.WriteErrors) > 0 || wcError.WriteConcernError != nil { | ||
|
Uh oh!
There was an error while loading. Please reload this page.