pg_shard icon indicating copy to clipboard operation
pg_shard copied to clipboard

Removing existing shards should be easier

Open jberkus opened this issue 11 years ago • 6 comments

We need a function for dropping all shards of a particular table. Otherwise the process of dismantling a sharded table in order to recreate it can be quite complex.

jberkus avatar Dec 04 '14 22:12 jberkus

Two quick questions to help define this feature:

  • In the ideal implementation of this feature, would the "prototype" table on the master also be dropped, or just its shards?
  • Would the user experience be better by intercepting DROP TABLE commands against distributed tables, or would that be misleading (i.e. should we just have a custom function)?

jasonmp85 avatar Dec 04 '14 23:12 jasonmp85

Jason,

From an ideal perspective, we would not include dropping the master table. One of the main reasons to drop the shards is so that you can make a change to the master table because you forgot something before you created the shards. It would also parallel how a master is created. Thus you'd have create table --> create master --> create shards --> drop shards --> drop master --> drop table. Obviously, we'll eventually need to implement a way to modify sharded tables as well.

And yes, you should block dropping the master table unless it's been rendered not a master. From experiment, if you drop the master table it gets you in a state which isn't easily resolved short of dropping all of the databases involved.

jberkus avatar Dec 04 '14 23:12 jberkus

Got it. You don't want the master table dropped, so intercepting DROP TABLE is not ideal. Just a function to drop the shards (and their ephemera: sequences, constraints, etc.) from workers and remove shard records from the master's metadata.

jasonmp85 avatar Dec 05 '14 00:12 jasonmp85

You, you mean automatically intercepting DROP TABLE and dropping the shards instead? No, I don't want to do that. It would be tricky, and could be a huge foot-gun. Having multiple steps is better, so that users realize that they are deleting all data on all shards.

jberkus avatar Dec 05 '14 00:12 jberkus

Just as a note, this also came up in our conversations with Neustar.

samay-sharma avatar Aug 28 '15 11:08 samay-sharma

This issue was moved to citusdata/citus#119

ozgune avatar Feb 03 '16 18:02 ozgune