Skip to content

Sharding while keeping docs available.  #1774

Closed

Description

@wojons

Would be great if having a replica of a table and then sharding will shard from one replica while allowing reads and writes to still fall on the other members and then when the rebalancing is done with the first group it then does the next. Just would be great for rebalaning live data sets.

Activity

  1. coffeemug commented on Dec 17, 2013

    @coffeemug
    Contributor

    This was originally part of #223, but no longer is. Moving to subsequent for now. I'll be doing more shuffling of issues tonight, so I might move to backlog depending on how things turn out. This might make it in before the LTS release.

  2. danielmewes commented on Jan 28, 2014

    @danielmewes
    Member

    Here's a solution which highly reduces the downtime. There would still be something like a second of downtime, depending on the speed of the nodes and the network.

    This is what we could do:

    1. Split shards, without changing their node assignment. Everything remains available
    2. Make the machines which should end up holding the shards secondaries for those shards. The node that currently has the data remains the primary, everything remains available.
    3. Once a shard has been backfilled, we initiate a "hand over" procedure:
      The primary places a special "take over" message at the end of the write queue. At the same time, it stops accepting new queries (except outdated_ok reads). The shard is unavailable until the write queue has drained. That should usually be pretty fast, but can take a moment if the network or disk i/o is very slow.
    4. When the secondary receives the "take over" message, it updates the blueprint and makes itself the new primary for the shard. The new primary is promoted through the directory and the shard becomes fully available again.
    5. Merge shards on the new primaries if necessary

    There are a few details that need to be sorted out, e.g. what happens if a node crashes in the middle of the hand over. Overall it sounds like it could be relatively easily implemented within our current clustering system.

    I'm not sure if it is possible to avoid the last moment of downtime. It seems (theoretically) tricky, because one way or the other any existing gap (in terms of processed writes) between the old primary and the new one has to be closed before we can switch over to a new primary.

  3. coffeemug commented on Jan 28, 2014

    @coffeemug
    Contributor
  4. added 5 commits that reference this issue on May 14, 2014
  5. larkost commented on May 21, 2014

    @larkost
    Collaborator

    I have a test for this on the branch larkost/1774-online-sharding-test, up for review 1496.

  6. added 6 commits that reference this issue on Jun 4, 2014
  7. 3 remaining items

  8. timmaxw commented on Jul 17, 2014

    @timmaxw
    Member

    I agree with the comment by @danielmewes above: this could be done without major changes to the clustering system. In particular, incremental backfills are not a prerequisite.

  9. barosl commented on Jul 18, 2014

    @barosl
    Contributor

    Also, I want to note that some non-relational databases including Couchbase and Cassandra are already capable of rebalancing without availability loss. We really need this!

  10. coffeemug commented on Jul 18, 2014

    @coffeemug
    Contributor

    @barosl -- we're on it!

  11. nickpoorman commented on Aug 8, 2014

    @nickpoorman

    +1

  12. thelinuxlich commented on Aug 27, 2014

    @thelinuxlich

    +1

  13. modified the milestones: , subsequent on Sep 29, 2014
  14. danielmewes commented on Aug 27, 2015

    @danielmewes
    Member

    The strategy described here is implemented in 2.1.
    For paving over the last few seconds of unavailability when switching over shards, we need to implement something like #4331 . Closing this, since it's 90% done and we have a separate issue to follow up for the remaining 10%.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions