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

feat(NODE-3011): Load Balancer Support #2909

Merged
merged 6 commits into from Aug 3, 2021
Merged

Conversation

durran
Copy link
Member

@durran durran commented Jul 15, 2021

No description provided.

@durran durran force-pushed the NODE-3011/load-balancer-support branch 3 times, most recently from b8c5ac1 to c536a22 Compare July 16, 2021 14:13
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

I got through almost half of the PR, going to take a fresh look at the rest of it Monday; meanwhile, some thoughts/questions

package.json Show resolved Hide resolved
src/cmap/connect.ts Show resolved Hide resolved
src/cmap/connect.ts Outdated Show resolved Hide resolved
src/cmap/connection.ts Show resolved Hide resolved
src/cmap/connection.ts Outdated Show resolved Hide resolved
src/cmap/errors.ts Outdated Show resolved Hide resolved
src/cmap/metrics.ts Outdated Show resolved Hide resolved
test/tools/runner/index.js Outdated Show resolved Hide resolved
@dariakp dariakp added the Team Review Needs review from team label Jul 19, 2021
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

Some more questions/comments, still not quite finished with the PR because I want to take a very close look at connection pool and sessions changes

src/error.ts Outdated Show resolved Hide resolved
src/cursor/abstract_cursor.ts Outdated Show resolved Hide resolved
src/cursor/abstract_cursor.ts Show resolved Hide resolved
src/cursor/abstract_cursor.ts Show resolved Hide resolved
src/operations/command.ts Outdated Show resolved Hide resolved
test/unit/cmap/metrics.test.js Show resolved Hide resolved
test/unit/mongo_client_options.test.js Show resolved Hide resolved
test/unit/cmap/stream_description.test.js Show resolved Hide resolved
test/unit/cmap/stream_description.test.js Show resolved Hide resolved
test/unit/cmap/stream_description.test.js Show resolved Hide resolved
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.

Did a full read through and left a few nit comments - I'll follow up with a final pass once some of the active comments on the PR have been resolved. Very nice work here! 👍

src/transactions.ts Outdated Show resolved Hide resolved
test/functional/spec-runner/index.js Outdated Show resolved Hide resolved
@durran durran requested review from emadum and dariakp July 20, 2021 18:19
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

I went through and resolved the comments that were fully addressed; there are still a few that don't have replies (they might have gotten hidden by github on the main page) and some others that are open for discussion

src/cmap/connection_pool.ts Outdated Show resolved Hide resolved
test/unit/cmap/stream_description.test.js Show resolved Hide resolved
src/cmap/connection.ts Show resolved Hide resolved
test/unit/mongo_client_options.test.js Show resolved Hide resolved
src/utils.ts Show resolved Hide resolved
src/sessions.ts Outdated Show resolved Hide resolved
src/sessions.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

I just merged in the changes stream test changes, so you can sync those in making the PR a bit smaller.
Got some nits and some more concept questions here:

src/cmap/connect.ts Outdated Show resolved Hide resolved
src/cmap/connect.ts Show resolved Hide resolved
src/cmap/connection.ts Show resolved Hide resolved
src/cmap/connection_pool.ts Show resolved Hide resolved
src/cmap/connection_pool.ts Outdated Show resolved Hide resolved
test/functional/unified-spec-runner/runner.ts Outdated Show resolved Hide resolved
test/functional/unified-spec-runner/runner.ts Outdated Show resolved Hide resolved
test/functional/change_stream_spec.test.js Outdated Show resolved Hide resolved
test/manual/load-balancer.test.js Outdated Show resolved Hide resolved
test/tools/mock.js Outdated Show resolved Hide resolved
@durran durran requested a review from nbbeeken July 22, 2021 14:13
@durran durran force-pushed the NODE-3011/load-balancer-support branch from b996d70 to b8687dd Compare July 23, 2021 13:53
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

My review request got cleared early I think, there are still comments outstanding (maybe collapsed by GH) I resolved what's been addressed hopefully that makes things more visible

src/utils.ts Outdated Show resolved Hide resolved
src/sdam/server.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

I went through and resolved all of my comments that didn't require follow up. There's a few things left on outstanding TODOs, but I think we're pretty close

@dariakp dariakp self-requested a review July 23, 2021 18:29
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

Accidentally cleared my review, resetting to "request changes" for the unresolved comments

@durran durran requested review from nbbeeken and dariakp July 26, 2021 12:14
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

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

Just following up on a couple of questions, resolved most outstanding comments

src/sessions.ts Show resolved Hide resolved
src/cursor/abstract_cursor.ts Show resolved Hide resolved
test/functional/unified-spec-runner/runner.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

@durran durran changed the title NODE-3011: Load Balancer Support feat(NODE-3011): Load Balancer Support Jul 28, 2021
@durran durran requested review from nbbeeken and dariakp July 29, 2021 14:09
@dariakp
Copy link
Contributor

dariakp commented Jul 29, 2021

LGTM pending merge conflict resolution and green tests

@durran durran force-pushed the NODE-3011/load-balancer-support branch from 453fc4c to a1f4489 Compare July 30, 2021 14:28
@durran durran force-pushed the NODE-3011/load-balancer-support branch 6 times, most recently from 212cc48 to 78a8b9b Compare July 30, 2021 22:30
@durran durran marked this pull request as ready for review July 30, 2021 22:30
@durran durran force-pushed the NODE-3011/load-balancer-support branch 7 times, most recently from 302eef1 to a7c188a Compare August 2, 2021 15:29
src/cursor/abstract_cursor.ts Show resolved Hide resolved
@@ -79,6 +79,10 @@ export class AggregateOperation<T = Document> extends CommandOperation<T> {
}
}

get isCursorCreating(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems it would be better suited to be an aspect. If we could refactor to that it would be great but also something we can defer as well.

Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need this on operations classes? The cursor design is such that subclasses of AbstractCursor implement their own initialization which execute an operation, so we should have all the context we need about which operations create cursors without explicitly adding that context to operations classes. Is there a reason you can't move the check in executeOperation into the AbstractCursor call to _initialize ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well the addition of this was specifically for retry behaviour, and I wanted to keep all the retry related code in the same place and not have it scattered in multiple places.

Copy link
Member Author

@durran durran Aug 2, 2021

Choose a reason for hiding this comment

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

Also because of the findOne case - it doesn't directly instantiate a cursor, it calls collection.find in its operation which means that the session in that case it not owned by the cursor as executeOperation creates the implicit session, not cursor._initialize.

Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored in a026ce4 to use aspects.

Copy link
Contributor

Choose a reason for hiding this comment

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

What tests were failing without this condition? I tried running the tests locally without the creates_cursor aspect and all passed. There are some skips so maybe my environment is incomplete. (I have both multi and single env variables)

Copy link
Member Author

@durran durran Aug 3, 2021

Choose a reason for hiding this comment

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

No tests fail without this condition, but it leaks the connection each time findOne retries. This is because findOne calls executeOperation, which itself creates an implicit session with the owner being a symbol. Then inside its execute method it calls collection.find, which creates a cursor with the already created implicit session. The connection is pinned at the connection pool level because find is a pinnable operation, and then when the cursor exhausts it does not unpin because the cursor is not the owner of the session. So the connection remains pinned to the session.

Copy link
Member Author

Choose a reason for hiding this comment

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

Screenshot 2021-08-03 at 16 18 31

Here are the extra 2 checked out connections from the findOne retries at the end of the test run.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do agree in this case that the pin should never have occurred, but until we refactor the operation layer it's always going to be pinned here because we pin on connection checkout from the pool and the find command is pinnable.

Copy link
Member Author

Choose a reason for hiding this comment

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

@durran durran requested a review from nbbeeken August 2, 2021 18:35
@durran durran force-pushed the NODE-3011/load-balancer-support branch from 363d41b to 9168bbc Compare August 2, 2021 20:30
@durran durran force-pushed the NODE-3011/load-balancer-support branch from 9168bbc to 8ab4cfa Compare August 3, 2021 14:17
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.

Couple of small suggestions but this is looking good to me. 🥇

test/functional/unified-spec-runner/runner.ts Outdated Show resolved Hide resolved
src/sdam/server.ts Show resolved Hide resolved
nbbeeken and others added 2 commits August 3, 2021 15:52
Co-authored-by: Eric Adum <eric.adum@mongodb.com>
Co-authored-by: Eric Adum <eric.adum@mongodb.com>
@nbbeeken nbbeeken merged commit c554a7a into 4.0 Aug 3, 2021
@nbbeeken nbbeeken deleted the NODE-3011/load-balancer-support branch August 3, 2021 20:12
ljhaywar pushed a commit that referenced this pull request Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
5 participants