-
Notifications
You must be signed in to change notification settings - Fork 253
Fix: Apply table mapping in restoreSchemaRegular for DROP/DETACH/CREA… #1273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix: Apply table mapping in restoreSchemaRegular for DROP/DETACH/CREA… #1273
Conversation
…TE operations - Table mapping was not applied during schema restoration - DROP/DETACH operations were targeting original table names instead of mapped names - Added logic to apply RestoreTableMapping before schema operations - Fixes issue where --restore-table-mapping parameter was ignored during --schema restore Issue: When using --restore-table-mapping with --schema flag, the tool would execute DROP/DETACH on the original table name from backup instead of the mapped target table name, causing data loss. The RestoreData function correctly applies mapping, but restoreSchemaRegular did not. This fix ensures consistency across both functions.
|
please stop using vibe-coding if you can't programming and don't understand what exactly was generated |
|
thanks for catching bug anyway, will try to fix it |
|
Are you talking about the treatment in pkg/backup/restore.go being redundant? (408:507) @Slach |
|
My apologies, please excuse my rude words. I just in stress. Was I right about vibe-coded PR? |
|
No, I only used AI to generate the PR description because I couldn’t find any template, and I wanted to provide the correct context. |
|
Ok, yep, too much words for PR description than usual |
…ix-restore-table-mapping-schema
Pull Request Test Coverage Report for Build 19500019936Details
💛 - Coveralls |
fix for #1278
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.