-
Notifications
You must be signed in to change notification settings - Fork 918
GODRIVER-3322 Apply client-level timeout to UploadFromStreamWithID #1782
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
API Change ReportNo changes found! |
}) | ||
|
||
// Create a new MongoClient with timeoutMS=10. | ||
cliOptions := options.Client().SetTimeout(10).ApplyURI(mtest.ClusterURI()) |
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.
Did you mean
.SetTimeout(10 * time.Millisecond)
?
|
||
// If the operation-level context is not respected, then the client-level | ||
// timeout will exceed deadline. | ||
ctx, cancel := context.WithTimeout(context.Background(), 500*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.
Can we use:
.SetTimeout(10 * 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.
The goal of this test is to ensure that an operation-level context is actually used. Otherwise, this test would fail.
}, | ||
}) | ||
|
||
// Create a new MongoClient with timeoutMS=10. |
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.
It will be better to update the comment to describe the code more accurately.
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.
Do you have something in mind? This comment is taken from the prose test: https://github.com/mongodb/specifications/tree/master/source/client-side-operations-timeout/tests#6-gridfs---upload
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.
Never mind, it looks good now.
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 may have missed something, but is the "timeoutMS=10" still accurate after bf50559? Where is the timeout set?
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 good! 👍
ee199ea
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 good overall with a question about the comment.
}, | ||
}) | ||
|
||
// Create a new MongoClient with timeoutMS=10. |
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 may have missed something, but is the "timeoutMS=10" still accurate after bf50559? Where is the timeout set?
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.
👍
GODRIVER-3322
Summary
bucket.UploadFromStream
andbucket.UploadFromStreamWithID
will pre-maturely cancel a context if a client-level timeout is set since the latter method creates the context and defers cancelation.We should not cancel the client-scoped contexts after returning a download stream. Instead, keep the
cancel()
function on the stream objects and call it whenClose()
orAbort()
are called. See GODRIVER-3325 for a more robust and long-term solution.Background & Motivation
Discovered dogfooding evergreen.