Skip to content

Re-instate a sane array size limit #971

Closed

Description

@mlucy

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.

Activity

  1. ghost assigned on Jun 10, 2013
  2. mlucy commented on Jun 10, 2013

    @mlucy
    MemberAuthor

    See also issue #969.

  3. jdoliner commented on Jun 10, 2013

    @jdoliner
    Contributor

    Actually maybe we should just expand this to an in memory size limit on all datums.

  4. mlucy commented on Jun 10, 2013

    @mlucy
    MemberAuthor

    That's a slightly harder problem. We do need to do it at some point, though.

  5. mlucy commented on Jun 18, 2013

    @mlucy
    MemberAuthor

    Here's what I think we should do here:

    • 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.
  6. coffeemug commented on Jun 18, 2013

    @coffeemug
    Contributor

    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.

  7. srh commented on Jun 18, 2013

    @srh
    Contributor

    Or just support swapping arrays out to disk...

  8. coffeemug commented on Jun 19, 2013

    @coffeemug
    Contributor

    Or just support swapping arrays out to disk...

    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).

  9. jdoliner commented on Jun 19, 2013

    @jdoliner
    Contributor

    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.

  10. coffeemug commented on Jun 19, 2013

    @coffeemug
    Contributor
  11. mlucy commented on Jun 19, 2013

    @mlucy
    MemberAuthor

    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.

  12. jdoliner commented on Jun 19, 2013

    @jdoliner
    Contributor

    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.

  13. coffeemug commented on Jun 19, 2013

    @coffeemug
    Contributor

    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.

  14. coffeemug commented on Jun 19, 2013

    @coffeemug
    Contributor

    @mlucy -- would it be cool if I move this issue out of 1.7-required?

  15. mlucy commented on Jun 19, 2013

    @mlucy
    MemberAuthor

    @coffeemug -- go for it.

  16. mlucy commented on Jun 21, 2013

    @mlucy
    MemberAuthor

    Moving to backlog since we failed to settle on anything and it isn't that important right now.

  17. mlucy commented on Jul 2, 2013

    @mlucy
    MemberAuthor

    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.

  18. danielmewes commented on Jul 2, 2013

    @danielmewes
    Member

    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.
  19. srh commented on Jul 2, 2013

    @srh
    Contributor

    Those are also justifications for having no limit.

  20. danielmewes commented on Jul 2, 2013

    @danielmewes
    Member

    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)

  21. danielmewes commented on Jul 2, 2013

    @danielmewes
    Member

    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)

  22. mlucy commented on Jul 3, 2013

    @mlucy
    MemberAuthor

    I'll take a look at the code and see how difficult it would be to remove that assumption.

  23. coffeemug commented on Nov 19, 2013

    @coffeemug
    Contributor

    @mlucy -- from what I understand this is fixed. Should we close this issue?

  24. mlucy commented on Nov 20, 2013

    @mlucy
    MemberAuthor

    Closing. The current limit is 100k, but we may get rid of it when we have real per-query memory limits.

  25. coffeemug commented on Nov 22, 2013

    @coffeemug
    Contributor

    I think you forgot to actually click close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions