Repository navigation
test(storage-cassandra): hold the admitted restore's copy in the simultaneous restore test - #1499
Conversation
…ltaneous restore test The test started four restores of one backup and expected one admission and three BackupInUse. A restore creates its target's tables before it registers on the backup, and each statement waits for schema agreement. When that wait outlasted the first restore's copy, the first target went ACTIVE and its registration was removed, so a later registration found no active restore and was admitted too. Two jobs showed two admissions. A test hook now holds a legacy restore's copy after its registration. The simultaneous restore check moves into its own test, behind test-hooks, and releases the copy once all four restores have answered. Product behaviour is unchanged.
…ds the admitted copy The test released the held copy without checking that the hold was taken, so a hook that did nothing still passed. The test now asserts that the admitted target is still CREATING when the four restores have answered, and that the copy reached the hold within 60 s after the release. Each refused restore must be BackupInUse naming the admitted target and must leave no target behind. The doc comment says that only a restore that passes the early in-use check creates tables.
…kup, not the target
LeeroyHannigan
left a comment
There was a problem hiding this comment.
Thanks. I read the change against main 92155f3. On a single-node Cassandra 4.1 with password authentication, as in CI, the new test and the changed test passed 3 of 3 runs each. The crate's 191 lib tests passed too. With the hook call at backup_engine.rs:1312 removed, the new test failed 3 of 3 runs at line 1354 (left: 4, right: 1), because all four restores were admitted.
The hook runs at the start of run_restore_copy, after the registration and before the first item is written. Pause is built on tokio::sync::Notify, so a release that comes before the copy reaches the hold cannot hang the test. The test also still catches the second cause that #869 names, a live registration cleared as stale. The held target stays CREATING while the four restores answer, so a second admission fails the test.
#527 (opened 24 October) rewrites the same simultaneous section of test_a_restore_is_refused_while_a_target_of_its_backup_is_creating. The two PRs conflict there in three hunks, and the description does not name #527. The two versions test different things:
- #527 writes a CREATING target row and its
active_restoresentry by hand, then expects all four restores refused. Its four restores never race on an empty map, so it does not test that one of four simultaneous restores is admitted. - This PR tests that admission through the product's own registration, and the refusals too.
Whichever PR merges second should keep this PR's version of the section. #527 rewrote the section because a copy ended before a second target's schema existed. That reason does not apply once the copy is held. #527 also has one step that this PR does not: after the held row goes, a new restore clears the stale entry and is admitted. That step can stay in #527 as a test of its own. Please name #527 in the description.
The red WebAssembly / wasm check ran on 25 November on a merge commit that has main's #398 break and not its #1482 fix. This PR changes no code that the check builds, and it is not a required check.
… of four is admitted
|
#527 is now named in the description. I read its diff: it rewrites the same simultaneous section, and The red |
What
The Cassandra storage test that starts four restores of one backup at the same time now holds the admitted restore's copy until all four restores have answered.
pause_before_legacy_restore_copy, holds a legacy restore's copy after its registration and before its first item is written. It does nothing without thetest-hooksfeature.test_a_restore_is_refused_while_a_target_of_its_backup_is_creatingmoves into its own test,test_simultaneous_restores_of_one_backup_admit_exactly_one, behindtest-hooks. CI already buildsdirect_integrationwith that feature. The rest of the original test is unchanged.BackupInUseand must leave no target behind (TableNotFoundon describe). The refusal text isBackup is being used to restore another table: <backup ARN>. It names the backup, not the target, so the test checks the ARN.No product behaviour changes.
Why
Refs #869.
Two
cassandra-storagejobs admitted two of the four restores. The cause is not proven for those jobs. This is what is known:active_restoresempty and is admitted. An injected delay before one registration produced exactly this failure (see the first control below).registration_refusal,crates/storage-cassandra/src/backup_engine.rsaround lines 813-822 and 969-993). Nothing here rules it out. The new test would still catch it, because the held target stays CREATING and a second admission would fail the test.The first commit message says the delay "outlasted the first restore's copy" as the cause. Read that as the mechanism that was shown, not as the proven cause of the two CI failures.
The hold keeps the first registration in place until all four restores have answered, so every other registration meets it, however long the table creation takes.
Open PR #527 rewrites the same simultaneous section of
test_a_restore_is_refused_while_a_target_of_its_backup_is_creating, andgit merge-treereports a conflict in that test file. The two test different things. #527 writes a CREATING target row and itsactive_restoresentry by hand and expects all four restores refused, so its restores never race on an empty map. This PR tests that exactly one of four simultaneous restores is admitted through the product's own registration. Whichever PR merges second should keep this PR's version of the section. The extra step in #527, where a new restore clears the stale entry and is admitted, can stay as a test of its own.The older test
test_a_restore_is_refused_while_a_target_of_its_backup_is_creatingstill depends on its 10,000-item copy outlasting its refusals. Its refusals are early reads that run before any table is created, so the window is wide. This PR leaves it as it is.Testing done
Cassandra 127.0.0.1:9042 (1 GB heap),
EXTENDDB_TEST_CASSANDRA=required,--features test-hooks, Rust 1.97.0 for clippy.cargo fmt --checkcargo +1.97.0 clippy -p extenddb-storage-cassandra --all-targets -- -D warnings, without and withtest-hooksSimTarget2, hold armedexactly one is acceptedexactly one is acceptedbackup_engine::module on this branch (100 tests, parallel)backup_engine::module on maina417b2f8(99 tests, parallel)Control 3 fails without any injected delay: with a 200-item copy and no hold, more than one restore is admitted on this machine.
Control 1 and 2 patch (product code, not committed):
Control 2 also changes the test's arming line so that the hold is armed for another backup:
Control 3 patch (not committed):
Command for the controls and the 20 runs:
cargo test -q -p extenddb-storage-cassandra --features test-hooks --test direct_integration -- test_simultaneous_restores. The failing text of controls 2 and 3 isassertion left == right failed: exactly one is accepted: [Ok(TableDescription { table_name: "SimTarget0" .... The tree was restored after each control.Open question
Does live DynamoDB refuse a restore while another restore of the same backup is still creating its tables but has not registered yet? Nothing in the repo says. If it does, the gap between a target row being CREATING and its entry in
active_restoresis a product question, and this hold would hide it.