You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We used to limit the size of arrays, but I can't seem to find that code any more, so I think it might have disappeared. We should pick a sane limit and re-instate it.
Do the easy thing for now and limit array sizes. Open a separate issue for limiting the size of all data, and limiting the size of arrays by memory footprint rather than length.
I arbitrarily choose 10,000 as the limit, unless someone has a plausible argument for either a higher or lower limit.
Don't let my comment stand in your way of doing the simple thing, but I think limiting the array size to N elements isn't very useful considering the incredibly large range of document sizes we've seen so far (from a few bytes to megabytes). I think we should put in the time and limit the array size by memory footprint -- it would be immensely more useful.
I actually think not doing this is a feature, not a bug. If we implement swapping arrays out to disk we'll make the implementation significantly more complex, but also train users to create large arrays that, instead of failing when they get too big, become progressively slower and less scalable over time. That's not what arrays are for, so I think setting a hard limit on array size is a better option all around (less work and more user-friendly in the long term).
So one downside I see to picking 10,000 as an arbitrary size limit is that if a user happens to be storing an array that size in a document they're going to run in to problems when they try to migrate on the other hand if we did things memory footprint based and picked a cap over 10MB we'd avoid this problem.
Also doing an array size limit like this doesn't actually seem like it addresses the problem that well. The point of this limit is to prevent people from running themselves out of memory or accidentally sending too much stuff over the network but an array of 10,000 numbers really isn't that unreasonable while an array of even 1,000 very large dicts is.
Doing the right thing here and bounding based on size is hard. Not because it's theoretically hard, but because it will require a code audit. The current interface doesn't prevent people from adding data to other data and then increasing the size of the first datum.
Also, I think what we might actually want is per-query memory limits, not per-data-structure memory limits. That might also be easier to implement, because instead of having to audit all our old code to make sure that we aren't updating something after it might have been added to something else, we just need to make the datum_t constructors private and add a helper new_datum.
I'd vote we just move this out of this sprint if it's hard. I don't think this issue is really urgent AFAIK no one has actually hit this yet I think I was the one who initially requested it.
I agree -- I think we'll deal with better cache quotas in 1.8, and this issue seems to belong there rather than in this sprint. This way we can announce them together as memory improvements.
I'm moving this into 1.8-required because I was just looking at our code in arr.cc and a lot of it assumes that the size of an array is less than INT_MAX. We should really assert that, at the very least, somewhere.
I think if this gets implemented, it should definitely be configurable.
There are two things which I don't like about limiting the size of arrays statically:
It is difficult to rule out that there is any use case in which a really huge array might be useful. Even if it goes into the higher GBs.
People will likely not think too much about the size limit up to the point where they hit it and their queries very suddenly start failing. I see a real chance that if somebody ever hits this limit, it is going to happen in a production system. At that point, solving the issue will likely require some fundamental changes to the scheme of the data. The consequence would be very significant downtime.
Now if the limit can be adjusted by the user, this wouldn't actually be a problem. The admin could raise the limit to temporarily work around the issue. While this will lead to more memory consumption, it would remove the sudden "cliff" between a system which is working, and a system which is just failing completely.
Only to some degree.
Having a (configurable) limit has the advabtage of bounding memory utilization. If arrays get too large, the user would receive an error message instead of the server crashing due to failing allocations or the OOM killer terminating it.
If the decision is between a static and no limit, I would be in favor of no limit though.
The other thing which makes the limit on array sizes a bit unsatisfying IMO is the fact that it doesn't actually stop queries from exceeding available memory. There are still loads of other ways to make that happen. A configurable per-query memory limit of course would be absolutely awesome!
One addition: if places in the code assume that arrays are smaller than INT_MAX as @mlucy mentioned and changing (or finding) all of those places is difficult, then of course failing on arrays too large early is still better than failing in bad and unpredictable ways later...
Activity
mlucy commentedon Jun 10, 2013
See also issue #969.
jdoliner commentedon Jun 10, 2013
Actually maybe we should just expand this to an in memory size limit on all datums.
mlucy commentedon Jun 10, 2013
That's a slightly harder problem. We do need to do it at some point, though.
mlucy commentedon Jun 18, 2013
Here's what I think we should do here:
coffeemug commentedon Jun 18, 2013
Don't let my comment stand in your way of doing the simple thing, but I think limiting the array size to N elements isn't very useful considering the incredibly large range of document sizes we've seen so far (from a few bytes to megabytes). I think we should put in the time and limit the array size by memory footprint -- it would be immensely more useful.
srh commentedon Jun 18, 2013
Or just support swapping arrays out to disk...
coffeemug commentedon Jun 19, 2013
I actually think not doing this is a feature, not a bug. If we implement swapping arrays out to disk we'll make the implementation significantly more complex, but also train users to create large arrays that, instead of failing when they get too big, become progressively slower and less scalable over time. That's not what arrays are for, so I think setting a hard limit on array size is a better option all around (less work and more user-friendly in the long term).
jdoliner commentedon Jun 19, 2013
So one downside I see to picking 10,000 as an arbitrary size limit is that if a user happens to be storing an array that size in a document they're going to run in to problems when they try to migrate on the other hand if we did things memory footprint based and picked a cap over 10MB we'd avoid this problem.
Also doing an array size limit like this doesn't actually seem like it addresses the problem that well. The point of this limit is to prevent people from running themselves out of memory or accidentally sending too much stuff over the network but an array of 10,000 numbers really isn't that unreasonable while an array of even 1,000 very large dicts is.
coffeemug commentedon Jun 19, 2013
@jdoliner 👍
mlucy commentedon Jun 19, 2013
Doing the right thing here and bounding based on size is hard. Not because it's theoretically hard, but because it will require a code audit. The current interface doesn't prevent people from adding data to other data and then increasing the size of the first datum.
Also, I think what we might actually want is per-query memory limits, not per-data-structure memory limits. That might also be easier to implement, because instead of having to audit all our old code to make sure that we aren't updating something after it might have been added to something else, we just need to make the
datum_tconstructors private and add a helpernew_datum.jdoliner commentedon Jun 19, 2013
I'd vote we just move this out of this sprint if it's hard. I don't think this issue is really urgent AFAIK no one has actually hit this yet I think I was the one who initially requested it.
coffeemug commentedon Jun 19, 2013
I agree -- I think we'll deal with better cache quotas in 1.8, and this issue seems to belong there rather than in this sprint. This way we can announce them together as memory improvements.
coffeemug commentedon Jun 19, 2013
@mlucy -- would it be cool if I move this issue out of 1.7-required?
mlucy commentedon Jun 19, 2013
@coffeemug -- go for it.
mlucy commentedon Jun 21, 2013
Moving to backlog since we failed to settle on anything and it isn't that important right now.
mlucy commentedon Jul 2, 2013
I'm moving this into 1.8-required because I was just looking at our code in
arr.ccand a lot of it assumes that the size of an array is less than INT_MAX. We should really assert that, at the very least, somewhere.danielmewes commentedon Jul 2, 2013
I think if this gets implemented, it should definitely be configurable.
There are two things which I don't like about limiting the size of arrays statically:
Now if the limit can be adjusted by the user, this wouldn't actually be a problem. The admin could raise the limit to temporarily work around the issue. While this will lead to more memory consumption, it would remove the sudden "cliff" between a system which is working, and a system which is just failing completely.
srh commentedon Jul 2, 2013
Those are also justifications for having no limit.
danielmewes commentedon Jul 2, 2013
Only to some degree.
Having a (configurable) limit has the advabtage of bounding memory utilization. If arrays get too large, the user would receive an error message instead of the server crashing due to failing allocations or the OOM killer terminating it.
If the decision is between a static and no limit, I would be in favor of no limit though.
The other thing which makes the limit on array sizes a bit unsatisfying IMO is the fact that it doesn't actually stop queries from exceeding available memory. There are still loads of other ways to make that happen. A configurable per-query memory limit of course would be absolutely awesome!
-----Original Message-----
From: srh [email protected]
Date: Tue, 02 Jul 2013 15:18:33
To: rethinkdb/[email protected]
Reply-To: rethinkdb/rethinkdb [email protected]
Cc: Daniel [email protected]
Subject: Re: [rethinkdb] Re-instate a sane array size limit (#971)
Those are also justifications for having no limit.
Reply to this email directly or view it on GitHub:
#971 (comment)
danielmewes commentedon Jul 2, 2013
One addition: if places in the code assume that arrays are smaller than INT_MAX as @mlucy mentioned and changing (or finding) all of those places is difficult, then of course failing on arrays too large early is still better than failing in bad and unpredictable ways later...
-----Original Message-----
From: srh [email protected]
Date: Tue, 02 Jul 2013 15:18:33
To: rethinkdb/[email protected]
Reply-To: rethinkdb/rethinkdb [email protected]
Cc: Daniel [email protected]
Subject: Re: [rethinkdb] Re-instate a sane array size limit (#971)
Those are also justifications for having no limit.
Reply to this email directly or view it on GitHub:
#971 (comment)
mlucy commentedon Jul 3, 2013
I'll take a look at the code and see how difficult it would be to remove that assumption.
coffeemug commentedon Nov 19, 2013
@mlucy -- from what I understand this is fixed. Should we close this issue?
mlucy commentedon Nov 20, 2013
Closing. The current limit is 100k, but we may get rid of it when we have real per-query memory limits.
coffeemug commentedon Nov 22, 2013
I think you forgot to actually click close.