Fix temp-file race between concurrent clickhouse_import_support scripts - #177
Open
jamesqo wants to merge 1 commit into
Open
Fix temp-file race between concurrent clickhouse_import_support scripts#177jamesqo wants to merge 1 commit into
jamesqo wants to merge 1 commit into
Conversation
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
write_clickhouse_config_filenames its temp config file with a second-resolution timestamp in$(pwd):Every script that sources
clickhouse_client_command_line_functions.shfrom the same working directory (e.g.verify-management-state.shand theget_database_currently_in_production.shchild it spawns, both running with cwd = the SSH user's home dir) generates the same filename when they land in the same second. One process's creation (rm -f+touch) or shutdown cleanup then deletes the file out from under the other, and clickhouse-client fails with:The caller then misreads this as "database does not exist" and aborts. Observed failing
import_triage_dag/verify_management_stateon 2026-08-26 (the error timestamp matches the colliding filename's second exactly). A stray zero-byteclickhouse_client_config_2026-07-22-*.yamlin the same home dir is debris from an earlier instance of the same collision.ccclf_database_exists.txt/ccclf_database_table_list.txtare fixed filenames in$(pwd)with the same cross-process collision, without even needing same-second timing.Fix
Name all three temp files by process id instead — concurrent processes cannot share a PID, so no process can collide with (or clean up) another's files. Creation, permissions (600), content checks, and shutdown cleanup are unchanged.
🤖 Generated with Claude Code