Repository navigation
create: run the first FREEZE serially when shadow/increment.txt doesn't exist - #1664
Open
RyoKusnadi wants to merge 1 commit into
Open
RyoKusnadi wants to merge 1 commit into
RyoKusnadi wants to merge 1 commit into
Conversation
…'t exist, fix Altinity#1651 Signed-off-by: Ryo Kusnadi <ryokusnadi@gmail.com>
Author
|
@Slach friendly ping on this one when you have a moment. Happy to change anything. |
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.
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