Skip to content
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

refactor: remove cursorState from Cursor and wire protcol methods #2549

Merged
merged 1 commit into from
Sep 29, 2020

Conversation

mbroadst
Copy link
Member

@mbroadst mbroadst commented Sep 25, 2020

Cursors presently have an internal state tracking object called cursorState which has a high degree of coupling with multiple components in the system, and is source of great confusion and bugs. This patch removes the cursorState completely, mounting its relevant properties directly on the CoreCursor type and removing it from the signature of the query, killCursors, and getMore wire protocol methods.

Many changes were required as part of this refactoring, but most notable is cleanup around cursor close. The internal call to kill the cursor raced with the _endsession method, which uncovered a number of failures in our test suite when fixed.

NODE-2810

NOTE: this is based on #2546 , so it will appear to have the same changes until that PR is merged and this one is rebased.

Cursors presently have an internal state tracking object called
`cursorState` which has a high degree of coupling with multiple
components in the system, and is source of great confusion and
bugs. This patch removes the `cursorState` completely, mounting
its relevant properties directly on the `CoreCursor` type and
removing it from the signature of the `query`, `killCursors`,
and `getMore` wire protocol methods.

Many changes were required as part of this refactorinig, but
most notable is cleanup around cursor `close`. The internal call
to kill the cursor raced with the `_endsession` method, which
uncovered a number of failures in our test suite when fixed.

NODE-2810

if (typeof cursorState.session === 'object') {
options.session = cursorState.session;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we want to stop passing the session here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry it looks like we lost your comments somewhere (maybe the force push). So what's going on here is that the wire protocol killCursors command used to take in a cursorState which might have had a session, and now it takes an options which may have a session. The options are passed all the way down to the command method which will use the session there, so there's no need to copy it here any longer

: false;

// get rid of these?
this._limit = limit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_limit and _batchSize seem to be used. What's the purpose of this comment and the deprecation comment above? Are these meant to be private? If so can we use private keyword?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are used, but won't be for much longe (referring to the cursor prototype I discussed in our meeting yesterday). For now, I wanted to keep these around to make @emadum 's work of combining Cursor and CoreCursor easier.

Copy link
Contributor

@reggi reggi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this has a lot of good learnings in it. LGTM

Copy link
Contributor

@emadum emadum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some nice test cleanup in here 👍

@mbroadst mbroadst merged commit fe4821c into master Sep 29, 2020
@mbroadst mbroadst deleted the NODE-2810/remove-cursor-state branch September 29, 2020 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants