Repository navigation
feat(engine): serve a batch partially when a backend throttles some entries - #536
LeeroyHannigan wants to merge 41 commits into
Conversation
A backend that can classify its own failure into the service's error
vocabulary (a hosted database reporting a documented unavailability or
capacity condition) had no way to return that error with its own message:
every unrecognised StorageError variant reaches the client as the fixed
"Internal server error" string after an error-level log line.
StorageError::Service(DynamoDbError) carries a fully formed client error.
Nine engine functions map a StorageError to a client error. Six own a
catch-all and gain a Service arm that returns the error with its variant
and message unchanged and without the fault log line: the data path mapping
in create_table.rs, the backup mapping in backup.rs, the UpdateTable
mapping, the streams and TTL mappings, and sanitize_storage_error for the
metadata and tagging paths. The other three (the condition-check variant of
the data path mapping, the create-backup and restore mappings) delegate
their catch-all to one of the six. The server's authorization read
delegates to the data path mapping.
The engine keeps one rule for itself. A ConditionalCheckFailedException
carries its item to the client only when the request set
ReturnValuesOnConditionCheckFailure to ALL_OLD, which the condition-check
mapping applies to a backend's error as it does to the engine's own
ConditionFailed; the generic data path mapping, which has no such value to
read, discards the item as it does for ConditionFailed. The message is kept.
Tests: a Service pass-through test at every one of the nine mappings; at
each of the six with a catch-all, a control that Internal("driver text")
still becomes the fixed string, and a subscriber-based test that counts
error-level log events (none for a Service error, one for an Internal
error). tracing-subscriber becomes a dev-dependency of the engine crate for
that test. The condition-check item rule has a test per
ReturnValuesOnConditionCheckFailure value and one for the generic path.
The doc comment states the backend's obligation: the message crosses the
wire verbatim, so it must be service-shaped text with no driver output, host
names, connection strings or credentials; an unclassified failure stays
Internal, and Transient remains the queue workers' retry signal.
…ls, the RFCs and an ADR The storage design lists the variant beside the Internal redaction rule and states the backend's obligation for the message. The security model's error message section names it as the one path that carries backend-chosen text to a client, under the same wording rule as the engine's own messages. The backend author manual's DataEngine section states when to return it and when a failure stays Internal. RFC-0003 section 9.2 adds the obligation to the error fidelity criteria. RFC-0002 states that variants may be added to StorageError in a minor release, so a backend crate matching on it exhaustively carries a catch-all arm. ADR-0023 records the decision, the options not taken and the consequences.
…the throttle variants became structs The StorageError::Service tests constructed ProvisionedThroughputExceededException as a tuple variant; with the reasons list it is a struct variant with a constructor. This commit reconciles the two changes and belongs to whichever of them lands second.
…ntries Amazon DynamoDB serves the entries of a BatchGetItem or BatchWriteItem that the table has capacity for and returns the rest under UnprocessedKeys or UnprocessedItems; the call fails with the throttle error only when no entry could be served. ExtendDB's two batch handlers failed the whole request on the first storage error of any kind. A per-key storage call that fails with StorageError::Service carrying a throttle error (ProvisionedThroughputExceededException, ThrottlingException or RequestLimitExceeded) now moves that entry to the unprocessed set and the loop continues. BatchGetItem returns the table's KeysAndAttributes with Keys reduced to the unprocessed ones, in request order, and the other request fields echoed as sent; BatchWriteItem returns the throttled WriteRequest entries as sent, in request order. ConsumedCapacity and ItemCollectionMetrics count the served entries only, so the capacity and metrics bookkeeping moves after the storage call. When every entry of the request was throttled the call fails with the first throttle error. Every other storage error still fails the request as before. A BatchWriteItem that asked for ReturnItemCollectionMetrics SIZE carries the field as an empty map when no written item belongs to an item collection, and omits it without SIZE. The server records ThrottledRequests once and a read or write throttle event per table when a batch response carries a non-empty unprocessed map, since its own bucket never saw that throttle and the metrics would otherwise read as zero. Measured against the service on 2026-10-21 (1,070 raw responses on a 1 RCU / 1 WCU table seeded with 100 items of 4 KB): two partial BatchGetItem responses served 16 of 25 keys and echoed ConsistentRead and ProjectionExpression beside the 9 unprocessed keys, ConsumedCapacity counting the 16; 26 of 26 fully served responses carried UnprocessedKeys as an empty map; 13 of 13 fully processed BatchWriteItem responses carried UnprocessedItems as an empty map and, with SIZE, ItemCollectionMetrics as an empty map. The partial BatchWriteItem shape was measured on 2026-10-20 on an on-demand table: 18 of 80 batches returned 200 with 6 to 24 of 25 PutRequest entries echoed under UnprocessedItems. Documented in the API Reference and not reached in the samples: the echo of ExpressionAttributeNames and AttributesToGet, DeleteRequest entries under UnprocessedItems, and the all-throttled failure. The order of the service's served and unprocessed lists was neither request nor sorted order; the engine returns request order. Tests drive both handlers against a storage double that throttles a chosen set of partition key values: the partial shapes with the request fields echoed and served-only capacity, capacity by item size, the AttributesToGet echo, one table throttled beside a served one with an empty Responses list for it, exactly one entry served, every entry throttled failing with the throttle error carrying the read or write reason, nothing throttled serializing the empty maps, SIZE without collections, and a non-throttle Service error still failing the request. The partial-response metrics have their own unit tests. The double lives in its own file beside the tests. This change uses StorageError::Service and DynamoDbError::is_throttle and stacks on the pull requests that introduce them.
A backend that can classify its own failure into the service's error
vocabulary (a hosted database reporting a documented unavailability or
capacity condition) had no way to return that error with its own message:
every unrecognised StorageError variant reaches the client as the fixed
"Internal server error" string after an error-level log line.
StorageError::Service(DynamoDbError) carries a fully formed client error.
Nine engine functions map a StorageError to a client error. Six own a
catch-all and gain a Service arm that returns the error with its variant
and message unchanged and without the fault log line: the data path mapping
in create_table.rs, the backup mapping in backup.rs, the UpdateTable
mapping, the streams and TTL mappings, and sanitize_storage_error for the
metadata and tagging paths. The other three (the condition-check variant of
the data path mapping, the create-backup and restore mappings) delegate
their catch-all to one of the six. The server's authorization read
delegates to the data path mapping.
The engine keeps one rule for itself. A ConditionalCheckFailedException
carries its item to the client only when the request set
ReturnValuesOnConditionCheckFailure to ALL_OLD, which the condition-check
mapping applies to a backend's error as it does to the engine's own
ConditionFailed; the generic data path mapping, which has no such value to
read, discards the item as it does for ConditionFailed. The message is kept.
Tests: a Service pass-through test at every one of the nine mappings; at
each of the six with a catch-all, a control that Internal("driver text")
still becomes the fixed string, and a subscriber-based test that counts
error-level log events (none for a Service error, one for an Internal
error). tracing-subscriber becomes a dev-dependency of the engine crate for
that test. The condition-check item rule has a test per
ReturnValuesOnConditionCheckFailure value and one for the generic path.
The doc comment states the backend's obligation: the message crosses the
wire verbatim, so it must be service-shaped text with no driver output, host
names, connection strings or credentials; an unclassified failure stays
Internal, and Transient remains the queue workers' retry signal.
…ls, the RFCs and an ADR The storage design lists the variant beside the Internal redaction rule and states the backend's obligation for the message. The security model's error message section names it as the one path that carries backend-chosen text to a client, under the same wording rule as the engine's own messages. The backend author manual's DataEngine section states when to return it and when a failure stays Internal. RFC-0003 section 9.2 adds the obligation to the error fidelity criteria. RFC-0002 states that variants may be added to StorageError in a minor release, so a backend crate matching on it exhaustively carries a catch-all arm. ADR-0023 records the decision, the options not taken and the consequences.
crates/engine/src/lib.rs: main added the start_key module to the module list. This branch added the service_error_log_tests module under cfg(test) at the same place. The merged file declares both, in name order. docs/adr/README.md: main added rows for ADR-0023 (catalog migrations), ADR-0026 (credential cryptography on AWS-LC) and ADR-0027 (Cassandra index row version stamps). This branch added its ADR as 0023. Main owns number 0023, and the open read-options and Cassandra consistency branches hold 0024 and 0025, so the ADR of this branch moves to 0028. The file is renamed to 0028-backend-classified-client-error.md, its title line reads ADR-0028, and the README keeps main's three rows and lists the new row after them. No other file names the number.
crates/engine/Cargo.toml: main added `futures` to the engine's dependencies for the backup catalog work. This branch added a `[dev-dependencies]` section with `tracing-subscriber` for the log test at the mapping sites. The result lists `futures` with the other dependencies and keeps the dev-dependency section below it. Cargo.lock is main's file with `tracing-subscriber` added to the engine's dependency list, the one entry this branch brings.
crates/engine/src/batch_write_item.rs keeps the write loop of feat/throttling-reasons in write_batch, which tries every request and defers a transient, conflict or connection failure to UnprocessedItems. This branch's write loop goes. is_deferrable also takes a Service error that carries a throttle error, so a throttled request goes to UnprocessedItems through the same loop. The loop keeps the first throttle error and counts the throttled requests. When no request applied and the backend throttled every request, the batch answers the first throttle error, as this branch did. When no request applied and another failure was among them, the batch answers 503, as feat/throttling-reasons does. The DynamoDB API reference documents the throttle error only for a batch that it cannot process because of throttling. The comment on the rule and the warning text name the throttle case. The file also keeps the empty ItemCollectionMetrics map of this branch for a request that sets SIZE. write_batch_deferral_tests.rs gets one new row in the 503 test: a throttled request and a conflicted request, with nothing applied. crates/engine/src/create_table.rs keeps one storage error mapping test module, with the snapshot test from feat/throttling-reasons and the Service error tests from this branch. crates/engine/src/lib.rs keeps the start_key module from feat/throttling-reasons and the service_error_log_tests module from this branch. crates/engine/src/streams.rs keeps the GetRecords limit checks and streams_tests.rs from feat/throttling-reasons. It also keeps the crate visibility of storage_to_dynamo and the Service error mapping tests from this branch. crates/engine/src/update_table.rs keeps update_table_tests.rs from feat/throttling-reasons, and the merge moves the three Service error tests of this branch into that file. crates/engine/Cargo.toml keeps the dependencies, the feature table and the test dependencies from feat/throttling-reasons and the tracing-subscriber test dependency from this branch. docs/adr/README.md keeps the index rows and the License section from feat/throttling-reasons and the row of this branch for the backend-classified client error ADR.
MetricsCollector::record takes the account since #955. record_partial_batch_throttle now takes the account of the request and records both metrics under it, as the throttle records of the bucket do. Its tests query the metrics by that account. The storage traits changed on feat/throttling-reasons. BackupEngine is gone, and StorageEngine requires BackupCatalog, LegacyBackupReader, RestoreEngine and SnapshotEngine. get_stream_records takes the stream ARN. The test double of crates/engine/tests/batch_partial.rs implements the four traits with stubs that the tests never reach, as it did for BackupEngine. It also takes the new parameter. OperationContext has a backup runtime and an item authorizer, and the test context sets a runtime with one job slot and no authorizer. In crates/engine/src/backup.rs the merge put the service_error_tests module after the modules that feat/throttling-reasons added. rustfmt orders that list by name, so the commit moves the module into its place.
feat/throttling-reasons has ADR 0023 for the catalog migrations, and this branch carried the backend-classified client error decision as a second 0023. feat/storage-service-error moved that decision to 0028. This commit renames the file to 0028-backend-classified-client-error.md with the same content and title as on feat/storage-service-error, and moves its index row to 0028. The index row was the only link to the old name.
Since main #475, BatchWriteItem leaves a request that failed with a transient, conflict or connection error in UnprocessedItems. record_partial_batch_throttle read UnprocessedItems and UnprocessedKeys from the response, so it recorded those deferrals as throttles. DispatchMetrics now carries throttled_tables, by the catalog's table name. It lists each table of a batch with at least one request or key that a backend throttled, once. write_batch adds a table where it counts a throttle, and handle_batch_get_item adds one where it leaves a key unprocessed. record_partial_batch_throttle records ThrottledRequests and the read or write throttle event for each of those tables. A table that a request named by its ARN gets the same table dimension as main's other records (#922).
…page The merge of feat/throttling-reasons brought main's row for a BatchWriteItem with no request applied, which says that the batch answers 503. This branch's row on partial batch success says that any other backend error still fails the request. A batch of which a backend throttled every request answers the first throttle error, and BatchWriteItem defers transient, conflict and connection failures. Each row now says so and names the other row.
crates/engine/Cargo.toml keeps the tokio test-util, extenddb-storage-sqlite, tempfile and libc dev-dependencies from main and the tracing-subscriber dev-dependency from this branch. crates/engine/src/streams.rs keeps the tests module in streams_tests.rs from main and the Service arm from this branch. The Service pass-through tests from this branch move into streams_tests.rs. crates/engine/src/update_table.rs keeps the tests module in update_table_tests.rs from main and the Service arm from this branch. The Service pass-through tests from this branch move into update_table_tests.rs. docs/adr/README.md keeps the ADR-0029 row from main and the ADR-0028 row from this branch.
Main added the runtime, store_identity, store_maintenance and sync modules to backup.rs. The merge placed this branch's service_error_tests declaration after them, where rustfmt wants it before store_identity. This commit moves the declaration. Nothing else changes.
…ional check item A ConditionalCheckFailedException inside StorageError::Service reached the client with its item through the backup, UpdateTable, streams and TTL mappings and through sanitize_storage_error. Only the two create_table mappings applied the ALL_OLD rule that the variant's doc comment states. create_table::service_err_to_dynamo now holds the rule, and every Service arm calls it. It returns the error unchanged, except that a conditional check error loses its item. storage_err_to_dynamo_with_ccf keeps one arm of its own, for a request that set ReturnValuesOnConditionCheckFailure to ALL_OLD. The tests now give every mapping the same rows: five backend-classified errors, each with a message that the engine never writes. Each row holds the body the client gets (error_document), and the CCF row has an item. The rows run at the seven mappings that the crate root can reach. The create-backup, restore and shard lookup mappings delegate to these, and their own modules run the rows through them. This commit removes the per-site tests that the rows replace. They used the engine's own text "The conditional request failed" as the backend message. A mapping that replaced the backend message with that text passed them.
…ts error class A statement whose item operation failed with a throttle, a conflict or a fault of the server got Code ValidationError in its BatchExecuteStatement entry. A Service error from a backend reaches the entry this way, and so do the engine's own conflict and internal errors. StatementError::from_error now takes the Code from batch_code. That function gives the code that the API Reference lists for each class (BatchStatementError): ProvisionedThroughputExceeded, ThrottlingError, RequestLimitExceeded, TransactionConflict, ItemCollectionSizeLimitExceeded and InternalServerError. The list has no code for ServiceUnavailable, which gets InternalServerError. Every other class keeps ValidationError. The message and the TableName rule do not change: the entry names the table when the failure reached the item. The test has one row per class and compares the whole entry.
… missing table authorize_request reads the table's key schema before the IAM decision, which needs it for dynamodb:LeadingKeys. key_info_for_authz passed every error of that read except TableNotFound to the caller. A backend that answers StorageError::Service(ResourceNotFoundException) there told a caller without access that the table does not exist, before the IAM decision could refuse the caller. key_info_for_authz now treats that error as it treats TableNotFound: the key stays absent, the IAM decision runs, and a caller it refuses gets the refusal. Every other Service error still fails closed with its own class. Mapped to a missing table, such an error would reach the policy evaluator with dynamodb:LeadingKeys absent. The doc comment gives that as the reason for failing closed on transient and connection faults. The tests gain a row for the backend's not-found and one for a backend-classified ServiceUnavailable.
…t covers The ADR said that nine functions map a StorageError to a client error and that each ends in a catch-all. At this head there are ten. Five end in a catch-all, and the data path mapping names every variant. Four delegate to one of those six: the conditional check mapping, the create-backup and restore mappings and the shard lookup mapping. The ADR now lists them by file. The decision section names create_table::service_err_to_dynamo as the one function every Service arm calls, and the rule it applies to a conditional check error's item. It also records the two answers that depend on the error's class. One is the Code of a BatchExecuteStatement entry. The other is the server's key schema read before the IAM decision, which treats a backend's ResourceNotFoundException as a missing table. The rationale section says that the log test runs at the seven mappings the crate root reaches. The three private mappings write no log line of their own, and their modules' tests cover them.
The security model and the backend author manual called StorageError::Service the one path that carries backend-chosen text to a client. The data path mapping also passes on the message of Validation, NoOpUpdate, Unsupported, IndexesInUse, LimitExceeded, BackupInUse and TransactionConflict as the backend wrote it. It passes on the cancellation reasons of TransactionCanceled too. Both pages now list these variants and apply the same rule to their text: service-shaped, with no driver output, host names, connection strings or credentials. The security model also records that the server reads a table's key schema before the IAM decision. A backend's ResourceNotFoundException from that read is a missing table, so a caller the IAM decision refuses gets the refusal.
…ackup log tests use The Service log test sets a counting subscriber as the thread's default. tracing caches each callsite's interest when a thread first reaches it. While one thread default is the only subscriber in the process, that cache comes from the default of the thread that got there first. A test without a subscriber that reaches a mapping's log callsite first caches it as "never", and the count then reads 0. A count of 0 is also the expected answer for a Service error, so that half of the test could pass without checking. The backup log tests already install a global subscriber that is interested in every callsite (InterestedInEveryCallsite). This commit moves it into crates/engine/src/test_tracing.rs, and both the backup LogLines and error_events_during install it before they set a thread default. The new test an_event_from_a_callsite_another_thread_met_first_is_counted makes another thread meet a callsite first, and it counts 0 events without the global subscriber.
#487 gives TransactionConflictException and ServiceUnavailable the BatchExecuteStatement entry measured for a contended statement: Code TransactionConflict, the message "Transaction is ongoing for the item" and no TableName. batch_code gave the first TransactionConflict with the error's own message and TableName, and the second InternalServerError. Once both PRs merge, #487's arm matches first and those two arms are dead. batch_code drops the two arms, so they keep ValidationError until #487 merges. The test drops their rows and the ValidationException row, which main's an_error_of_the_item_operation_names_the_batch_table covers.
…ient The backup mapping passes on the backend's message of TableNotFound, TableAlreadyExists and TableNotActive, and the streams mapping that of TableNotFound. The security model and the storage extension manual now list them with the other variants. ADR-0028 says which BatchExecuteStatement classes keep their listed code, now that #487 maps the contended entry. It also says that the shard lookup mapping checks the shard id length before it delegates, and names no variant of its own.
The None case repeated service_error_log_tests, whose sites() runs the conditional check mapping without ALL_OLD over the conditional check row. The comment on sites() now says that this mapping also maps the engine's own ConditionFailed.
The merge brings main's move of the backup storage error mapping from backup.rs to backup_requests.rs. So the fault log test names the function at its new path. StreamEngine gained first_sequence_number_at_or_after on main, so the batch_partial storage double implements it as not exercised, like its other stream methods.
…ests through their constructors The merged storage-service-error head builds ProvisionedThroughputExceededException, ThrottlingException and RequestLimitExceeded as tuple variants in the fault log rows and in the BatchExecuteStatement code test. On this branch they are struct variants with a reasons list, so the tests build them with provisioned_throughput_exceeded, throttling and request_limit_exceeded and an empty list. An empty list is left out of the error body, so the expected bodies do not change.
CloudWatch's metrics page for DynamoDB counts each throttled entry of a BatchGetItem or BatchWriteItem as a ReadThrottleEvents or WriteThrottleEvents event. A batch counts in ThrottledRequests only when every entry was throttled. A throttled request stays out of UserErrors. The server recorded ThrottledRequests and one throttle event per table on a batch that answered 200 with entries a backend throttled. It counted the throttle error of a batch whose every entry was throttled in UserErrors. DispatchMetrics::throttled_tables now maps each table, by catalog name, to the number of its entries a backend throttled. On a 200 the server records that number as one read or write throttle event data point per table. It records no ThrottledRequests there. record_error_metrics counts a throttle error in ThrottledRequests, under the table the request named when it names one, and not in UserErrors. The server's own bucket records its refusals before dispatch. So that arm counts a throttle a backend reported.
…ery throttle class The partial batch tests compared the served and unprocessed lists as sets, so a list returned in reverse order passed. They also ran with ProvisionedThroughputExceededException only, so a check narrowed to that class passed. No test held the first throttle error of an all-throttled batch or the catalog name the engine hands the server. The tests now compare Responses, UnprocessedKeys, UnprocessedItems and ItemCollectionMetrics in request order. The partial and all-throttled tests of both operations run for ProvisionedThroughputExceededException, ThrottlingException and RequestLimitExceeded. Each class has its service message and reasons list, and the tests compare the error by status and body. Two tests throttle the keys or puts of one table with different errors. They rotate the errors so that each class comes first once, and expect the error of the first entry. Two tests send a table ARN as the request name. They expect the answer under the ARN and the throttled entry count under the catalog name. The storage double takes an error per key for this.
…and read the metrics No server test reached the call that records the throttle metrics of a batch a backend served partially. Every handler test ran on SQLite, which never reports a throttle, so the call recorded nothing in any of them. The new test builds the handler state with the engine tests' storage double in place of the SQLite engine for the table and item calls. It sends a partly throttled BatchGetItem, a partly throttled BatchWriteItem and an all-throttled BatchGetItem. Then it reads ReadThrottleEvents, WriteThrottleEvents, ThrottledRequests and UserErrors from the collector. The double is included by path, as the bin crate includes the PostgreSQL catalog check support.
… contract The storage design said that every engine mapping site returns a Service error to the client unchanged. On BatchGetItem and BatchWriteItem, the engine holds back a throttle error for one entry. The entry goes to UnprocessedKeys or UnprocessedItems and the client sends it again. A backend that reported a throttle for a write that had committed would have the write applied twice, with a second stream record. Only a code comment on is_deferrable said so. The Error Types section of the storage design now states the hold-back and the rule it puts on a backend. A backend reports a throttle for a write only when the write did not commit, and reports a write of unknown commit outcome as Internal. The backend author manual, the security model and ADR-0028 name the hold-back and point at that section.
Clippy's type_complexity lint refused the inline tuple type of the rows.
…a backend throttled CloudWatch's metrics page for DynamoDB counts each throttled entry of a BatchGetItem or BatchWriteItem as a ReadThrottleEvents or WriteThrottleEvents event. A batch in which every entry was throttled adds one ThrottledRequests, and its entries still count as events. The server recorded the ThrottledRequests of that batch and no events. The engine answers that batch with the throttle error alone, so the counts did not reach the server. batch_entry_counts counts the entries of each table from the request before the dispatch, by the table name an ARN names. When a batch answers a throttle error, the handler records those counts with record_partial_batch_throttle, one data point per table, as it does on a 200. authz_resource::table_name_only reduces the ARN, and is now pub(crate). A throttle that the backend reports on the catalog read also gives the batch's throttle error, so it also counts every entry. The service has no such failure.
…per-table map Both batch handlers counted the throttled entries twice: in throttled_count and in the per-table map throttled_tables, incremented in the same arm. The all-throttled checks now compare the sum of the map's values with the number of keys or of requests not applied, and throttled_count is gone.
…ne helper The recorder's row table and the handler test of the batch throttle metrics each read a metric's sum and data point count from the collector. Each test had its own copy of that query. points in throttle_helpers.rs now takes the account, and both tests call it.
The comments on the all-throttled batch said the answer was documented and not measured. They also said the same of the shape of a fully throttled table in Responses. Measured against the service on 2026-11-24, 24 of 24 BatchGetItem and 3 of 3 BatchWriteItem batches whose every entry was throttled answered 400. In 29 of 29 responses the service left a fully throttled table out of Responses. The comments in both batch handlers and in the batch_partial tests now say so. The tests and the handler still keep that table as an empty list. The comment on record_error_metrics now states the UserErrors rule of the page in two sentences: one for a failed condition, one for a throttled request.
|
Throttle metrics: changed in 0890859 and 0923371. A partly served 200 records each table's throttled entry count as one |
demohan
left a comment
There was a problem hiding this comment.
At f9e372a a partly served batch records no ThrottledRequests, an all-throttled batch counts in ThrottledRequests and not in UserErrors, write throttle events are one per entry and table, and the handler, storage contract, order and throttle class items are done; the Responses shape is as it was, and two metric rows differ from the service, one of them because of what I asked for.
- On the service in us-east-1 a partly served 200 had no
ThrottledRequestspoint in any minute, an all-throttled batch counted one per attempt, and write events were 25 per 25-put batch, 5 per 5 puts and 2 per 2 puts on each of two tables; this head records the same, and the points keep their sum and count through the SQLite and PostgreSQL metric stores. Removing the error-path events, counting one per table, recording on a 200, counting the error inUserErrors, or leaving an ARN unreduced each fails a test, the handler call is pinned, and the eight batch shapes answer as at the reviewed commit, twice, on both backends. fmt, both clippy commands and the 1.91.1 check are clean, and CI is green on 60 of 60. - For a single-table all-throttled batch, the service records
ThrottledRequestsunder TableName and Operation in 23 of 23 minutes, and under Operation alone only when two tables are throttled (9 minutes); this head uses Operation alone for both.
I will approve once a fully throttled table is left out of Responses, the single-table ThrottledRequests point carries its table, and the read events follow the service.
| // class can come out; the service's choice for that case is not measured | ||
| // (one table per request in the sample). A table whose every key was | ||
| // throttled beside a served table keeps an empty `Responses` list; the | ||
| // service left it out in 29 of 29 measured responses. |
There was a problem hiding this comment.
The comment records the difference, but the shape is unchanged: through handle_request this head answers "Responses":{"T":[],"U":[...]} twice, and on the service 24 of 24 responses left a table whose 15 keys all came back unprocessed out of Responses and out of ConsumedCapacity. tests/batch_partial.rs:202-205 asserts the [] entry; leaving the table out, with the test expecting that, would match.
| for (table, entries) in throttled_tables { | ||
| metrics.record( | ||
| event, | ||
| f64::from(*entries), |
There was a problem hiding this comment.
My earlier comment asked for one read event per entry, and that is not what the service does for BatchGetItem. With one attempt per call, batches of 1, 2, 3, 4, 5, 8, 10, 16 and 25 keys on a throttled table gave 1, 2, 2, 2, 2, 3, 3, 4 and 5 ReadThrottleEvents (1 and 25 keys measured twice), where this head records the key count, 25.0 for 25 keys. The write events are one per entry, as here. The service's rule is not settled by these points; a count that grows more slowly than the keys, pinned by these rows, would be closer than the key count.
| SystemErrors, | ||
| UserErrors, | ||
| /// Throttled request count. Recorded when token bucket rejects a request. | ||
| /// Throttled request count. Recorded when the token bucket rejects a request or a backend serves a batch partially. |
There was a problem hiding this comment.
Optional. Since 0890859 this doc no longer holds: a partly served batch records no ThrottledRequests.
What
Amazon DynamoDB serves the entries of a
BatchGetItemorBatchWriteItemthat the table has capacity for. It returns the rest underUnprocessedKeysorUnprocessedItems, and the call fails with the throttle error only when no entry could be served. ExtendDB'sBatchGetItemfailed the whole request on the first storage error of any kind.BatchWriteItemdeferred only transient, conflict and connection failures toUnprocessedItems(#475), and failed the request on any other storage error, a throttle included.A per-key storage call that fails with
StorageError::Servicecarrying a throttle error (ProvisionedThroughputExceededException,ThrottlingExceptionorRequestLimitExceeded) now moves that entry to the unprocessed set and the loop continues.BatchGetItemreturns the table'sKeysAndAttributeswithKeysreduced to the unprocessed ones, in request order. It echoes the other request fields (ConsistentRead,ProjectionExpression,ExpressionAttributeNames,AttributesToGet) as sent.BatchWriteItemreturns the throttledWriteRequestentries as sent, in request order.ConsumedCapacityandItemCollectionMetricscount the served entries only. When every entry of the request was throttled the call fails with the first throttle error. OnBatchGetItemevery other storage error still fails the request as before. OnBatchWriteItemthe engine defers a request that meets a transient, conflict or connection failure, as #475 made it. A batch with nothing applied and such a deferral answers 503. DynamoDB documents the throttle error only for a batch that it cannot process because of throttling. ABatchWriteItemthat asked forReturnItemCollectionMetrics: SIZEcarries the field as an empty map when no written item belongs to an item collection, and omits it withoutSIZE.The server's own token bucket is unchanged. It runs before dispatch, keys on the request's top-level
TableName, and refuses a whole request. It has no per-entry view, so it applies to single-item calls and produces no partial response. This change covers the backend-reported throttle, which a backend returns throughStorageError::Service. No in-tree backend returns one yet. When a backend throttled entries of a batch that answered 200, the engine counts them per table, by catalog name, inDispatchMetrics::throttled_tables. The server records each count as oneReadThrottleEventsorWriteThrottleEventsdata point with the account and the table, and records noThrottledRequests. A batch whose every entry was throttled answers the throttle error. The server counts that error inThrottledRequestsunder the account and the operation, and not inUserErrors. The all-throttled error also records one throttle event data point per table, with the entry count as its value. The server counts those entries from the request, because the engine answers that batch with the error alone. The CloudWatch metrics page for DynamoDB gives both rules:The server does not count the entries of
UnprocessedItems, because since #475 they also hold requests deferred for a transient, conflict or connection failure.Why
A client with a backend that throttles per entry got a 400 for the whole batch and had to resubmit everything. The service serves what it can, and the SDKs' batch helpers resubmit the unprocessed entries only. The echoed
KeysAndAttributescarries every field the SDKs need to resubmit (aProjectionExpressionbrings itsExpressionAttributeNamesalong).On 2026-10-21 I measured the service with 1,070 raw responses on a 1 RCU / 1 WCU table seeded with 100 items of 4 KB. The client was boto3 with the standard retry mode and one attempt.
BatchGetItemresponses served 16 of 25 keys and echoedConsistentReadandProjectionExpressionbeside the 9 unprocessed keys.ConsumedCapacitycounted the 16.UnprocessedKeysas an empty map.BatchWriteItemresponses carriedUnprocessedItemsas an empty map and, withSIZE,ItemCollectionMetricsas an empty map.The partial
BatchWriteItemshape was measured on 2026-10-20 on an on-demand table. In 18 of 80 batches the answer was 200, with 6 to 24 of the 25PutRequestentries echoed underUnprocessedItems. The service's served and unprocessed lists came back in neither request nor sorted order. The engine returns request order. Documented in the API Reference and not reached in the samples: the echo ofExpressionAttributeNamesandAttributesToGet,DeleteRequestentries underUnprocessedItems, and the all-throttled failure.Stacking
This branch is built on #529 (
StorageError::Service) and #532 (DynamoDbError::is_throttle). The change under review is the feature, its test reconciliation and the commits listed under "Changes since the 24 November review". The branch also merges #532 atfa154a293and #529 atea4efd4b9. It also holds the merge of #532's head and five follow-up commits, described below. A rebase ontomain, after both bases merge, has to keep theBatchWriteItemresolution of that merge.Merge of #532's head
eca7b869fmerges #532 atfd9cf3a97, which holdsmainat95425f5e8. Seven files conflicted. Incrates/engine/src/batch_write_item.rs, #475 onmaindefers transient, conflict and connection failures toUnprocessedItemsinwrite_batch, and the batch answers 503 when no request applied. This branch had a second loop of its own for throttles. The merge keeps one loop,main's. A throttle defers its request in that loop like the other deferrable failures. With nothing applied, a batch of which the backend throttled every request answers the first throttle error. A batch in which the engine deferred a request for another reason answers 503. An internal error still fails the batch with 500. The DynamoDB API Reference documents the throttle error for aBatchWriteItemthat cannot process any item because of throttling. The other six files keep both sides.The follow-up commits:
542d07332adapts this branch's code to interfaces thatmainchanged in files that merged without a conflict. For example,MetricsCollector::recordtakes the account since fix(metrics): keep each account's metrics apart #955, and the test double implements the four backup traits that replacedBackupEngine.f5ef79484renumbers the backend-classified client error ADR from 0023 to 0028, as feat(storage): a StorageError::Service variant the engine passes through #529 has it, because 0023 onmainis the catalog migrations ADR.fa7a1e524addsDispatchMetrics::throttled_tables, so the server records a throttle only for a table that a backend throttled. Before it, the server read the response'sUnprocessedItems, which since fix(mongodb): retry a write conflict on the stream sequence counter #475 also holds deferred requests.3cd1be409updates the twoBatchWriteItemrows of the differences doc for the merged rule.e63887da6fixes the rule comment and the partial batch row: a batch with a deferred request answers 503, and an internal error answers 500.Changes since the 24 November review
87b9a8297merges feat(core): throttle errors carry the service's ThrottlingReasons #532 atfa154a293.crates/engine/src/backup.rsconflicted becausemainmovedstorage_err_to_dynamotobackup_requests.rs. TheServicearm moved with it. Indocs/differences-from-dynamodb.mdthe merge keeps feat(core): throttle errors carry the service's ThrottlingReasons #532's "Throttle error bodies" row and this PR's "Partial batch success under throttling" row.f7a2adac9fixes the engine test build after that merge: the fault log test names the moved function, and thebatch_partialstorage double implements the newfirst_sequence_number_at_or_after.6287ab4f3merges feat(storage): a StorageError::Service variant the engine passes through #529 atea4efd4b9. Twelve files conflicted. Each takes feat(storage): a StorageError::Service variant the engine passes through #529's side: onecreate_table::service_err_to_dynamofor everyServicearm, the rows test and the ADR-0028 counts. The merge also drops the older per-siteServicetests that the merge brought back instreams.rs,ttl.rsandupdate_table_tests.rs, which feat(storage): a StorageError::Service variant the engine passes through #529 replaced with its rows test.523e3b43ebuilds the throttle errors of feat(storage): a StorageError::Service variant the engine passes through #529's tests through their constructors, because feat(core): throttle errors carry the service's ThrottlingReasons #532 made them struct variants.0890859b8counts each throttled entry as a throttle event and the all-throttled error as a throttled request.15805a722makes thebatch_partialtests compare in request order and run the three throttle classes. It adds tests of the first throttle error and of the catalog name of an ARN-keyed request.2a0676bd2adds thehandle_requesttest of the batch throttle metrics.c9fae6adbstates the backend rule for a throttle on a batch in the storage design. The backend author manual, the security model and ADR-0028 point at it.5e16c28a5names a test row type for Clippy.092337105records the throttle events of an all-throttled batch:batch_entry_countscounts each table's entries from the request, and the handler records them on a throttle error.17dab8949dropsthrottled_countfrom both batch handlers. The all-throttled checks sum the per-table map.cf240c354gives the two server tests one helper that reads a metric from the collector.f9e372a29cites the measured all-throttled answers in the comments of both handlers and ofbatch_partial.Testing done
Eighteen integration tests in
crates/engine/tests/batch_partial.rsdrive both handlers against a storage double (tests/batch_partial/failing_store.rs). The double throttles a chosen set of partition key values and records the writes it applied. The tests cover:AttributesToGetechoResponseslist for itSIZEwithout collectionsServiceerror still failing the requestThey compare every list in request order, and the throttle tests run for
ProvisionedThroughputExceededException,ThrottlingExceptionandRequestLimitExceeded. The metrics have two row tables inthrottle_helpers.rs, for the recorder and forbatch_entry_counts, and one test of the three throttle classes inresponse.rs. Ahandle_requesttest inhandler/throttle_wire_tests.rsreads the collector for a partial and an all-throttled batch. That test uses the storage double ofbatch_partial.Negative controls, each on a clean committed tree and restored after:
BatchGetItemtestsBatchGetItemfails its one-served testResponseslists fails the two-table testProjectionExpressionor theAttributesToGetecho fails the matching testItemCollectionMetricsunderSIZEfails its test, and swallowing a non-throttleServiceerror fails that testEach of these fails a server test:
ThrottledRequestsrecorded on a 200batch_entry_countsEach of these fails a
batch_partialtest:UnprocessedKeysorUnprocessedItemslistOn the merge: an all-throttled check that is always true fails the mixed row (one throttled request and one conflicted request answer 503). Without the throttle case in
is_deferrable, twobatch_partialtests fail. Whenwrite_batchnames a table for every deferral and not only for a throttle, the held-item test fails.At
f9e372a29,cargo +1.97.0 clippy -p extenddb-engine -p extenddb-server --all-targets -- -D warningspasses, and so doescargo +1.97.0 test -p extenddb-storage-postgres --test doc_version_literals. The 899 engine library tests includethe_reconciler_resumes_a_dead_manifest_restore_with_its_spool_host, which failed once in the full run and passed alone (#995).e63887da6changes two comments and one doc row only.Checklist
cargo test --workspace --lib; the integration suites run in CI)cargo fmt --check)cargo clippy --all-targets -- -D warnings)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. The wire change reproduces measured service behaviour on a path no in-tree backend reaches yet; no trait changes.
Breaking changes
None. The batch responses gain populated
UnprocessedKeysandUnprocessedItemsonly when a backend reports a per-entry throttle, which no in-tree backend does today; every other response is byte-identical to before except that aBatchWriteItemwithReturnItemCollectionMetrics: SIZEnow carries"ItemCollectionMetrics": {}where it carried nothing, matching the service.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.