Skip to content
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

Vertically shard tables into existing keyspace #3142

Closed
tirsen opened this issue Sep 7, 2017 · 3 comments
Closed

Vertically shard tables into existing keyspace #3142

tirsen opened this issue Sep 7, 2017 · 3 comments

Comments

@tirsen
Copy link
Collaborator

tirsen commented Sep 7, 2017

We're not sure if we're going to need this feature but it would be interesting to explore how much work it would be to support it.

We're preparing to do a vertical split of our major database and we're having some anxieties around which tables should go into the keyspace that is going to be sharded.

If we make the wrong decision and accidentally leave some tables behind could Vitess potentially support moving tables from a keyspace to an already existing keyspace?

It seems like it wouldnt be too hard to move tables into an unsharded keyspace. Could Vitess also support moving tables into a sharded keyspace? I.e. doing a split clone of a single table and then setting up a filtered replication relationship of a single table into multiple existing shards.

@alainjobart
Copy link
Contributor

We've been asked about this a few times, it would be a nice feature to have. A couple comments:

  • in all the resharding workflows we have (vertical splits, horizontal resharding - both split and merge), the destination shard is always empty before we switch to it. The main reason for this is we can turn off the QueryService before the switch, so we're sure no DML makes it there when it shouldn't. However, in this case, all we need is to blacklist the tables that are being migrated on the destination shard before we migrate them, to have the same guarantees (the same way we blacklist tables right after they've been migrated on the source shards). So this change can be made somewhat easily.

  • as far as moving tables from an unsharded keyspace to a sharded keyspace, the first guarantee we'd need is that we know the keyspace_id (or can compute it) on the source shards, so it can be inserted in the statements, or computed from the rows if using RBR. Once that's established, filtered replication needs to be changed a bit to support both table list and keyspace_id filters at the same time (right now it does one or the other). Then we can set this up.

None of these changes are really hard, it's just a matter of coding the policies, and implementing an end-to-end test. Filtered replication itself is very easy to configure, supports multiple streams from any random source, and overall 'just works'. Migrating the 'served types' is also very easy: mark the source read-only, wait for filtered replication to catch up, move the topology records, mark the destination read-write.

@tirsen
Copy link
Collaborator Author

tirsen commented Sep 9, 2017

I'm glad to hear that this doesn't sound too hard if it's something we're going to need in the future.

@ajm188 ajm188 removed the P3 label Mar 9, 2023
frouioui pushed a commit to planetscale/vitess that referenced this issue Nov 21, 2023
…xisting vreplication rows copied to local counter if resuming from another tablet (vitessio#3143)

* backport of 3142

* Adjust for v17

Signed-off-by: Matt Lord <[email protected]>

---------

Signed-off-by: Matt Lord <[email protected]>
Co-authored-by: Matt Lord <[email protected]>
frouioui pushed a commit to planetscale/vitess that referenced this issue Mar 26, 2024
@mattlord
Copy link
Contributor

I'm going to close this as done via the MoveTables command: https://vitess.io/docs/concepts/move-tables/

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

No branches or pull requests

5 participants