fix: pass function call result to execute_op query_id during rollback#87
Open
thehecktour wants to merge 1 commit into
Open
fix: pass function call result to execute_op query_id during rollback#87thehecktour wants to merge 1 commit into
execute_op query_id during rollback#87thehecktour 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.
What this fixes
In
attempt_migration_rollback, every rollback operation was being tagged with the same static string as itsquery_id— the string representation of theuuid4function object itself, not a generated UUID.In Python, functions are first-class objects. Writing
uuid4without()is a valid expression — it evaluates to the function itself.str()on a function produces its memory address representation, which is constant for the lifetime of the process.Why this matters
execute_oppassesquery_idaslog_commentin the ClickHouse query settings:log_commentis how ClickHouse tags a query insystem.query_logand how you identify it forKILL QUERY. Without unique IDs per operation, the consequences during a rollback are:system.query_log— impossible to distinguish which step ran, failed, or how long each tookKILL QUERY WHERE log_comment = '...'— they all have the same tagProof it's a typo, not intentional
The forward migration path in the same file already does this correctly:
Same file — one path calls the function, the other doesn't. The inconsistency is the tell.
The bug was likely introduced when
execute_opwas refactored from its original PostHog signature (which passed a UUID string externally) to the current one (which generates it inline). The rollback call was updated to pass the value inline, but the()was dropped in the process, as evidenced by the commented-out original:Change
File:
housewatch/async_migrations/runner.pyOne character. Every rollback operation now gets a proper unique UUID as its
query_id, consistent with how forward migration operations are already handled. 🔧