Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4b7389a
fix: answer requests during a table's DELETING window as the service …
LeeroyHannigan Oct 29, 2026
5b4c9ff
test(cassandra): keep the DELETING-window rows out of the control-pla…
LeeroyHannigan Oct 29, 2026
b060b0e
Merge branch 'main' into fix/505-deleting-window-answers
LeeroyHannigan Nov 3, 2026
e583912
fix(mongodb): finish a DeleteTable that stops after its DELETING mark
LeeroyHannigan Nov 3, 2026
1de1816
test(postgres): describe the concurrent DeleteTable test as the code …
LeeroyHannigan Nov 3, 2026
040be0d
fix(postgres): keep an abandoned restore target not found while it is…
LeeroyHannigan Nov 3, 2026
acb03bf
fix(sqlite): answer only a missing _ddb_ table as a table that is gone
LeeroyHannigan Nov 3, 2026
9f87c96
refactor(sqlite): drop the unreachable no-row arm after the DELETING …
LeeroyHannigan Nov 3, 2026
8156c69
test(sqlite): find the cargo target directory from the test binary's …
LeeroyHannigan Nov 3, 2026
657e1c0
test: run the DELETING window wire tests at any control-plane delay
LeeroyHannigan Nov 3, 2026
3a0ee7d
test: wait for a table being deleted at fixture teardown
LeeroyHannigan Nov 3, 2026
f2a777a
fix(engine): answer an index read on a table that is gone as not found
LeeroyHannigan Nov 3, 2026
97b4bef
fix(engine): refuse TagResource and UntagResource while a table is DE…
LeeroyHannigan Nov 3, 2026
34a9c9a
fix(mongodb): remove a deleted table's tags only with its document
LeeroyHannigan Nov 3, 2026
4e1ebe0
test: check that ListTagsOfResource lists a DELETING table's tag
LeeroyHannigan Nov 3, 2026
d8d6e05
Merge branch 'main' into fix/505-deleting-window-answers
LeeroyHannigan Nov 3, 2026
1df5cb0
Merge origin/main into fix/505-deleting-window-answers
LeeroyHannigan Nov 14, 2026
a5fb656
test: build the DELETING window fixtures against the current engine t…
LeeroyHannigan Nov 14, 2026
4e19113
docs: name the backup reconciler as the remover of a restore target
LeeroyHannigan Nov 14, 2026
bff95d9
test(storage-postgres): accept a refused queued DeleteTable in the on…
LeeroyHannigan Nov 14, 2026
d00f160
Merge origin/main into fix/505-deleting-window-answers
LeeroyHannigan Nov 24, 2026
cc9a38a
fix(engine): drop a table's cached key info before DeleteTable runs
LeeroyHannigan Nov 24, 2026
cd5b930
refactor(engine): drop the TTL mapper's arm for a table being deleted
LeeroyHannigan Nov 24, 2026
538dd10
refactor(engine): build the TableBeingDeleted answer in one helper
LeeroyHannigan Nov 24, 2026
b2e28fa
refactor(sqlite): mark a deleted table by its name, as main does
LeeroyHannigan Nov 24, 2026
76ecc52
docs(server): name the CREATING answer in the key-info cache comment
LeeroyHannigan Nov 24, 2026
de51e0f
test(storage-postgres): honour EXTENDDB_TEST_PG_REQUIRED in the DELET…
LeeroyHannigan Nov 24, 2026
ff6a7ee
test: assert the not-found message once a deleted table is gone
LeeroyHannigan Nov 24, 2026
ac683d3
test: split the PostgreSQL and MongoDB DELETING window tests by concern
LeeroyHannigan Nov 24, 2026
cf93668
docs: state when PostgreSQL and SQLite keep a deleted table's row DEL…
LeeroyHannigan Nov 24, 2026
757a6b9
Merge origin/main into fix/505-deleting-window-answers
LeeroyHannigan Nov 24, 2026
e343a2b
Merge origin/main into fix/505-deleting-window-answers
LeeroyHannigan Nov 24, 2026
154f0da
Merge origin/main into fix/505-deleting-window-answers
LeeroyHannigan Nov 24, 2026
9cbb9fe
Merge origin/main into fix/505-deleting-window-answers
LeeroyHannigan Nov 24, 2026
b7d46a8
Merge origin/main into fix/505-deleting-window-answers
LeeroyHannigan Dec 3, 2026
a1e2494
fix(storage-postgres): index reads, the drop and restore claims in th…
LeeroyHannigan Dec 3, 2026
d9db9c4
fix(server): serve a DELETING table's key info without keeping it
LeeroyHannigan Dec 3, 2026
1159934
test: the dropped-table handling of SQLite Query and Scan and MongoDB…
LeeroyHannigan Dec 3, 2026
bd6b452
test(pytest): check that the window write went with the table
LeeroyHannigan Dec 3, 2026
b6ba507
docs: the service's two phases of the DELETING window
LeeroyHannigan Dec 3, 2026
a2cae34
test(storage-postgres): hold a lock at every instant in the served-tr…
LeeroyHannigan Dec 3, 2026
74429ba
Merge origin/main into fix/505-deleting-window-answers
LeeroyHannigan Dec 4, 2026
3d882d0
Merge origin/main into fix/505-deleting-window-answers
LeeroyHannigan Dec 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/integration-mongodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ jobs:
EXTENDDB_TEST_MONGODB_STANDALONE_URI: mongodb://127.0.0.1:27019/?directConnection=true
EXTENDDB_TEST_MONGODB_REQUIRED: "1"
run: cargo test -p extenddb-storage-mongodb snapshot_engine
- name: Run DELETING window tests
# What DeleteTable and UpdateTable answer while a table is DELETING,
# and that a delete which stopped after its mark is finished. Each
# test works in databases of its own on the replica set above.
env:
EXTENDDB_TEST_MONGODB_URI: mongodb://127.0.0.1:27018/?directConnection=true
EXTENDDB_TEST_MONGODB_REQUIRED: "1"
run: cargo test -p extenddb-storage-mongodb --lib deleting_window_tests
- name: Stop MongoDB containers
if: always()
run: docker rm -f extenddb-runtests-mongo-27018 extenddb-snapshot-standalone-27019
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -809,13 +809,14 @@ jobs:
# storage layer directly against this job's PostgreSQL. The PutItem create
# race tests hold a create open in an outside transaction, the
# write-transaction conflict tests force a deadlock, the stream clock test
# holds a row lock open while a write waits on it, and the backup restore
# cases need catalog rows the current binary would not write; all need
# direct access. The online GSI build tests reorder queue rows by hand and
# pause writers with a test hook. The LSI query plan test reads the
# statement the engine sent from pg_stat_activity and explains it, which
# the wire cannot show. They build their own throwaway databases; the
# connection string is the server, not a database. `--tests` runs
# holds a row lock open while a write waits on it, the backup restore
# cases need catalog rows the current binary would not write, and the
# DELETING window tests hold a table DELETING with no poller to finish it;
# all need direct access. The online GSI build tests reorder queue rows by
# hand and pause writers with a test hook. The LSI query plan test reads
# the statement the engine sent from pg_stat_activity and explains it,
# which the wire cannot show. They build their own throwaway databases;
# the connection string is the server, not a database. `--tests` runs
# every target of the crate, so a new test file needs no edit here, and
# EXTENDDB_TEST_PG_REQUIRED turns a test's skip for a missing connection
# string into a failure.
Expand Down
6 changes: 4 additions & 2 deletions crates/core/src/error/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ pub enum ErrorMessageKey {
TableNotFound,
TableAlreadyExists,
TableInUse,
/// A second `DeleteTable` of a table that is `DELETING` (measured on the
/// service 2026-11-30).
/// A control-plane change refused because the table is `DELETING`.
/// Measured on the service 2026-10-24 for a second `DeleteTable` and for
/// `UpdateTable` during the window, and 2026-11-30 for a second
/// `DeleteTable`.
TableBeingDeleted,
MissingKeySchema,
KeySchemaTooMany,
Expand Down
11 changes: 11 additions & 0 deletions crates/engine/src/create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub fn storage_err_to_dynamo(e: extenddb_storage::error::StorageError) -> Dynamo
ErrorMessageKey::TableInUse,
&[&name],
)),
StorageError::TableBeingDeleted(name) => table_being_deleted(&name),
// Only RestoreTableFromBackup raises this; its own mapping makes it
// TableInUseException. Elsewhere (a plain CreateTable into a name
// that is a CREATING restore target) the service's text is the one
Expand Down Expand Up @@ -232,6 +233,16 @@ pub fn storage_err_to_dynamo(e: extenddb_storage::error::StorageError) -> Dynamo
}
}

/// The service's answer to a change of a table that is `DELETING`
/// (`DeleteTable`, `UpdateTable`, `TagResource`, `UntagResource`):
/// `ResourceInUseException` with the `Table is being deleted` sentence.
pub(crate) fn table_being_deleted(name: &str) -> DynamoDbError {
DynamoDbError::ResourceInUseException(error_message(
ErrorMessageKey::TableBeingDeleted,
&[name],
))
}

/// Like [`storage_err_to_dynamo`], but includes the old item in
/// `ConditionalCheckFailedException` when `ReturnValuesOnConditionCheckFailure`
/// is `ALL_OLD`.
Expand Down
76 changes: 76 additions & 0 deletions crates/engine/src/delete_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ pub async fn handle_delete_table(
validate_table_name(&input.table_name, &ctx.limits)?;

let table_name = input.table_name.clone();
// Drop the cached TableKeyInfo before the storage call as well as after
// it. The storage call can outlive the request: MongoDB finishes a delete
// in a task of its own when the caller gives up, and the invalidation
// after the call then never runs. A write with an entry cached before the
// delete would create the dropped data collection again.
ctx.auth_cache
.invalidate_table_key_info(&ctx.account_id, &table_name)
.await;
let table_desc = ctx
.storage
.delete_table(&ctx.account_id, input)
Expand Down Expand Up @@ -56,6 +64,74 @@ fn deleting_description(mut desc: TableDescription) -> TableDescription {
#[cfg(test)]
mod tests {
use super::*;
use extenddb_storage::error::StorageError;

/// A second DeleteTable during the DELETING window: the measured sentence
/// (2026-10-24), byte for byte. The other non-ACTIVE statuses keep theirs.
#[test]
fn a_deleting_table_has_its_own_sentence() {
match storage_err_to_dynamo(StorageError::TableBeingDeleted("t".to_owned())) {
DynamoDbError::ResourceInUseException(msg) => assert_eq!(
msg,
"Attempt to change a resource which is still in use: Table is being deleted: t"
),
other => panic!("expected ResourceInUseException, got {other:?}"),
}
match storage_err_to_dynamo(StorageError::TableNotActive("t".to_owned())) {
DynamoDbError::ResourceInUseException(msg) => {
assert_eq!(msg, "Table is being created, updated, or deleted: t");
}
other => panic!("expected ResourceInUseException, got {other:?}"),
}
}

/// Records the key-info invalidations a handler asks for.
#[derive(Default)]
struct Invalidations(std::sync::Mutex<Vec<(String, String)>>);

impl extenddb_auth::TableKeyInfoCacheInvalidator for Invalidations {
fn invalidate<'a>(
&'a self,
account_id: &'a str,
table_name: &'a str,
) -> futures::future::BoxFuture<'a, ()> {
self.0
.lock()
.unwrap()
.push((account_id.to_owned(), table_name.to_owned()));
Box::pin(async {})
}

fn invalidate_all(&self) {}
}

/// The table's key-info entry is dropped before the storage call, so a
/// DeleteTable that does not get back to the handler (a caller that gives
/// up while MongoDB finishes the delete, or a call that fails, as here:
/// the test context's catalog has no tables) leaves no entry cached from
/// before it.
#[tokio::test]
async fn the_key_info_entry_is_dropped_before_the_storage_call() {
let invalidations = std::sync::Arc::new(Invalidations::default());
let mut ctx = crate::test_context::context_on(
crate::test_context::memory_engine().await,
"000000000000",
);
ctx.auth_cache = extenddb_auth::AuthCacheRegistry::default()
.with_table_key_info_invalidator(invalidations.clone());

let err = handle_delete_table(serde_json::json!({"TableName": "tbl"}), &ctx)
.await
.expect_err("a catalog without tables fails the storage call");
match err {
DynamoDbError::InternalServerError(msg) => assert_eq!(msg, "Internal server error"),
other => panic!("expected InternalServerError, got {other:?}"),
}
assert_eq!(
*invalidations.0.lock().unwrap(),
[("000000000000".to_owned(), "tbl".to_owned())]
);
}

#[test]
fn a_description_read_before_the_delete_answers_as_deleting() {
Expand Down
32 changes: 32 additions & 0 deletions crates/engine/src/index_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,38 @@ pub fn classify_vector_index_read(
}
}

/// The answer for a GSI or LSI name that `index_info_by_table_id` reported
/// missing (`err`) on the table `key_info` describes.
///
/// The key info can come from the key-info cache, and the cache keeps an entry
/// read while the table was `DELETING` after the control plane removes the
/// table, since that removal does not reach the cache. The index rows go with
/// the table, so a cached entry would turn a read on a table that is gone into
/// `The table does not have the specified index` until the entry expires. The
/// catalog is therefore asked for the table again. A table it no longer has is
/// answered as a read on a missing table (`ResourceNotFoundException`) and its
/// cache entry is dropped; a table it still has keeps `err`. The extra read
/// runs only for an index name that does not resolve.
pub async fn unresolved_index_error(
ctx: &OperationContext,
key_info: &TableKeyInfo,
err: extenddb_storage::error::StorageError,
) -> DynamoDbError {
match ctx
.storage
.table_key_info(&ctx.account_id, &key_info.table_name)
.await
{
Err(gone @ extenddb_storage::error::StorageError::TableNotFound(_)) => {
ctx.auth_cache
.invalidate_table_key_info(&ctx.account_id, &key_info.table_name)
.await;
crate::create_table::storage_err_to_dynamo(gone)
}
_ => crate::create_table::storage_err_to_dynamo(err),
}
}

/// Resolve an index name that `index_info_by_table_id` reported missing
/// against the table's vector index metadata.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/partiql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ mod returning;
mod select;
mod snapshot;
#[cfg(test)]
mod test_context;
pub(crate) mod test_context;
mod transaction;
mod write;

Expand Down
4 changes: 2 additions & 2 deletions crates/engine/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::create_table::storage_err_to_dynamo;
use crate::expression_helpers::{build_expression_maps, parse_optional_filter};
use crate::index_helpers::{
VectorIndexReadRefusal, classify_unresolved_index_read, combined_lek_key_schema,
validate_query_select_index_support,
unresolved_index_error, validate_query_select_index_support,
};
use crate::legacy_filter::{desugar_filter, desugar_key_conditions};
use crate::read_helpers::{PostRead, read_page};
Expand Down Expand Up @@ -78,7 +78,7 @@ pub async fn handle_query(
Err(err @ StorageError::IndexNotFound(_)) => {
match classify_unresolved_index_read(ctx, &key_info, idx_name).await? {
VectorIndexReadRefusal::NotFound => {
return Err(storage_err_to_dynamo(err));
return Err(unresolved_index_error(ctx, &key_info, err).await);
}
// Query refuses a backfilling vector index with the same
// message as an active one (measured 2026-08-20; Scan
Expand Down
5 changes: 4 additions & 1 deletion crates/engine/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::create_table::storage_err_to_dynamo;
use crate::expression_helpers::{build_expression_maps, parse_optional_filter};
use crate::index_helpers::{
VectorIndexReadRefusal, classify_unresolved_index_read, combined_lek_key_schema,
unresolved_index_error,
};
use crate::legacy_filter::desugar_filter;
use crate::read_helpers::{PostRead, read_page};
Expand Down Expand Up @@ -260,7 +261,9 @@ pub async fn handle_scan(
Err(err @ StorageError::IndexNotFound(_)) => {
return Err(
match classify_unresolved_index_read(ctx, &key_info, idx_name).await? {
VectorIndexReadRefusal::NotFound => storage_err_to_dynamo(err),
VectorIndexReadRefusal::NotFound => {
unresolved_index_error(ctx, &key_info, err).await
}
VectorIndexReadRefusal::Backfilling => {
DynamoDbError::ValidationException(format!(
"{VECTOR_INDEX_BACKFILLING_SCAN_PREFIX}{idx_name}"
Expand Down
53 changes: 49 additions & 4 deletions crates/engine/src/tagging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,43 @@ fn extract_table_name_from_arn(arn: &str) -> Option<&str> {
Some(table_name.split('/').next().unwrap_or(table_name))
}

/// What [`validate_resource_arn`] answers for a table that is `DELETING`.
#[derive(Clone, Copy, PartialEq, Eq)]
enum WhileDeleting {
/// `ListTagsOfResource`: the table is listed until it is gone.
Serve,
/// `TagResource` and `UntagResource`: refused as a table still in use.
Refuse,
}

/// Refuse a tag change on a table that is being deleted. The service answers
/// `TagResource` and `UntagResource` on a `DELETING` table with
/// `ResourceInUseException` and the sentence `DeleteTable` and `UpdateTable`
/// give in that window, and serves `ListTagsOfResource` (measured
/// 2026-11-03). The key info carries no status, and the data plane reads a
/// `DELETING` table as found on PostgreSQL and SQLite, so the status is read
/// with `describe_table`. Any other answer from it is left to the existence
/// check that follows.
async fn refuse_while_deleting(
table_name: &str,
ctx: &OperationContext,
) -> Result<(), DynamoDbError> {
if let Ok(desc) = ctx
.storage
.describe_table(
&ctx.account_id,
extenddb_core::types::DescribeTableInput {
table_name: table_name.to_owned(),
},
)
.await
&& desc.table_status == extenddb_core::types::TableStatus::Deleting
{
return Err(crate::create_table::table_being_deleted(table_name));
}
Ok(())
}

/// Validate that the ARN refers to an existing table owned by the caller.
///
/// The error classes and messages below match `DynamoDB`, verified against the
Expand All @@ -99,13 +136,18 @@ fn extract_table_name_from_arn(arn: &str) -> Option<&str> {
/// | Table ARN with a different partition, service, or region | `ValidationException` (invalid `TableArn`) |
/// | Stream ARN with a different partition, service, or region | `ValidationException` (`Invalid StreamArn`) |
/// | Table does not exist | `ResourceNotFoundException` |
/// | Table is `DELETING`, for `TagResource` and `UntagResource` (`while_deleting` is `Refuse`) | `ResourceInUseException` (`Table is being deleted`) |
///
/// Account is checked before the partition, service, and region, matching the
/// service: a cross-account ARN is denied without revealing whether its other
/// fields are valid. For a table ARN, a no-permissions principal is denied by
/// authorization before this runs; the partition, service, region, and
/// existence errors therefore surface only for an authorized principal.
async fn validate_resource_arn(arn: &str, ctx: &OperationContext) -> Result<(), DynamoDbError> {
async fn validate_resource_arn(
arn: &str,
ctx: &OperationContext,
while_deleting: WhileDeleting,
) -> Result<(), DynamoDbError> {
if !arn.starts_with("arn:") {
return Err(DynamoDbError::ValidationException(format!(
"One or more parameter values were invalid: ARNs must start with 'arn:': {arn}"
Expand Down Expand Up @@ -170,6 +212,9 @@ async fn validate_resource_arn(arn: &str, ctx: &OperationContext) -> Result<(),
))
})?;

if while_deleting == WhileDeleting::Refuse {
refuse_while_deleting(table_name, ctx).await?;
}
// Verify the table exists via table_key_info (lightweight check).
ctx.storage
.table_key_info(&ctx.account_id, table_name)
Expand Down Expand Up @@ -205,7 +250,7 @@ pub async fn handle_tag_resource(
));
}

validate_resource_arn(&input.resource_arn, ctx).await?;
validate_resource_arn(&input.resource_arn, ctx, WhileDeleting::Refuse).await?;

ctx.storage
.tag_resource(&input.resource_arn, &input.tags)
Expand Down Expand Up @@ -242,7 +287,7 @@ pub async fn handle_untag_resource(
));
}

validate_resource_arn(&input.resource_arn, ctx).await?;
validate_resource_arn(&input.resource_arn, ctx, WhileDeleting::Refuse).await?;

ctx.storage
.untag_resource(&input.resource_arn, &input.tag_keys)
Expand Down Expand Up @@ -277,7 +322,7 @@ pub async fn handle_list_tags_of_resource(
));
}

validate_resource_arn(&input.resource_arn, ctx).await?;
validate_resource_arn(&input.resource_arn, ctx, WhileDeleting::Serve).await?;

let tags = ctx
.storage
Expand Down
3 changes: 3 additions & 0 deletions crates/engine/src/update_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ fn update_table_err_to_dynamo(
StorageError::TableNotActive(name) => {
DynamoDbError::ResourceInUseException(format!("Table {name} is not in ACTIVE state"))
}
// The service words a DELETING table differently from the other
// non-ACTIVE statuses (measured 2026-10-24).
StorageError::TableBeingDeleted(name) => crate::create_table::table_being_deleted(&name),
StorageError::IndexAlreadyExists(name) => DynamoDbError::ValidationException(format!(
"One or more parameter values were invalid: Index already exists: {name}"
)),
Expand Down
21 changes: 21 additions & 0 deletions crates/engine/src/update_table_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,27 @@ fn an_internal_failure_is_still_an_internal_server_error() {
assert!(matches!(err, DynamoDbError::InternalServerError(_)));
}

/// UpdateTable on a DELETING table: the measured sentence (2026-10-24),
/// byte for byte, and the other non-ACTIVE statuses keep theirs.
#[test]
fn a_deleting_table_has_its_own_sentence() {
let err = update_table_err_to_dynamo(StorageError::TableBeingDeleted("t".to_owned()), "t");
match err {
DynamoDbError::ResourceInUseException(msg) => assert_eq!(
msg,
"Attempt to change a resource which is still in use: Table is being deleted: t"
),
other => panic!("expected ResourceInUseException, got {other:?}"),
}
let err = update_table_err_to_dynamo(StorageError::TableNotActive("t".to_owned()), "t");
match err {
DynamoDbError::ResourceInUseException(msg) => {
assert_eq!(msg, "Table t is not in ACTIVE state");
}
other => panic!("expected ResourceInUseException, got {other:?}"),
}
}

/// Measured 2026-10-24: a `StreamSpecification` object without `StreamEnabled`
/// gets the null-member sentence. A member that is not an object (a string, a
/// number, an array) is not that case: it is left to deserialisation, which
Expand Down
Loading
Loading