cockroachdb / cockroachdb/cockroach

schemachanger: add UNDROP TABLE

Open
#145,376 2 comments 0 reactions 0 assignees View on GitHub
A-schema-changes C-enhancement T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Currently, if a user accidentally drops some tables, they can recover via RESTORE or CREATE TABLE AS OF SYSTEM TIME. We could build an alternative approach that doesn't require a backfill: via an UNDROP table cmd that can be run before the gc TTL. For this to work, we'd likely need to refactor DROP to:
- provide some unwinding of all the references dropped [here ](https://github.com/msbutler/cockroach/blob/butler-read-only-fail-upgrade/pkg/sql/drop_table.go#L244)
- delay the dropping of the del range until the ttl for the table has expired by polling its span configs

So, if the user runs UNDROP before we issue a delrange, we could, in theory, skip the del range drop and rebuild the schema graph.

I don't know if this is technically sound, nor do I think this should be prioritized. I'd rather just make restore or index backfills very very fast. But obviously i'm biased and not a PM.

cc @arulajmani

Jira issue: CRDB-49876

Epic CRDB-61003

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.