-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(NODE-6387): Add CSOT support to change streams #4256
Conversation
e4fe9bf
to
ffcb23b
Compare
3591368
to
a645d9f
Compare
2820e4d
to
e5e443d
Compare
src/cursor/abstract_cursor.ts
Outdated
@@ -489,7 +493,7 @@ export abstract class AbstractCursor< | |||
await this.fetchBatch(); | |||
} while (!this.isDead || (this.documents?.length ?? 0) !== 0); | |||
} finally { | |||
if (this.cursorOptions.timeoutMode === CursorTimeoutMode.ITERATION && this.cursorId != null) { | |||
if (shouldRefresh) { |
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.
Since this line is after fetchBatch the value at cursorId could have changed right? so is the stored condition still the same one we want to refresh on?
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.
Yes because the only time that cursorId
is null is when the cursor is uninitialized , but to guard against any changes we make to that logic, we can check for existence of timeoutContext
instead, because they're effectively testing the same thing.
Actually, since we introduced the potential use of an external timeout context, that might not be true. Checking this 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.
Let me know what you find.
It sounds correct; my thinking is that if we've hit an error we should still have a null id because the operation didn't give us one, maybe we still set it to 0 somewhere or this logic runs in either case.
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 only two times we set the cursorId to null are in
AbstractCursor#constructor()
AbstractCursor.rewind()
Anywhere else, we are setting the cursorId
from the server response (which is never null, provided that nothing went wrong server-side), so regardless of where we check the cursorId
, in AbstractCursor.next()/.tryNext()/.hasNext()
, it will still yield the correct behaviour of only calling timeoutContext.refresh()/.clear()
when the cursor is already initialized and in iteration mode.
If it's initially null, then we'd still want to clear the clear the timeout if the cursor gets killed (id set to zero).
test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts
Outdated
Show resolved
Hide resolved
test/integration/client-side-operations-timeout/node_csot.test.ts
Outdated
Show resolved
Hide resolved
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.
LGTM, just request me back when we can resolve the two threads. Moved to team review
test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts
Outdated
Show resolved
Hide resolved
c3f31da
to
4fd4b24
Compare
93a148b
to
fee5ac4
Compare
Description
What is changing?
ChangeStream
ChangeStream.next()
,ChangeStream.hasNext()
,ChangeStream.tryNext()
)MongoOperationTimeoutError
when the internal cursor iteration times outConnection
Testing
Is there new documentation needed for these changes?
Yes, punted to NODE-5688
What is the motivation for this change?
NODE-6387
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript