Skip to content

Add support for maxTimeMS mongoOption #3018

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

Merged
merged 1 commit into from
Nov 11, 2016

Conversation

TylerBrock
Copy link
Contributor

@TylerBrock TylerBrock commented Nov 4, 2016

We have several enormous collections (think 35 million+ objects). When running parse-dashboard there is no way to prevent users from finding/sorting on criteria having no index. The dashboard doesn't respond, users click to sort the other direction, more slow running queries... eventually the system comes down.

Eventually it would be nice to have parse-dashboard only allow sorting/filtering on indexed columns and on all columns when the collection size is less than 10k objects or something. Even then, there is no guarantee our application's inbound queries are all covered. For example a user in the browser JS console making their own queries.

It would be nice to put a limit on find/count (in MS) by taking advantage of the per-operation $maxTimeMS MongoDB query operator. This is an initial stab at getting it to work.

@@ -60,6 +60,39 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
});
});

fit('find succeeds when query is within maxTimeMS', (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

no fit there buddy :)

Copy link
Contributor Author

@TylerBrock TylerBrock Nov 4, 2016

Choose a reason for hiding this comment

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

yup, already fixed :-( and I fixed the tests failing on mongodb 3.0.x

@TylerBrock TylerBrock force-pushed the add-maxtimems-support branch from bb0e9ca to 19bf63c Compare November 4, 2016 21:30
@facebook-github-bot
Copy link

@TylerBrock updated the pull request - view changes


// MaxTimeMS is not a global MongoDB client option, it is applied per operation.
this._maxTimeMS = mongoOptions.maxTimeMS;
delete mongoOptions.maxTimeMS;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this delete the property from the options being passed in? Not sure if we clone before passing in - perhaps we should shallow clone here if not?

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'm just going to remove the delete altogether, it will be ignored by the driver.

@TylerBrock TylerBrock force-pushed the add-maxtimems-support branch from 19bf63c to 366c72f Compare November 11, 2016 14:42
@facebook-github-bot
Copy link

@TylerBrock updated the pull request - view changes

.then(() => adapter._rawFind('Foo', { '$where': `sleep(${maxTimeMS * 2})` }))
.then(
() => {
done('Find succeeded despite taking too long!');
Copy link
Contributor

Choose a reason for hiding this comment

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

Just spotted this - should we instead call fail('reason') and then done()? Looks like currently the test won't fail when the operation succeeds

Copy link
Contributor

Choose a reason for hiding this comment

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

So should be

fail('Find succeeded despite taking too long!');
done();

@TylerBrock TylerBrock force-pushed the add-maxtimems-support branch from 366c72f to d1cee52 Compare November 11, 2016 15:26
@facebook-github-bot
Copy link

@TylerBrock updated the pull request - view changes

@TylerBrock TylerBrock merged commit e9dfb68 into parse-community:master Nov 11, 2016
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.

4 participants