parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

ability to use allowDiskUse on mongo for find and count methods

Open stewones opened this issue 3 years ago • 7 comments
trafficstars

New Feature / Enhancement Checklist

Current Limitation

currently it's not possible to set allowDiskUse as option to queries

Feature / Enhancement Description

according to this comment, starting with mongo v5.12.8 it would be possible to pass allowDiskUse through setOptions

https://github.com/Automattic/mongoose/issues/10177#issuecomment-836868781

await Test.find().sort({ name: 1 }).setOptions({ allowDiskUse: true }).exec();

Example Use Case

query.find({ allowDiskUse: true }).then(function(results) {
  // Request succeeded
}, function(error) {
  // Request failed
});

Alternatives / Workarounds

N/A

3rd Party References

N/A

stewones avatar Jan 06 '22 01:01 stewones

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

That sounds like a good addition, allowDiskUse has been added in MongoDB 4.4.

mtrezza avatar Jan 06 '22 13:01 mtrezza

Yo @mtrezza

Do you think that would be too crazy to implement? I'm willing to set up parse for dev and have a shot

stewones avatar Feb 01 '22 13:02 stewones

I think it would be straight forward to implement. It's just another option that can be passed in Parse.Query which is then passed through to the MongoDB driver. You could take a look at Parse.Query.readPreference for how an option is passed to the driver. You would basically replicate that and rename it Parse.Query.allowDiskUse.

mtrezza avatar Feb 06 '22 15:02 mtrezza

Hello @stewones can you implement it for aggregates too? Otherwise I will do it later.

aclec avatar May 05 '22 07:05 aclec

It seems that no PR has ever been submitted for this issue, so feel free to submit one.

mtrezza avatar May 05 '22 08:05 mtrezza

hey guys, I've left the company I was working for which would benefit from this feature, so completely lost the interest for now. but would love to see this feature added.

stewones avatar May 10 '22 17:05 stewones

alright I need this for a pet project now, looking into 👀

stewones avatar Nov 25 '22 19:11 stewones

got it working for the find method, now need to add tests and support aggregate as well. PR coming in a few hours 🫡

stewones avatar Nov 25 '22 23:11 stewones

@mtrezza

would be super awesome to get some feedback asap on this PR https://github.com/parse-community/Parse-SDK-JS/pull/1619

we gonna need it for the new feature

in order to use allowDiskUse mongo requires at least one sort otherwise an error is thrown by Mongo but ParseError can't recognize it causing [object Object] as a log message, which in turn makes it impossible to figure what's going on.

once that PR ^ is accepted Parse will be able to print those errors like this

Screenshot 2022-11-25 at 21 07 38

stewones avatar Nov 26 '22 00:11 stewones

How is this feature dependent on or related to https://github.com/parse-community/Parse-SDK-JS/pull/1619? That PR seems to be only about making log messages more readable.

mtrezza avatar Nov 26 '22 00:11 mtrezza

Sorry I expressed myself badly, too much excitement 🙈

It's not dependent, actually, it's just frustrating cause Parse should print errors like in that ^ screenshot but it doesn't. So user wants to use allowDiskUse, an error is thrown and they don't know that this option requires a sort. that PR fixes it and other edge cases.. like I got a Parse server running monitored by GCP Error Reporting and I currently can't figure out some errors due to this issue. Error message gets blank.

stewones avatar Nov 26 '22 00:11 stewones

Got it, let me mark this as off-topic, as these comments really belong to the other issue it seems. I reviewed the other PR and posted some thoughts. Let's continue the discussion there.

mtrezza avatar Nov 26 '22 00:11 mtrezza

allowDiskUse is true by default in mongo 6. If Parse let the default option, it will work with an upgrade of mongo version.

aclec avatar Nov 26 '22 13:11 aclec

Maybe it still makes sense to add the option, as there will be deployments running on MongoDB <6 for a while, probably years?

mtrezza avatar Nov 26 '22 13:11 mtrezza

created a draft. it already works with find

https://github.com/parse-community/parse-server/pull/8337

stewones avatar Nov 27 '22 17:11 stewones

That sounds like a good addition, allowDiskUse has been added in MongoDB 4.4.

Do not think, this included the aggregation queries. It only mentions the find and the sort operation.

suhailbw avatar Dec 30 '22 06:12 suhailbw

Could you explain a bit more?

mtrezza avatar Dec 31 '22 09:12 mtrezza