Repository navigation
Conversation
…'t exist, fix #1651 Signed-off-by: Ryo Kusnadi <ryokusnadi@gmail.com>
Follow-up for #1651 review findings: - serialFreezeTableIndex is a Backuper method sharing isFreezeEngine and isTableOnPlainDisks with AddTableToLocalBackup, so a View, Distributed, Kafka or plain-disk table is never chosen for the serial step; the smallest eligible table is chosen (GetTables sorts by size DESC), an empty table only without freeze_by_part (ALTER TABLE FREEZE increments the counter before iterating parts, FREEZE PARTITION runs per part) - an empty shadow/increment.txt fails every FREEZE in ClickHouse CounterInFile (only a missing file is initialized), remove it and run the first FREEZE serially so clickhouse-server recreates it - create_remote --streaming gets the same serial-first step - name the table in the serial error and log, unit tests cover engines, plain disks, freeze_by_part and the empty counter, add integration TestSerialFirstFreezeOnFreshServer and a ChangeLog entry The counter is global (<path>/shadow/increment.txt in MergeTreeData::freezePartitionsByMatcher), not per disk, so only the default data path is checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DROP DATABASE ... SYNC is a syntax error on ClickHouse 1.1.54394, 19.17, 20.3 and 20.8, so TestSerialFirstFreezeOnFreshServer failed in its cleanup step on those CI versions after all backup checks had passed. env.dropDatabase adds SYNC only for Atomic/Replicated databases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reopened from #1664 by @RyoKusnadi (original fork was deleted); commit cherry-picked onto current master with authorship preserved.
Problem
On a fresh clickhouse-server, the first
create/create_remoteover several tables can fail withcode: 32, File .../shadow/increment.txt is empty. You must fill it manually. It happens once per server lifetime, but it is a failed backup (and a flaky CI run).How it happens: a new server has no
shadow/increment.txt.createfreezes tables in parallel (clickhouse.max_connectionsworkers). Two FREEZE queries race to create the file: one creates it empty, the other locks it first and finds it empty (theCounterInFilerace described in #1651).Cause
createBackupLocalinpkg/backup/create.gostarts all table workers at once, so the first FREEZEs overlap.Fix
Before starting the workers,
serialFreezeTableIndexchecks<default disk path>/shadow/increment.txt. If it is missing (or can't be checked, for example clickhouse-backup runs on another host), the first table that will really run FREEZE is backed up serially, then the rest run in parallel as before. I don't write the file myself, since it belongs to clickhouse-server. The per-table body moved into a local closure so the serial and parallel paths share it.Scope
increment.txtin testflows (open questions in the issue).use_embedded_backup_restoredoesn't use FREEZE and is unaffected.clean --allalready keepsincrement.txt.Testing
TestSerialFreezeTableIndex(temp dirs, no ClickHouse): fresh dir, unreachable path, existing file,doBackupData=false, skipped/schema-only tables, empty list.undefined: serialFreezeTableIndex(test written first).go test ./pkg/backup/ -run TestSerialFreezeTableIndexpasses;go test ./pkg/backup/passes (376 tests);go vet ./pkg/backup/andgofmt -lare clean.Risk
Only the first backup on a server without
increment.txtis a bit slower (one serial FREEZE). When the file can't be checked remotely, everycreatehas one serial FREEZE first.Fixes #1651
🤖 Generated with Claude Code