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

fix(sessions): move active session tracking to topology base #1665

Merged
merged 21 commits into from
Feb 23, 2018

Conversation

daprahamian
Copy link
Contributor

Part of HELP-5834

Cannot be merged right now, as it needs a new release of mongodb-core

Moves the tracking of active sessions to the topology base.
Doing this allows us to ensure that all active and pooled
sessions are ended when the topology closes, and that implicit
sessions are tracked.

Part of HELP-5384
@daprahamian daprahamian changed the title WIP: fix(sessions): transfer control of session management to session pool WIP: fix(sessions): move active session tracking to topology base Feb 21, 2018
…essions

A hook that executes both during and after each test, ensuring that
no sessions are leaked.

This will cause A LOT of failures, since anything that does not
properly call client.close will register as a leak.
Crud Spec tests were never calling client.close
Tests were not calling client.close().
This test doesn't do anything. And I have a feeling that with
our new approach to options management, we don't want it to
do what it thinks it should be doing
Fixing tests in generator examples that do not properly call client.close.

Still need to fix leak in rename exmaple
Fixing tests in promise examples that do not properly call client.close.

Still need to fix leak in rename exmaple
Fixing tests in cursor tests that do not properly call client.close.
Fixing tests in db tests that do not properly call client.close.
Fixes tests in operation examples that do not properly call client.close

Still need to fix actively leaking sessions
These sessions will be cleaned up by close, but to make the
session leak tests pass, we manually close these sessions
Copy link
Member

@mbroadst mbroadst left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, just want an answer on two particular questions

});

// We need to wash out all stored processes
if (forceClosed === true) {
Copy link
Member

Choose a reason for hiding this comment

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

hmm doesn't look like this code made it up to the base class, was this accidentally removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That code was already here


client.close();
done();
collection.dropIndex('a_1').then(
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd prefer to use .then/.catch vs this form if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.catch is technically not part of A+, so if someone swaps in another A+ promise library, it could break.

const MongoClient = require('../../lib/mongo_client');
const ServerSessionPool = core.Sessions.ServerSessionPool;

(() => {
Copy link
Member

Choose a reason for hiding this comment

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

why is this wrapped in an IIFE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it actually have to be. I'll remove it.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure A+ matters anymore now that this is part of the spec. Take a look here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Specifications, everything that supports Promises supports catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll change that :)

@daprahamian daprahamian changed the title WIP: fix(sessions): move active session tracking to topology base fix(sessions): move active session tracking to topology base Feb 23, 2018
@daprahamian
Copy link
Contributor Author

@mbroadst This has passed CI, and should be good to merge (though we may want to remove the hardcoded mongodb-js/mongodb-core tag)

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.

2 participants