-
Notifications
You must be signed in to change notification settings - Fork 2
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
Call stack size exceeded with r.args
#11
Comments
@Calavoow you can already pass an array to .getAll(r.args(ids)) The explicit That being said, I would not recommend passing 100k IDs into a It would be better to split the IDs up into batches of maybe 100-1000 or so on the client-side, and then issuing one such |
I'm going to close this since the functionality already exists. |
@danielmewes Unfortunately, the Plus this is an issue that is caused by the way RDBOp in the js library handles its incoming arguments. It expects variadic arguments. And this is precisely not possible if you have 100k arguments. And no matter how the input is transformed, to construct an AST you will still have to call RDBOp to create the operator for the selection query. |
We've found RethinkDB can become unresponsive when doing updates across a large set of documents. As Daniel recommended I would definitely batch on the client side instead of attempting to update all 100,000 at once. I can share some JS code we are using for that if you would find it helpful. |
For now I work around this issue by chunking the ids into lists of 10k ids and doing updates with those. From my profiling the more ids the better the performance really. Although marginal at 1k+. But it greatly simplifies some of the query construction code if we can make a query in one step. Instead of working with a list of queries. |
@Calavoow |
@danielmewes Yes, I did. Here is a minimal example: > r.db('test').table('test').getAll(r.args(Array(1e6).fill(0)))
RangeError: Maximum call stack size exceeded
at ... |
Hmm interesting. It's possible that we can change something in the JavaScript driver to make this work. Let me rename the issue and re-open it... |
r.args
Renamed from "Support for batch selections" to "Call stack size exceeded with |
Putting into backlog for now because passing a very high number of arguments into a single |
In the case where we want to update 100k documents by id at once, we want to perform a selection on 100k ids. However, the JavaScript library throws an Error when constructing a
getAll(...ids)
whereids.length === 1e6
:To resolve this error I made a proof of concept modification to the ast.coffee library file that supports such large operations without giving an error. It is available here: https://gist.github.com/Calavoow/714705fa6bdeeb2479af6f2db531be76/. When calling
getAll(ids)
(note: no rest arguments) the query completes successfully. Thus RethinkDB itself is able to handle this operation, but the JavaScript interface is not.Of course this poses is an issue for indices that are arrays. But I think it would be a good addition to support large selections so that batch updates do not have to be chunked. Honestly, to us it seems that
getAll
should rather take indices as elements of an array rather than arguments. Since it maps a list of ids to a list of results. It would be the list analogue ofget
. I.e.getAll = [ids].map(get)
. Alternatively, another operator could be introduced requiring the ids as a list. For example agetBatch
function.The text was updated successfully, but these errors were encountered: