From b6cc60205530ee2b29da782feb1abe8a9105651e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Thu, 3 Oct 2024 10:05:44 +0200 Subject: [PATCH] fix(restore): skip restoration of additional entities included in DESC SCHEMA WITH INTERNALS As described in the comment. Fixes #4050 --- pkg/service/restore/restore_integration_test.go | 15 +++++++++++++-- pkg/service/restore/schema_worker.go | 7 +++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/service/restore/restore_integration_test.go b/pkg/service/restore/restore_integration_test.go index 36518fb7e..24ba7fb11 100644 --- a/pkg/service/restore/restore_integration_test.go +++ b/pkg/service/restore/restore_integration_test.go @@ -188,6 +188,13 @@ func TestRestoreSchemaRoundtripIntegration(t *testing.T) { m3 = map[query.DescribedSchemaRow]struct{}{} ) for _, row := range srcSchema { + // Scylla 6.3 added roles and service levels to the output of + // DESC SCHEMA WITH INTERNALS (https://github.com/scylladb/scylladb/pull/20168). + // Those entities do not live in any particular keyspace, so that's how we identify them. + // We are skipping them until we properly support their restoration. + if row.Keyspace == "" { + continue + } m1[row] = struct{}{} if opt, ok := objWithOpt[row.Name]; ok { if !strings.Contains(row.CQLStmt, opt) { @@ -200,10 +207,14 @@ func TestRestoreSchemaRoundtripIntegration(t *testing.T) { t.Fatalf("Src schema: %v, is missing created objects: %v", m1, objWithOpt) } for _, row := range dstSchemaSrcBackup { - m2[row] = struct{}{} + if row.Keyspace != "" { + m2[row] = struct{}{} + } } for _, row := range srcSchemaDstBackup { - m3[row] = struct{}{} + if row.Keyspace != "" { + m3[row] = struct{}{} + } } Print("Validate that all schemas are the same") if !maputil.Equal(m1, m2) { diff --git a/pkg/service/restore/schema_worker.go b/pkg/service/restore/schema_worker.go index bf1048f7f..1773ff4ab 100644 --- a/pkg/service/restore/schema_worker.go +++ b/pkg/service/restore/schema_worker.go @@ -141,6 +141,13 @@ func (w *schemaWorker) restoreFromSchemaFile(ctx context.Context) error { var createdKs []string for _, row := range *w.describedSchema { + if row.Keyspace == "" { + // Scylla 6.3 added roles and service levels to the output of + // DESC SCHEMA WITH INTERNALS (https://github.com/scylladb/scylladb/pull/20168). + // Those entities do not live in any particular keyspace, so that's how we identify them. + // We are skipping them until we properly support their restoration. + continue + } if row.Keyspace == "system_replicated_keys" { // See https://github.com/scylladb/scylla-enterprise/issues/4168 continue