Repository navigation
fix(cassandra): fence concurrent DeleteTable with a lease - #598
LeeroyHannigan wants to merge 14 commits into
Conversation
360f822 to
5b4c9ff
Compare
Two concurrent DeleteTable calls on one table each read the catalog row, dropped the data tables and answered 200. Amazon DynamoDB answers one of them 200 and the other ResourceInUseException with "Attempt to change a resource which is still in use: Table is being deleted: <name>". DeleteTable now claims the row with a lightweight transaction before the first drop, conditioned on the table id and on a status other than DELETING, and sets status_transition_at five minutes ahead. The call whose claim applies removes the table and reports DELETING; the other answers the being-deleted sentence and deletes nothing. The control-plane sweep takes a DELETING row whose deadline has passed with a compare-and-set on that deadline, and skips the row when the swap does not apply. The call and the sweep run the same removal: the drops keyed on the table id first, then a renewal of the lease with the same swap, then the continuous-backup and tag deletes, which are keyed on the name and the ARN, then the row delete conditioned on the table id. An actor whose renewal does not apply stops before the name-keyed deletes, so a call that outlives its lease leaves them to the sweep that took the row over. The abandoned-restore sweep skips any row that carries a deadline, since a restore target never carries one and a claimed row always does. One case still depends on the lease length. An actor that has renewed its lease and then stalls for more than 300 s before the continuous-backup delete, the tag delete and the row delete can find that a sweep took the row over, finished, and freed the name; its two deletes then reach a table created under that name in the meantime. Those two keys carry no table id, so closing the case needs a schema change. A DeleteTable that stops after its claim leaves the row DELETING. A retry is refused with the being-deleted sentence until the lease has passed and the sweep's next pass has removed the table, 300 s plus up to 60 s for the pass; before this change a retry finished the removal at once. With the server's key-info cache warm, data-plane requests during the delete answer as before: 200 until the base data table is dropped, then 500. With it cold they answer 404 for the whole delete, where they answered 200 and then 500 before; the 404 comes from the read that maps DELETING to not found on this backend. The service answers 200 throughout. The 200 of DeleteTable reports DELETING for a table that is already gone when the answer arrives, so a DescribeTable sent after it answers 404. The sweep now logs a row it cannot remove and goes on to the next row; it used to return at the first failure. Direct storage tests cover two concurrent calls (ten rounds, one of them on a CREATING table), a table created into the name during a delete, a claim whose call stopped, a claim carrying another table id, a renewal against a stale deadline, two sweeps over one stopped claim, a sweep whose row is replaced under it, the abandoned-restore sweep over a claimed restored table, PITR and tag writes during the drops, the order of the name-keyed deletes, and a sweep pass with a row it cannot remove. A dual-target wire row sends two concurrent DeleteTable calls and accepts a not-found answer for the loser only on PostgreSQL and SQLite.
32bd451 to
13a2940
Compare
…nt-delete-table crates/storage-cassandra/src/backup_engine.rs keeps the restore target removal from the base branch. The deadline check this branch added to the abandoned restore sweep goes with that sweep, which main no longer has. crates/storage-cassandra/src/delete_table.rs keeps the removal without a continuous_backups delete from the base branch and the lease claim, the renewal and the removal order from this branch. Main dropped the continuous_backups table in catalog migration 5. crates/storage-cassandra/src/worker_store.rs keeps the lease take and the shared removal from this branch. The base branch's change there, the end of the continuous_backups delete, holds through that removal. crates/storage-cassandra/tests/direct/deleting_window.rs keeps the module doc from this branch, which names the DeleteTable claim as the writer of the DELETING mark. tests/python/test_deleting_window_control_plane.py keeps the index read test from the base branch inside TestDeletingWindowDataPlane and the TestConcurrentDeleteTable class from this branch after it.
…ble lease tests Main dropped the continuous_backups table in catalog migration 5, with describe_continuous_backups and update_continuous_backups. The lease tests enabled point-in-time recovery on their tables and read the stored row. That showed two things: a fenced delete leaves the newer table's row alone, and the name-keyed deletes run after the drops. The tags share the same fence and the same place in the removal, so they now carry those checks alone. The pitr_row helper and the continuous_backups clean-up go from delete_table_support.rs. The point-in-time recovery writes and assertions go from six tests. The test of the abandoned restore sweep over a claimed restored table goes as well: it tested a check that main's restore target removal replaced.
…nt GsiInput Main added warm_throughput to GsiInput. The gsi_input helper of the DeleteTable lease tests now sets it to None.
…elper each The direct test binary held two readers of system_schema.tables for a data table. One in backup_engine.rs takes the table name, one in delete_table_support.rs takes the table id. The second now formats the name and calls the first, which the file makes visible to the binary. The DELETING window tests read a row's status with a query of their own. They now call row_status from delete_table_support.rs, which reads the same column.
…nt-delete-table The base branch accepts a refused queued DeleteTable in the PostgreSQL snapshot test an_open_needs_one_connection_per_pool (bff95d9). No file conflicts.
…nt-delete-table crates/storage-cassandra/src/delete_table.rs keeps this branch's side where main changed the old index metadata delete: delete_indexes_for_table deletes that metadata after the index drops. The tag delete keeps this branch's statement, keyed on table_arn, and sends it through main's self.session.run(Stmt::Write, ...). Main's tests/consistency_policy.rs refuses a query_with_values call in source that is not a test. crates/storage-cassandra/src/worker_store.rs keeps this branch's lease take and remove_claimed_table in place of the old sweep's tag delete, the one statement main changed there. The merge also deletes the imports of PolicySession and Stmt that main added to that file. The tag delete they served is gone, and the unused_imports lint fails the -D warnings build. crates/storage-cassandra/tests/direct/backup_engine.rs keeps this branch's pub(crate) data_table_exists, which the delete tests share, with main's cassandra_util::system_read. crates/storage-cassandra/tests/direct_integration.rs lists concurrent_delete_table, then main's consistency_levels and consistency_shape. tests/python/test_deleting_window_control_plane.py keeps the not-found assertion of the base branch at the end of test_index_reads_after_the_table_is_gone_are_not_found, then the TestConcurrentDeleteTable class of this branch.
…SQLite TestConcurrentDeleteTable checked the message of the ResourceInUseException answer only. The ResourceNotFoundException it accepts on PostgreSQL and SQLite was checked by its code alone. Each accepted answer now has its message in one map, and assert_validation checks the status, the code and the message. The not-found message is ExtendDB's, Requested resource not found, the text NOT_FOUND holds. A local PostgreSQL server gave it for DeleteTable on a missing table on 2026-11-24, and SQLite shares the engine's mapping. The docstring no longer names issue and pull request numbers. On a PostgreSQL-backed server the class passed twice. With a wrong expected message it failed in 2 of 3 runs, so the not-found branch runs there.
demohan
left a comment
There was a problem hiding this comment.
The lease fences concurrent deletes. Two DeleteTable calls at once give one 200 DELETING and one 400 ResourceInUseException with the service's "being deleted" sentence, byte-equal to the service in us-east-1, where the base answered two 200s; 48 of 48 concurrent pairs on the wire row and 20 of 20 rounds across two servers on one Cassandra 4.1 node answer this way, with and without GSIs. DeleteTable and DescribeTable report DELETING, UpdateTable and TagResource during a delete get the service's error, and CreateTable of the same name answers "Table already exists".
- A holder stopped past its lease: the other server's sweep took the row 2.2 s after the deadline. With the name re-created with a new tag, an item and a GSI, the resumed holder answered 200, its renewal failed, it skipped the name-keyed deletes, and the new table kept its tag, item, GSI and table id.
- Six stopped claims under two live sweeps were each removed once, with no orphan tags, index rows or data tables across 26 deletes. Every other writer of the row's status is conditional, and restore targets are not taken by the sweep.
fmt, clippy and the 1.88 MSRV check are clean, 142 unit tests and 314 of 314 direct integration tests pass, the PR's pytest files pass on a head Cassandra server (46 passed, 5 skipped by design), CI is green on 53 checks, and the five controls in the body and one more each fail their tests.
I will approve once the lease is released on error, the two answers below follow the service or are listed, and the docs match.
crates/engine/src/ttl.rs:227
UpdateTimeToLive during a delete now answers 400 ResourceInUseException Table X is not in ACTIVE state (3 of 3), where the base answered 200 (3 of 3). The service answers 200 for the first 0.3 to 1.2 s and then 400 Attempt to change a resource which is still in use: Table X is being deleted, over 13 delays in two runs. The error class matches the service's later phase and the sentence matches neither. Answering the "being deleted" sentence for a DELETING row would match the later phase; the body can list the change.
docs/differences-from-dynamodb.md:60
The row says Cassandra DeleteTable is synchronous and never marks the row DELETING, which this PR makes untrue. docs/troubleshooting.md:384 says a stopped transition completes at the next startup; on Cassandra a DeleteTable that stops after its claim keeps the name until the lease passes and the next sweep runs, up to about 360 s.
| // Claim the row before the first drop. Two concurrent calls both read | ||
| // the same row; the claim applies for one of them and the other | ||
| // answers TableBeingDeleted, as the service answers the second of two | ||
| // concurrent calls (measured 2026-10-25, five rounds of five). |
There was a problem hiding this comment.
No error path releases the lease. Once a call has claimed the row, a failure or a crash leaves it DELETING with the deadline 300 s ahead, and only the 60 s idle sweep takes it after that. With the holding server killed right after its claim, retries on the other server answered 400 "Table is being deleted" for 320.5 s, then not found; on the 550 base a retry finished the removal at once. The body discloses this as behaviour 1. On an error after the claim, swapping the deadline to now() with the compare-and-set the renewal uses, and notifying the poller, would clear in-process failures within about a second.
There was a problem hiding this comment.
Fixed in 66a3046. When a statement fails after the claim (the call) or the take (the sweep), remove_claimed_table now moves the actor's deadline to the current time. It uses the compare-and-set of the renewal: release_delete_lease and renew_delete_lease share swap_delete_deadline. The failed call then wakes the poller, and the poller's next pass removes the table. A failure inside the sweep does not wake the poller, because the poller runs that pass. A wake from inside it would keep the poller polling every second while the failure lasts.
a_delete_that_fails_after_its_claim_is_finished_by_the_next_sweep fails a DeleteTable at its first index table drop. It checks that the row's deadline is no longer ahead, and that one sweep pass removes the table and both index tables. With the release removed, it fails on the deadline, which is 300 s ahead.
A dropped request also left the lease. When a client closed the connection after the claim, the server stopped the call part way. On a local server, the client of a DeleteTable of a table with 8 GSIs timed out after 0.2 s. The row stayed DELETING, and the sweep removed it 351 s after the request. bba68ad runs the claim and the removal in a task that the call awaits, as the PostgreSQL backend does with its drops. With it, the row of the same request read DELETING for about 4 s and was then gone. a_delete_whose_request_is_dropped_after_its_claim_still_removes_the_table aborts a call after its claim, and it fails when the removal runs inline.
A server process that stops after the claim still leaves the 300 s lease. The body, docs/differences-from-dynamodb.md and docs/troubleshooting.md say so (08b7356).
| // answers TableBeingDeleted, as the service answers the second of two | ||
| // concurrent calls (measured 2026-10-25, five rounds of five). | ||
| let lease = match caller { | ||
| DeleteTableCaller::Client => Some( |
There was a problem hiding this comment.
CreateBackup during a delete answers TableNotFoundException for the whole delete (2 of 2 races, 3 of 3 sweep rounds); the not-found mapping comes from 550. The base answered 200 until the data table was dropped. The service accepts the backup for about 2 s (200, later AVAILABLE) and then answers TableNotFoundException while DescribeTable still says DELETING. The body lists this trade for item reads and writes and can list CreateBackup with them.
There was a problem hiding this comment.
Listed in the body as behaviour 3 and under Breaking changes. The body gives your service answers: 200 for about 2 s, then TableNotFoundException while DescribeTable still reads DELETING.
I checked it at the head on a local Cassandra-backed server. During a delete of a table with 8 GSIs, CreateBackup answered 400 TableNotFoundException "Table not found: " 277 of 277 times.
The answer comes from CreateBackup's check that the table is ACTIVE, which main has. The claim makes the row DELETING, so that check refuses the backup.
| /// leaves those deletes and the row delete to the actor that holds the row. | ||
| const DELETE_CLAIM_LEASE_SECS: i64 = 300; | ||
|
|
||
| fn lease_deadline_ms() -> i64 { |
There was a problem hiding this comment.
The deadline comes from the server's clock, and the sweep compares it with the Cassandra node's clock, so a server S seconds behind writes a lease of 300 minus S seconds. That widens the stall-after-renewal case the body names. The clock note in the docs can name this lease.
There was a problem hiding this comment.
Documented in 08b7356, with no code change. The clock synchronization note in docs/cassandra-setup.md and the doc comment of DELETE_CLAIM_LEASE_SECS now name the lease. The server sets the deadline from its own clock, and the sweep compares it with the node's clock. So a server S seconds behind the node writes a lease of 300 minus S seconds.
The body's case that depends on the lease length says the same. On such a server, a stall of 300 minus S seconds after the renewal is enough.
| } | ||
|
|
||
| /// Delete index metadata and drop index data tables for a given table. | ||
| /// Drop the index data tables of a table, then delete their index metadata. |
There was a problem hiding this comment.
Nothing tests dropping the index tables before deleting their metadata: with main's order restored, the two delete modules pass 10 of 10. A slow DeleteTable whose row a sweep takes over has no end-to-end test either: with the renewal check disabled, 1 of 10 fails, and with the renewal's deadline condition removed only the direct method test fails. A test-hooks test that pauses a call between its drops and its renewal would cover both.
There was a problem hiding this comment.
a_delete_whose_row_a_sweep_took_over_stops_at_its_renewal pauses a DeleteTable between its drops and its renewal, moves the deadline into the past, and lets a sweep take the row. It runs two cases. In the first, the call resumes after the sweep removed the table and the test created the name again and tagged it. In the second, the call resumes while the sweep holds the row, paused at its own renewal.
With the renewal check disabled, the first case fails: the call runs the tag delete, and the newer table loses its tag. Without the deadline condition in the compare-and-set, the second case fails: the call's renewal applies, and the call deletes the row the sweep holds. The first case passes under that control. Once the sweep finishes, the table id condition of the renewal refuses the call by itself.
The pause cannot show the order in delete_indexes_for_table, because the order only matters when a drop fails. a_delete_that_fails_after_its_claim_is_finished_by_the_next_sweep fails the first index table drop. With main's order restored it fails: the metadata is gone before the failed drop, and the sweep's pass leaves both index tables.
| /// EXISTS`, the TTL entries are cleared, and the index metadata goes after | ||
| /// the index tables, so a removal that stops part way leaves the ids the | ||
| /// next attempt needs. The tags are keyed on the table ARN, which carries | ||
| /// no table id. They are deleted last, after the renewal, while the |
There was a problem hiding this comment.
The row delete runs last, not the tag delete. The same is in tests/direct/delete_table_lease.rs:10.
There was a problem hiding this comment.
Fixed in 08b7356. The doc comment of remove_claimed_table and the module doc of tests/direct/delete_table_lease.rs now say that the row delete runs last. The tag delete comes before it, after the renewal.
I grepped the branch, the body and the docs for the same claim and found no other sentence that puts the tag delete last.
The DELETING window row of docs/differences-from-dynamodb.md said that DeleteTable on Cassandra never marks the row DELETING. The claim now marks it for the length of the drops. The row names the claim and the answer to a second DeleteTable. It gives the data-plane answers during the drops, with and without an entry in the key-info cache. The Control Plane table gets two rows. One is the DeleteTable 200 that reports DELETING for a table that is already gone. The other is a DeleteTable that stops after its claim. It gives the 300 s deadline, the sweep's next pass, and what a sweep does with a row it cannot remove. docs/troubleshooting.md names the stopped claim as a cause of a table stuck in DELETING on Cassandra, and adds a step to the fix.
A DeleteTable whose removal failed after its claim left the row DELETING with the claim's deadline 300 s ahead. A retry answered "Table is being deleted" until that deadline passed and the next sweep removed the table. When one of its statements fails, remove_claimed_table now moves the deadline that the actor holds to the current time. The actor is a DeleteTable call after its claim, or the control-plane sweep after its take. The release uses the compare-and-set of the renewal: release_delete_lease and renew_delete_lease share swap_delete_deadline. The call then wakes the control-plane poller. Its next pass takes the row and finishes the removal. A failure inside the sweep does not wake the poller, because the poller runs that pass. A wake from inside the pass would keep the poller polling every second while the failure lasts. The test hook fail_next_index_table_drop fails the next drop of an index data table in one account keyspace. The new test a_delete_that_fails_after_its_claim_is_finished_by_the_next_sweep fails a DeleteTable at its first index table drop. It checks that the row's deadline is no longer ahead, and that one sweep pass then removes the table and both index tables. The index metadata outlives the failed drop.
…ts claim When a client closed its connection during a DeleteTable, the server stopped running the request. A request that stopped after the claim left the drops part way done. It also left the row DELETING with the claim's deadline 300 s ahead, as a stopped server process does. On a local Cassandra-backed server, the client of a DeleteTable of a table with 8 GSIs timed out after 0.2 s. The row stayed DELETING, and the sweep removed the table 351 s after the request. delete_table_as now runs the claim and the removal in a task that the call awaits, as the PostgreSQL backend runs its drops. A dropped request detaches the task, and the task finishes the removal. With this change, DescribeTable read DELETING for about 4 s after the same request, and then answered ResourceNotFoundException. The new test a_delete_whose_request_is_dropped_after_its_claim_still_removes_the_table aborts a DeleteTable once its claim applies. It then waits for the row and the data table to go.
…es the row No test ran a DeleteTable call past its lease with the control-plane sweep beside it. So no end-to-end test of the call covered the renewal check or the deadline condition of the renewal's compare-and-set. The test hook pause_before_delete_lease_renewal holds the next removal of one table between its drops and its lease renewal. The new test a_delete_whose_row_a_sweep_took_over_stops_at_its_renewal pauses a DeleteTable there and moves the row's deadline into the past, so a sweep takes the row. It runs two cases. In the first, the call resumes after the sweep removed the table and the test created the name again and tagged it. In the second, the call resumes while the sweep holds the row, paused at its own renewal. In both cases the call answers 200 with DELETING. It runs none of the statements after its renewal (the tag delete and the row delete). The newer table keeps its row and its tag, and the sweep finishes the removal.
…al order docs/cassandra-setup.md and the doc comment of DELETE_CLAIM_LEASE_SECS now name the lease in the clock note. The server sets the lease's deadline from its own clock, and the sweep compares the deadline with the clock of the Cassandra node. A server S seconds behind the node writes a lease of 300 minus S seconds. The doc comment of remove_claimed_table and the module doc of tests/direct/delete_table_lease.rs said that the tag delete runs last. The row delete runs last, after the tag delete. docs/differences-from-dynamodb.md and docs/troubleshooting.md now describe the two ways a DeleteTable can end after its claim on Cassandra. A call that fails answers 500 and wakes the sweep, which removes the table at its next pass. A server process that stops leaves the row DELETING until the lease passes and the sweep runs. That takes up to about 6 minutes, and a restart does not shorten it. A request that its client drops does not stop the removal. The troubleshooting cause no longer says that every stopped transition completes at the next startup. The commit also splits long sentences in the comments of the three commits before it.
|
UpdateTimeToLive ( For the docs rows, 1b0aebf rewrote the DELETING window row of |
demohan
left a comment
There was a problem hiding this comment.
The items from the earlier review are resolved at 08b7356, measured on two servers built from this head sharing one Cassandra 4.1 node.
- A DeleteTable that fails after its claim hands the lease back. With DROP revoked on one index table, DeleteTable answered 500, the row's deadline was 0.6 s behind the node's clock rather than 300 s ahead, and the failing server's poller ran a pass about 0.1 s later; retries on the other server answered the being-deleted sentence while the failure lasted, and once DROP was granted the table was gone in 35.2 s and 7.0 s with no tags, index metadata, data or catalog row left, in both server orders. A request dropped after 0.2 s on an 8-GSI table is finished by its own task in about 2.7 s, and two-server races still give one 200 DELETING and one being-deleted 400, 10 of 10.
- UpdateTimeToLive and CreateBackup during a delete are listed in the body as behaviours 3 and 4 and under Breaking changes. The concurrent pair still matches the service in us-east-1 byte for byte, and DescribeTable, UpdateTable, TagResource and CreateTable during a delete answer as at 7318dbc.
- The clock note in
cassandra-setup.mdand the lease constant name the lease, the index tables drop before their metadata and that order has a test, the comments put the row delete last, and the differences and troubleshooting rows match the code. - Removing the release fails the failed-claim test, running the removal inline fails the dropped-request test, and restoring main's index order or disabling the renewal check or its deadline condition fails the new tests. fmt, clippy with and without test-hooks and the 1.91.1 check are clean, 181 lib, 10 consistency and 332 direct tests pass, and CI is green on 54 of 54 checks.
| // poller runs that pass. A wake from inside the pass would | ||
| // keep the poller polling every second while the failure | ||
| // lasts. | ||
| engine.control_plane_notify.notify_one(); |
There was a problem hiding this comment.
Optional. No test covers this wake: with notify_one() deleted, all 16 delete tests pass, because the failure test runs the sweep itself. The live runs show the wake clears the row within about a second; without it the row waits for the 60 s idle pass. tests/direct/delete_table_lease.rs is 698 lines, and moving the new tests to their own module would keep it under 600.
There was a problem hiding this comment.
Both stay as they are in this PR. Without the wake, the 60 s idle pass removes the row, and the failure test checks that removal by running the sweep itself. A test of the wake would have to time the removal against that pass on the Cassandra node. The new tests stay in tests/direct/delete_table_lease.rs: the move would change no test, and each push to this branch needs a new approval.
Changes since the last review
The branch is at 08b7356. Eight commits sit on 7318dbc, the head of the last review. The four newest answer that review:
DeleteTablecall) or the take (the control-plane sweep),remove_claimed_tablemoves the actor's deadline to the current time. It uses the compare-and-set of the renewal:release_delete_leaseandrenew_delete_leaseshareswap_delete_deadline. The failed call then wakes the control-plane poller, and the poller's next pass removes the table. A failure inside the sweep does not wake the poller, because the poller runs that pass.DeleteTablebetween its drops and its renewal while a sweep takes its row.docs/cassandra-setup.mdand in the doc comment ofDELETE_CLAIM_LEASE_SECS. It fixes the two comments that put the tag delete last. It also rewrites the text on a stopped claim indocs/differences-from-dynamodb.mdanddocs/troubleshooting.md.The four commits before them came from the earlier round:
crates/storage-cassandra/src/delete_table.rsandworker_store.rskeep this branch's lease and removal. The tag delete goes through main's statement policy (Stmt::Write). The merge deletes the two imports that main added toworker_store.rs. They served the sweep's own tag delete, which this branch replaces withremove_claimed_table, and the-D warningsbuild refuses them as unused.TestConcurrentDeleteTableassert the message of each answer it accepts from the losing call, and drops the issue and PR numbers from its docstring.docs/differences-from-dynamodb.md. It adds two Control Plane rows and names the stopped claim indocs/troubleshooting.md.The message of 13a2940 is no longer true at this head. It names the continuous-backup delete, a deadline skip in the abandoned-restore sweep, and tests that later commits dropped (see "Merged with main"). Whoever merges: please use the What section of this body as the squash message.
What
Two concurrent DeleteTable calls on one Cassandra table both answered 200 and both ran the deletion. DeleteTable now claims the catalog row with a lightweight transaction before its first drop. The claim is conditioned on the table id and on a status other than DELETING. It marks the row DELETING and sets
status_transition_at300 s ahead. The call whose claim applies removes the table and answers 200 with TableStatus DELETING. The other call answers 400 ResourceInUseException "Attempt to change a resource which is still in use: Table is being deleted: ", as the service does.The control-plane sweep takes a DELETING row whose deadline has passed, with a compare-and-set on that deadline. It skips the row when the swap does not apply. The call and the sweep run the same removal,
remove_claimed_table. It starts with the drops keyed on the table id, then renews the lease with the same swap. The tag delete, keyed on the ARN, comes next, and the row delete conditioned on the table id comes last. An actor whose renewal does not apply stops before the tag delete.delete_indexes_for_tablenow drops the index tables before it deletes their metadata, so a drop that fails leaves the metadata for the next attempt.When a statement of the removal fails, the actor moves its deadline to the current time with the same swap. The sweep's next pass then takes the row. A failed DeleteTable also wakes the control-plane poller. The call runs the claim and the removal in a task that it awaits. So a request that its client drops after the claim does not stop the removal.
Without the swap, two actors on one claimed row both run the tag delete. The two actors can be two servers' sweeps, or a slow call and the sweep that takes the row from it. The later actor can then delete the tags of a table created under the name in between.
On main, the removal of a restore target replaced the abandoned-restore sweep. It does not take a DELETING table.
The case that depends on the lease length
An actor can renew its lease and then stall for more than 300 s before the tag delete and the row delete. During the stall, a sweep can take the row, finish, and free the name. The actor's tag delete then reaches a table created under that name in the meantime. The key of the tag rows carries no table id, so closing the case needs a schema change (#1458). The lease comes from the server's clock, and the sweep compares it with the clock of the Cassandra node. So on a server S seconds behind the node, a stall of 300 minus S seconds is enough (
docs/cassandra-setup.md).Why
Fixes #553
#553 measured the service on 2026-10-25, five rounds of five. Of two DeleteTable calls sent at once on one table, one answers 200 and the other answers ResourceInUseException with the sentence above.
Behaviour to know about
docs/differences-from-dynamodb.mddescribes items 1, 2, 5 and 8, anddocs/troubleshooting.mddescribes item 1.Merged with main
Main reports point-in-time recovery (PITR) as unsupported and dropped its continuous-backup table (#335). So the continuous-backup delete and the PITR parts of the tests are gone. Main also removed the abandoned-restore sweep, so this branch's deadline skip in it and the test of that skip are gone. Main's own test of the removal of a restore target covers a DELETING restored table. The tests check a data table's existence through main's helper.
Overlaps with other PRs and merge notes
tests/python/test_deleting_window_control_plane.py: keep fix: answer TTL and tag calls during a table's DELETING window #599'sTestDeletingWindowTimeToLiveAndStreamTags, thenTestConcurrentDeleteTable.docs/differences-from-dynamodb.md: keep fix: answer TTL and tag calls during a table's DELETING window #599's row, with this branch's Cassandra sentences in place of the old one.crates/storage-cassandra/tests/direct/deleting_window.rsmerges with no conflict but does not compile, because this branch deletesstatus_of. The second of the two to merge changesstatus_of(&engine, &account.account_id)in fix: answer TTL and tag calls during a table's DELETING window #599'supdate_ttl_during_the_window_is_servedtorow_status(&engine, &account.account_id, TABLE). The earlier round checked these resolutions on a local merge of 1b0aebf and fix: answer TTL and tag calls during a table's DELETING window #599's e4465ec. The Cassandra test binary built, and its three delete modules passed (14 tests). Without the change the build fails with E0425 onstatus_of. At 08b7356,git merge-treeagainst fix: answer TTL and tag calls during a table's DELETING window #599's head fd12d6c (e4465ec with fix: answer requests during a table's DELETING window as the service does #550's 9cbb9fe merged) gives the same two conflicts, and the mergeddeleting_window.rsstill callsstatus_of.crates/storage-cassandra/src/delete_table.rs. They conflict with this branch in that file, in theuselines and in that refusal. They did so at c40ed59 too, and the four newest commits add no conflict with them.Testing done
At 08b7356, with toolchain 1.97.0 and cassandra:4.1 with PasswordAuthenticator, as in CI:
extenddb-storage-cassandralib: 181 passed.--test consistency_policy: 10 passed.--features test-hooks --test direct_integration, withEXTENDDB_TEST_CASSANDRA=required: the three delete modulesconcurrent_delete_table,delete_table_leaseanddeleting_windowpassed 16 of 16 (5, 8 and 3). The other callers of the sweep and of the removal (index::,stream_disable,transaction_ledger,index_delay_readsand thebackup_enginerestore-target tests) passed 40 of 40.tests/python/test_deleting_window_control_plane.pyon a Cassandra-backed debug server of this head, withEXTENDDB_TEST_BACKEND=cassandra:TestConcurrentDeleteTablepassed. The five held-window tests skip there, because they hold the window through PostgreSQL.cargo +1.97.0 fmt --all -- --check, andcargo +1.97.0 clippy -p extenddb-storage-cassandra --all-targets -- -D warningswith and without--features test-hooks: clean.cargo +1.91.1 check -p extenddb-storage-cassandra --all-targets: clean..github/workflows/wasm.ymlforwasm32-unknown-unknown: clean. This host has no clang, so the run used a stand-in C compiler and archiver. Clippy does not link.python3 -m pytest --collect-only -qoftests/(6643 tests) and oftests/python(678): no error.direct_integrationbinary (332 tests). CI runs it.Controls at 08b7356, each with the tests kept:
remove_claimed_table:a_delete_that_fails_after_its_claim_is_finished_by_the_next_sweepfails, because the row's deadline is still 300 s ahead.delete_indexes_for_table, with the index metadata deleted first: the same test fails, with both index tables left after the sweep's pass.a_delete_whose_row_a_sweep_took_over_stops_at_its_renewalfails in its first case, because the newer table loses its tag.a_sweep_whose_row_was_replaced_leaves_the_newer_table_alonefails too.a_delete_whose_row_a_sweep_took_over_stops_at_its_renewalfails in its second case, because the call deletes the row that the sweep holds.a_renewal_against_a_stale_deadline_does_not_applyfails too.a_delete_whose_request_is_dropped_after_its_claim_still_removes_the_tablefails, with the row still there after 60 s.concurrent_delete_tableanddelete_table_leasefail. Among them aretwo_concurrent_delete_tables_have_one_winner,a_table_created_during_a_delete_keeps_its_tagsanda_tag_written_during_the_drops_goes_with_the_table.delete_table.rs, because they callclaim_table_for_deleteandrenew_delete_lease. The control without a claim stands in for that one.TestConcurrentDeleteTablefailed in 2 of 3 runs on PostgreSQL, so its not-found branch runs there. The wire file has not changed since.CI runs the delete modules in
integration-cassandra.yml(cargo test -p extenddb-storage-cassandra --features test-hooks --test direct_integration, withEXTENDDB_TEST_CASSANDRA=required). It runs the wire class in the Cassandra pytest job, whosedevtools/run-tests --backend cassandraexportsEXTENDDB_TEST_BACKEND=cassandra, and in the PostgreSQL and SQLite pytest jobs.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
Breaking changes
On the Cassandra backend:
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.