Repository navigation
Conversation
…o behaviour change
Fails on purpose: the reference states the correct behaviour. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Needs the failpoints of the probe commit. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Needs the failpoints of the probe commit. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Needs the failpoints of the probe commit. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Needs the failpoints of the probe commit. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Needs the failpoints of the probe commit. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Needs the failpoints of the probe commit. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Fails on purpose: the reference states the correct behaviour. Needs the failpoints of the probe commit. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Each test states the correct behaviour and fails today. A listed test reports SKIPPED instead of FAIL, and NOT_FAILED once the defect is fixed, which flags the entry for removal. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
A line starting with whitespace is a comment and text after a test name is ignored, so the reason can live beside the entries instead of only in review. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Workflow [PR], commit [9556eba] Summary: ❌
AI ReviewSummaryPR #124485 adds five failpoints and an isolated integration module for existing Missing context / blind spots
Final Verdict✅ Approve — no new inline findings or remaining code changes requested by this review. Current integration CI results remain pending. |
Three rules: a test that arms a fail point must be tagged no-fasttest; a stateless test must not modify the server data on disk, so the torn first store case is dropped and belongs in an integration test; and a test name must not contain "fail". Co-Authored-By: Claude Opus 5 <[email protected]>
Lets a test stop the server between the sync of txn_version.txt.tmp and its rename to txn_version.txt. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Rows inserted outside a transaction are lost if the server stops after txn_version.txt.tmp is synced and before it is renamed. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Two ways this module could report nothing instead of a failed reproduction: - `requests` with `timeout=None` waits forever and `clickhouse-client` waits `DEFAULT_QUERY_TIMEOUT` (600 s). A request still running in a `ThreadPoolExecutor` worker keeps pytest alive at exit whatever `pool.shutdown(wait=False)` says, because `concurrent.futures` joins its non-daemon workers through an atexit hook. Every request now carries `QUERY_TIMEOUT`, and each future waits a little longer than that so the request's own error reaches the test instead of a `TimeoutError`. - `xfail(strict=True)` is satisfied by any failure. The hook in `_pytest/skipping.py` absorbs any exception in any phase, so a leaked session, a transport error or a broken module fixture all report as expected failures -- a module that executed no test body reported `12 xfailed` in 18 s. `raises=AssertionError` narrows it to the assertion each test is about; preconditions and infrastructure raise something else on purpose. Measured on the four shapes: a broken module fixture is an ERROR instead of twelve xfails, a wrong exception type is a FAILURE, the test's own assertion is the expected failure, and a passing test still fails on `strict`. Signed-off-by: Mikhail Filimonov <[email protected]>
|
Fixed in 2c007f4. Both timeout blockers were real, and wider than reported: 84 of the 95 requests here ran on "Slow" no longer holds. The 88 s this comment first reported is now 27 s. Two tests accounted for 21 s and 43 s of it, only because they sat out a timeout to observe a hang. They now wait for |
`raises=AssertionError` narrows the exception type, not the reason. Setup checks, the state a failpoint was supposed to create, and positive controls were `assert` too, so a reproduction that never reached its defect reported a clean expected failure. 20 of the 38 assertions were not about a defect. They now raise `Precondition`, which is not an `AssertionError`. `Instance.query` defaults to `DEFAULT_QUERY_TIMEOUT` (600 s), so 84 of the 95 requests here had no bound that any budget in this module could hold, and a polling loop whose own requests are unbounded has no bound either. Every request goes through `q`/`q_error` with an explicit timeout, and `poll` hands each predicate the time left, floored at `MIN_REQUEST_TIMEOUT`. `restart_clickhouse` enforces no overall deadline: `wait_start` runs ten 30 s readiness attempts before it looks at its budget, and `stop_clickhouse` waits on `llvm-symbolizer` with no deadline at all. `restart_server` starts the process with `wait_start=False` and polls readiness itself. `session_id` built the name from the epoch current when it was called, so a worker outliving its test would send its next request into the following test's session. `in_session` resolves the name at submit time, `workers` waits for what it submitted, and teardown kills a statement still running before rolling back -- a statement holds its session exclusively, so the rollback would answer `SESSION_IS_LOCKED` and leave a transaction open, pinning part cleanup for every later test. The unloaded-commit test assumed the updating thread parks after the commit reaches Keeper. It wakes on its own, so it can park before: `latest + 1` is then not the held commit's CSN and the test reproduces the raised-snapshot defect instead. It now requires, over `system.zookeeper`, that the entry is in the log and the loaded snapshot has not moved. 12 xfailed in 117 s, each on its own assertion in its own call phase. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
A Keeper entry does not say a commit is in unknown state: `TransactionManager::commitTransaction` injects the fault after `current_zookeeper->multi`, so the CSN node exists either way. A normally finalized but unloaded commit passed, and the mutation then hung on the raised-snapshot defect (ClickHouse#124488) instead. The test now waits for `TransactionManager` to log that it postponed finalization, counting lines from a baseline because one log serves the whole module. A failed `SELECT 1` is not evidence that the server aborted. The uncommitted-creation test now requires the process to be gone and a new `creation_csn is not set` line in the log or `stderr.log`. `settled` hands back whether the statement was ever running. A request that never reached the server used to read as a hang; it is now a `Precondition`. What remains is that elapsed time cannot separate "stuck" from "slower than 30 s", which is stated where the number is defined. `start_clickhouse` honours `wait_start=False` only on the branch where no process is left, and `stop_clickhouse` logs a failed kill instead of reporting it. So a stop that did not take put the ten-attempt readiness batch back in the path, and a surviving old server would have been accepted as the restarted one -- with the durability test then reading rows nothing had killed. `restart_server` kills the process itself and proves it is gone before launching. Teardown replaces a server it cannot clean instead of only reporting it, because pytest runs the tests after a teardown error anyway. 12 xfailed in 117 s, each on its own assertion. The unknown-state probe is verified in the run's log: one line, carrying `Fault injected: forced unknown state after commit`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
Part selection records `PostponeReasons::VERSION_NOT_VISIBLE` when a part is not visible at the mutation's start CSN, and `system.mutations.parts_postpone_reasons` carries it out as `Not visible by transaction version`. That is the mutation defect itself, where elapsed time equally described a slow server. A comment here claimed no such state exists; it was wrong. Waiting for that reason instead of the budget also ends the wait as soon as it appears. The module drops from 88 s to 27 s: the two hang reproductions were 21 s and 43 s and are now 1.7 s and 2.0 s. Also: - A repaired `SET TRANSACTION SNAPSHOT` that waits for the log no longer falls through into the raised-snapshot defect, where the fix would have kept reporting this test as xfailed. - The abort path waits for the creation-CSN line in the log rather than for the process. The exception is logged before `abort`, and fatal reporting may run for minutes (`SignalHandlers.cpp`), so waiting on the process first called a real abort an unrelated failure. - `server_process_count` replaces `get_process_pid`, which answers `None` both for no match and for a probe that did not run -- the second reading as a dead server. - A killed statement must fail because it was killed; other errors from it propagate. - Cleanup that cannot restore the server marks the module, and the next test refuses to run rather than reproduce anything against it. A request that outlived its test counts as contamination: a restart cannot cancel the client thread, whose next call would recreate its session. - The log pause is released before the pool is drained, so the join cannot wait on a commit the test is itself holding. 12 xfailed in 27.21s, each on its own assertion. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
A statement that finished between the observation that it was stuck and the kill was not stuck, so the caller's conclusion about it does not hold. `require_cancelled` accepted that silently and the test went on to report its defect. 12 xfailed in 27.12s. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
The three `DETACH`/`ATTACH` reproductions passed on the CI asan+ubsan runner and so failed as `XPASS(strict)`, while this same tree reproduces the defect on Release and on an asan+ubsan build locally, both on a standalone server and under the integration harness. The run's server logs are no longer reachable, so the tests now print the state the reproduction turns on: `system.parts`, `system.detached_parts`, the part directories and every `txn_version.txt` under them, before and after the reload, plus the injected error in one line. pytest prints a captured log for `XPASS(strict)`, so the next CI run says which link broke. What that state is: the rollback of a failed non-transactional removal marks `creation_csn = RolledBackCSN` in memory only, because `VersionMetadataOnDisk::storeInfoUnlocked` defers the store for a part that `VersionInfo::wasInvolvedInTransaction` says was never in a transaction. The empty covering parts keep the final directory names `transaction.renameParts` gave them and carry no `txn_version.txt`, so the loader reads them as prehistoric and they cover the live parts. `test_failed_drop_partition_survives_reload_when_rollback_mark_fails` also gets the positive control it lacked: both injections raise `CANNOT_WRITE_TO_FILE` and the statement reports only the first, so its precondition held for the single-fault path next door as well. The second injection fires inside `~MergeTreeData::Transaction`, which logs the exception and swallows it, so that log line is the only observable, and it lands after the client already has the error. Related: ClickHouse#124485 (comment) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
Three reproductions reported `XPASS(strict)` on `amd_asan_ubsan` while reproducing on every local build. The sanitizer build is not the reason: the same CI configuration (`-DSANITIZE=address,undefined`, `CMAKE_BUILD_TYPE=None`) reproduces all twelve locally, on a standalone server and in the integration harness. The reproductions depend on the empty covering parts of the failed removal staying on disk until the reload, and nothing kept them there. The rollback hands them to `removePartsFromWorkingSet` with `clear_without_timeout`, which sets `remove_time = 0`, so `grabOldParts` is free to take them whatever `old_parts_lifetime` says. `SYSTEM STOP MERGES` does not cover it either: cleanup runs on its own thread under `ActionLocks::Cleanup`. Once the directories are gone the reload finds only the original parts, keeps the rows, and the test reports a fix that did not happen. So `merges_stopped` becomes `merges_and_cleanup_stopped` and adds `SYSTEM STOP CLEANUP`. That also closes a second hole: a background part removal reaches `NonTransactionalRemovalLocks::store` with `LockKind::REMOVAL` like the statement under test, and can take the single-shot failpoint first. `two_parts` now polls cleanup every second instead of every 30, so a reproduction that loses this guard fails at once rather than depending on how long the test took, and each reload test first requires the rolled-back parts to still be on disk. Both directions were run on an ASan+UBSan build, with five seconds between the failed statement and the `DETACH`: - cleanup left running: `2 failed`, both on that new precondition -- the CI result, reproduced. - cleanup stopped: `12 xfailed`. `test_failed_drop_partition_survives_reload_when_rollback_mark_fails` is not one of the two: when the rollback's own mark fails, the covering parts stay `PreActive`, which `grabOldParts` does not touch. Its `XPASS` in CI, and the server death in the same run, are still unexplained. `require_injected_failure` now matches the injected message and not every `CANNOT_WRITE_TO_FILE`, and `reload_state` selects `_state` -- without it `system.parts` returns no `PreActive` part (`StoragesInfo::getParts`) -- and prints the contents of each `txn_version*` file rather than its name. Related: ClickHouse#124485 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
Seven places where a run could report something other than what the test claims to measure. A mutation verdict no longer trusts a postponement reason it may have outlived. `selectPartsToMutate` clears `current_parts_postpone_reasons` at the start of each pass, so the reason read right after releasing what the mutation waited for describes the pass before that: a repaired server that is about to proceed would be killed and reported as stuck. The verdict waits its budget out and reads the reason at the end. The lowered-snapshot reproduction requires the cleanup thread to have looked at the part while the snapshot was held. `grabOldParts` stamps `last_removal_attempt_time` on every part it examines, before testing whether a transaction can still see it, so that is the chance the defect needs. A run that never gave it one passed both assertions on a server that still removes the part. Merges stop before the inserts that make the two parts, not after: the module-wide stop locks the tables that exist when it runs, so a merge of the two rows could leave the removal batch holding a single part, with no second part for the failpoint to fail after. The double-fault control names its own table. Both the failpoint and its log line are global, so the bare message counted a mark that failed anywhere, including a mark of another test's part. A logical error is now expected of one test by name instead of the whole module. `cluster.shutdown` can only exempt the entire run, which also hides a logical error from an unrelated code path. The `<Fatal>` check stays exempt, and says why: the abort of a logical error writes a stack of which one line carries the message, so counting cannot tell it from an unrelated crash. `table_path` requires the table to have one data path rather than reading the first of several. A repaired ClickHouse#124488 reports what to do about it. That test cannot turn the repair into a passing expected failure, because everything after that point measures a different defect. Verified on an ASan+UBSan build: `12 xfailed`. Related: ClickHouse#124485 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
Four reproductions accepted state that predates the window they measure. - The mutation verdict read `parts_postpone_reasons` without knowing which selection pass wrote it. `selectPartsToMutate` rebuilds the map per pass, so the reason the paused transaction log justified outlived its release. `require_fresh_mutation_pass` arms `mt_select_parts_to_mutate_no_free_threads` and waits for `No free threads in pool`, which only a pass after that call can write. - `SYSTEM STOP CLEANUP` cancels an `ActionBlocker` that `IMergeTreeCleanupThread::run` tests once, before `iterate`, so a round already past it still removed the empty covering parts. `wait_for_no_cleanup` waits for the table's task to stop executing in `system.background_schedule_pool`. - The lowered-snapshot test accepted any non-zero `last_removal_attempt_time`. `StorageMergeTree::truncate` cleans up synchronously, so the stamp could be from a round that ran while the truncating transaction still protected the part. It now takes a baseline and requires a newer attempt. Its setup also ran with cleanup live, and the transactional `TRUNCATE` sets `remove_time = 0`, so nothing held the part between that commit and the lowered snapshot: cleanup is stopped until the snapshot is set. - Only the whole run could be exempted from the `<Fatal>` check, which hid an unrelated fatal report behind an intentional restart. The exemption is now per test, as the `LOGICAL_ERROR` one already was. 12 xfailed on an ASan+UBSan build of `538719e18bb`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
A fresh `last_removal_attempt_time` only said a cleanup round examined the part. `grabOldParts` stamps that time before any test, so a round that found the part removable and then skipped it under `NON_UNIQUE_OWNERSHIP` -- the reference the poll's own read of `system.parts` holds -- satisfied the precondition, and the assertions then passed on a server that does remove a part a lowered snapshot sees. Require `removal_state` to name the visibility test instead, with the attempt time only to date it. 12 xfailed on an ASan+UBSan build of `538719e18bb`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
`last_removal_attempt_time` is written at the top of `grabOldParts` and `removal_state` only after the test that stopped the round, and `system.parts` reads the two columns separately. A read taken while a round is in flight could pair this round's attempt time with the previous round's reason, so a server that goes on to remove the part satisfied the precondition. Give cleanup one round at a time and read both columns with cleanup stopped and the round drained; a round that ended in `NON_UNIQUE_OWNERSHIP` now has to be beaten by the next one. 12 xfailed on an ASan+UBSan build of `538719e18bb`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
`default_session_timeout` is 60 s, inside the waits these reproductions take. An expired session is dropped with its transaction rolled back, and the next request opens a new one silently: the test then reads the table outside the transaction it believes it is in, and the result it asserts on is the defect's. Every session request now carries `session_timeout = 3600`, and every request after the first in a session carries `session_check`, so a session that is gone fails the request instead of being replaced. A restart destroys the sessions, so `restart_server` forgets them. 12 xfailed on an ASan+UBSan build of `538719e18bb`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
ClickHouse#122375 removes the rolled-back empty covering parts inside the failing statement, so a failed `DROP PARTITION` or `TRUNCATE` no longer empties the table after a reload. The two reproductions assert that instead of expecting it to fail: the parts must leave the disk (`leftover_part_dirs`), and the rows must survive `DETACH`/`ATTACH`. `test_failed_drop_partition_survives_reload_when_rollback_mark_fails` is skipped. When the rollback itself throws, the handler added by ClickHouse#122375 hands a part in state `Temporary` to `tryRemovePartImmediately`, which raises `Cannot remove part ..., because it has state: Temporary`; a debug or sanitizer build aborts on it and the node is gone for the rest of the module. The reload it checks still loses the rows, so the test stays as written. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
`MergeTreeTransaction::afterCommit` is `noexcept` and stores the committed CSN through `setAndStoreCreationCSN` as well, so `version_metadata_store_creation_csn_fail` could terminate the server from an unrelated commit, and consume the one-shot injection before the rollback under test reached it. Inject only for `Tx::RolledBackCSN`. Three reads ran after their helper's budget was already spent and fell back to `QUERY_TIMEOUT`, which turned a 30 s or 60 s bound into up to three minutes: the final postpone-reason read of a `stop_early=False` verdict, and the `system.merges` and `system.background_schedule_pool` diagnostics of the two `Precondition` paths. They take `MIN_REQUEST_TIMEOUT`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Mikhail Filimonov <[email protected]>
|
tests look ok-ish now. @tuanpach or @murphy-4o do you want guys to pick the challenge to make those green? :) Some require quite straight-forward fixes and probably groneai can do those, and some need some design decisions. |
Two pauseable failpoints make the race deterministic: `version_metadata_store_pause_before_rename` stops `VersionMetadataOnDisk::storeInfoToDataPartStorage` after `txn_version.txt.tmp` is written and before it replaces `txn_version.txt` (the same name and spot as in open PR ClickHouse#124485), and `mt_mutate_task_pause_before_rename_part` stops a plain MergeTree mutation after its disk transaction is committed and before the new part is renamed into the table. The test stamps a part's creation CSN with COMMIT paused at the first point, runs a non-transactional mutation over the part while `txn_version.txt.tmp` exists, then reloads the table and checks that the mutated part is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Dear @murphy-4o, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Tests and failpoints only. Nothing a user can observe changes.
Twelve reproductions of open MergeTree transaction defects, in one integration module
(
tests/integration/test_transaction_defects). Nine state behaviour the server does not have and carry@pytest.mark.xfail(strict=True, raises=AssertionError): fixing a defect turns its test into afailure of the suite, which is the signal to drop the decorator and keep the test as a regression test.
Two have made that transition already. #122375 landed while this branch was open and repaired the
reload half of #124486, so
test_failed_drop_partition_survives_reloadandtest_failed_truncate_survives_reloadare plain regression tests: they now require the rolled-backempty covering parts to leave the disk inside the failing statement, which is what keeps the rows.
The twelfth is skipped, because the path #122375 added aborts the server when the rollback itself
fails — see below.
No fixes here. The defects are reproducible, and a fix now has a test waiting for it. The first commit
adds five failpoints and changes nothing else; the rest is tests. Every result below was observed on a
Release build of this branch merged with
4f53afc1bab.test_snapshot_above_latest_is_refusedSET TRANSACTION SNAPSHOTaccepts a snapshot far above the latest, instead ofINVALID_TRANSACTIONtest_mutation_at_raised_snapshot_finishesALTER … UPDATEnever finishes afterSET TRANSACTION SNAPSHOTraised the snapshot past a later commit. A lowered target hangs the same waytest_mutation_covers_part_of_unloaded_committransaction_log_pause_before_loading_entries,transaction_force_unknown_state_after_committest_lowered_snapshot_keeps_the_part_it_seestest_failed_drop_partition_leaves_no_removal_stampDROP PARTITIONleaves a part stamped for removal: plainSELECTs read it, transactions do notnon_transactional_removal_store_fail_after_first_parttest_failed_drop_partition_survives_reloadDROP PARTITIONkeeps the partition across a reload, and leaves no empty covering part on disktest_failed_truncate_survives_reloadTRUNCATEtest_failed_replace_partition_leaves_destination_intactREPLACE PARTITIONleaves the new part beside the ones it did not replacetest_failed_drop_partition_survives_reload_when_rollback_mark_failsDROP PARTITIONstill empties the table on reload. Skipped: it also aborts the server, see belowversion_metadata_store_creation_csn_failtest_drop_partition_racing_a_removal_is_refusedDROP PARTITIONracing a transaction that removes one of its parts is accepted; after the rollback the part is active beside the empty part covering itnon_transactional_drop_pause_before_publishtest_acknowledged_insert_survives_kill_during_first_version_metadata_storeversion_metadata_store_pause_before_renametest_drop_partition_of_uncommitted_creation_is_refusedLOGICAL_ERRORinstead ofSERIALIZATION_ERRORThe rollback's own failure aborts the server
test_failed_drop_partition_survives_reload_when_rollback_mark_failsis skipped, not deleted. Withthe rolled-back CSN store failing as well,
rollbackthrows, and the handler #122375 added evicts thePreActiveparts throughremovePartsFromWorkingSetImmediatelyAndSetTemporaryStateand hands them totryRemovePartImmediately, whoseTemporarybranch skipsmodifyPartState(..., Deleting):A debug or sanitizer build aborts there and the node is gone for the rest of the module, so the test
cannot run until that is fixed. What it checks still holds: the part the handler could not remove
keeps its final name on disk, and the reload loses the rows.
Why one integration module and not stateless tests
These reproductions cannot share a server, and three of them cannot run on the stateless one at all:
LOGICAL_ERRORaborts the server in a debug or sanitizer build. That is the defecttest_drop_partition_of_uncommitted_creation_is_refusedreports, and it is not expressible as anexpected failure: the stateless runner reports the server log's
Logical errorand the failedliveness check as failures of their own, whatever the test's own verdict is.
more parts reaches
NonTransactionalRemovalLocks::storefirst. Both callers passLockKind::REMOVAL, so a merge of any table — a system log included — is indistinguishable there.The five tests that use it stop merges server-wide for their duration, which a stateless test may
not do. The sequencing matters and is easy to get wrong:
SYSTEM STOP MERGESwithout a tableiterates the tables of every database and takes an action lock per table
(
InterpreterSystemQuery::startStopAction), so it must run after the test's tables exist, and itleaves a merge that is already running alone, so
system.mergesmust be drained before thefailpoint is armed.
data directory to stage it.
Risks / notes
cluster.shutdowncan exempt a run from itsLOGICAL_ERRORand<Fatal>checks, but only thewhole run, and one reproduction needs both: its logical error aborts a sanitizer build. The
exemptions are therefore replaced per test — a test must declare the message it may log, and
every other test must add no logical error and no fatal line of its own.
rest of the module, fail-closed; a restart cannot cancel a client thread that outlived its test;
and the restart deadline is approximate, because the Docker calls inside
tests/integration/helpers/cluster.pycarry their own 300 s — bounding those means rewriting thathelper, which does not belong here.
What each reproduction reads has to be dated
A reproduction is only as good as the state it reads, and four of these read state that could
predate the window they measure. Each is now dated against the window:
old_parts_lifetime. Therollback hands them to
removePartsFromWorkingSetwithclear_without_timeout, which setsremove_time = 0, andgrabOldPartsthen finds the removal time reached whatever the lifetimesays, so cleanup can delete them at any moment and nothing on disk distinguishes that from the
statement having removed them. Every test here holds
SYSTEM STOP CLEANUP(cleanup runs on its ownthread under
ActionLocks::Cleanup, whichSYSTEM STOP MERGESdoes not cover) and waits out around already past its cancellation test. The two regression tests then require the directories to
be gone, which is Do not keep a rolled back empty part until the parts in its range are removed #122375's removal and not a cleanup round; the skipped one requires them to be
there, which is what the reload loses the rows on.
selectPartsToMutateclearscurrent_parts_postpone_reasonsat the start of each pass, so a reason read right after releasingwhat the mutation waited for describes the pass before that. The verdict first makes the scheduler
write
No free threads in poolthroughmt_select_parts_to_mutate_no_free_threads, which datesthe map.
last_removal_attempt_timeis stamped before any test.TRUNCATEcleans up synchronously, soa stamp can be from a round that ran while the truncating transaction still protected the part, and
a round that found the part removable can still skip it under
NON_UNIQUE_OWNERSHIP— thereference the test's own read of
system.partsholds. The lowered-snapshot test gives cleanup oneround at a time and reads
removal_statewith cleanup stopped and the round drained.silently, so the test would read the table outside the transaction it believes it is in. Every
session request carries
session_timeout = 3600and, after the first,session_check.Testing
test_transaction_defects:2 passed, 1 skipped, 9 xfailed in 91.58s, exit code 0, on a Releasebuild of this branch merged with
4f53afc1bab. An earlier revision ran12 xfailed in 186.45son anASan+UBSan build of
538719e18bb. The time is almost all waiting for the cleanup and selection roundsabove.
Every test fails on its own assertion, and pytest enforces that. An all-
xfailmodule is greenwhen its tests fail for any reason at all:
_pytest/skipping.pyabsorbs any exception in any phaseinto
xfailunlessraisesis set.raises=AssertionErrornarrows the exception type, which isthe easy half. The reason is the hard half: setup checks, the state a failpoint was supposed to
create and positive controls are assertions too, and 20 of the 38 assertions here were not about a
defect. Those raise
Preconditioninstead, which is deliberately not anAssertionError, so areproduction that never reached its defect cannot pass for one that did. A leaked session, a merge
taking the once-only failpoint first, and an error in the module fixture each produced twelve clean
xfailedbefore that held.Two tests could report a different defect than the one they name. The unloaded-commit test
assumed the transaction log's updating thread parks after the commit reaches Keeper; it wakes on its
own, so it can park before, and the test then hung on #124488 instead. The CSN entry is also written
before the fault is injected, so a Keeper entry alone does not say the commit is in unknown state:
the test waits for
TransactionManagerto log that it postponed finalization.Every request carries an explicit timeout.
Instance.querydefaults toDEFAULT_QUERY_TIMEOUT(600 s), which outlasts every budget here, and a polling loop whose own requests are unbounded has
no bound either, so
pollhands each predicate the time it has left.restart_clickhouseenforcesno overall deadline —
start_clickhousehonourswait_start=Falseonly on the branch where noprocess is left, and
stop_clickhouselogs a failed kill rather than reporting it, so a survivingold server would have been accepted as the restarted one. The module kills and verifies that itself.
The two hang reproductions do not wait out a timeout. Part selection records
PostponeReasons::VERSION_NOT_VISIBLEwhen a part is not visible at the mutation's start CSN, andsystem.mutations.parts_postpone_reasonscarries it out. That reason is the defect itself, whereelapsed time equally described a slow server, and waiting for it ends the wait as soon as it
appears: 1.7 s and 2.0 s, against 21 s and 43 s on the clock.
On a fresh server
transactionLatestSnapshot()is 32 and every CSN up to 32 is reserved, soSET TRANSACTION SNAPSHOTrefuses it, and an emptyBEGIN TRANSACTION; COMMIT;allocates no CSN.Hence the warm-up insert in the module fixture.
Workflow [PR]
Sync PR [sync-upstream/pr/124485]
Related: #122375
Related: #123134
Related: #113961
Related: #124486
Related: #124487
Related: #124488
Related: #124489