Skip to content

Commit

Permalink
feat(restore): deliberately check for table existence
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal-Leszczynski committed Sep 17, 2024
1 parent e9210ab commit 129a4e8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/service/restore/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,21 @@ func (w *worker) initUnits(ctx context.Context) error {
return errors.New("no data in backup locations match given keyspace pattern")
}

tables, err := w.client.AllTables(ctx)
if err != nil {
return errors.Wrap(err, "get all tables")
}
for _, u := range units {
for i, t := range u.Tables {
// Verify that table exists
if !slices.Contains(tables[u.Keyspace], t.Table) {
return errors.Errorf(
"table %s.%s, which is a part of restored backup, is missing in the restored cluster. "+
"Please either exclude it from the restore (--keyspace '*,!%s.%s'), or first restore its schema (--restore-schema)",
u.Keyspace, t.Table, u.Keyspace, t.Table,
)
}
// Collect table tombstone_gc
mode, err := w.GetTableTombstoneGCMode(u.Keyspace, t.Table)
if err != nil {
return errors.Wrapf(err, "get tombstone_gc of %s.%s", u.Keyspace, t.Table)
Expand Down

0 comments on commit 129a4e8

Please sign in to comment.