Fix: Apply table mapping in restoreSchemaRegular for DROP/DETACH/CREA… #1273
+360
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
--restore-table-mappingworkflow so that schema and data restores both target the mapped table names, preventing accidental drops of the original table and the subsequent "… is not created" failure.transaction_archive:transaction_archive_v4anddb.table:newdb.newtable) so they are stored in a consistent form and applied everywhere in the restore pipeline.Context
Restoring
m_views_tables.transaction_archivewith--restore-table-mapping transaction_archive:transaction_archive_v4previously dropped the target table (transaction_archive_v4), created it during schema restore, but the data phase still probed ClickHouse for the original name. That caused the restore to abort with'm_views_tables.transaction_archive' is not created, leaving data un-restored.Root Cause
restoreSchemaRegularoperated on metadata that already carried the mapped name, whilerestoreDataRegularcontinued to query ClickHouse (and validate presence) using the original identifier. BecauseGetTablesnever sawtransaction_archive_v4under the old pattern, the data phase declared the table missing even though schema creation succeeded.Solution Details
prepareRestoreMapping) so both CLI formats (bare table anddb.table) collapse to the canonical table key.restoreDataRegularto:GetTables.checkMissingTablesbefore erroring out.checkMissingTablesto consider original, mapped, and reverse-mapped combinations and to re-populate its cache from ClickHouse on demand.restoreSchemaRegularintact per upstream guidance; all fixes are isolated to mapping ingestion and data-phase validation.Testing
GOCACHE=$(pwd)/.gocache go test ./pkg/backup -run TestRestorem_views_tables.transaction_archive_v4without missing-table errors.Rollout Notes
make build-docker+docker build … --target image_short).--restore-table-mappingwill pick up the fix automatically; no config updates needed.