Repository navigation
feat(core): throttle errors carry the service's ThrottlingReasons - #532
LeeroyHannigan wants to merge 13 commits into
Conversation
Amazon DynamoDB names the throttled resource and the limit on a throttle
error: a reasons list with one {reason, resource} entry, where reason is
ResourceType + OperationType + LimitType and resource is the table or index
ARN. ExtendDB's three throttle errors carried a message string only, and
the server's own throttle refusal sent one fixed provisioned-capacity body
for every bucket and billing mode.
The three throttle variants of DynamoDbError (ProvisionedThroughputExceededException,
ThrottlingException, RequestLimitExceeded) become struct variants with a
message and a reasons list, built through provisioned_throughput_exceeded,
throttling and request_limit_exceeded, read through throttling_reasons and
is_throttle. The error serializer renders the list as ThrottlingReasons on
the first and third and as throttlingReasons on ThrottlingException, and
omits it when empty. ThrottlingException moves to the
com.amazon.coral.availability# namespace. The message constants carry the
measured texts for a table's own capacity, a hot key and the
OnDemandThroughput caps, and the documented text for the account quota.
The throttle manager reports which bucket refused (the table, the partition
key or the account aggregate) with the table's billing mode, and an
on-demand table whose OnDemandThroughput caps are set is sized by the caps,
per direction: a table capped on writes only keeps the default read ceiling
and reports the caps limit on a write refusal alone. The server maps the
cause onto the body the service sends: the provisioned class and
Table{Read|Write}ProvisionedThroughputExceeded for a provisioned table's own
capacity; ThrottlingException with TableWriteKeyRangeThroughputExceeded for
a hot-key write on an on-demand table and no reasons list for a hot-key
read; ThrottlingException with the caps message and
Table{Read|Write}MaxOnDemandThroughputExceeded at a cap. The resource is the
table ARN DescribeTable returns; an ARN-form TableName naming a table in
this account is reduced to the bare name first, and a name no table can
have gets no reasons list, since the account bucket can refuse before the
engine has seen the name. A hot key on a provisioned table was captured
once (the provisioned class and message with
TableWriteKeyRangeThroughputExceeded); its read form, the on-demand default
ceiling and the account aggregate follow the API Reference's reason grammar
and were not produced by the measurements. The code says which is which.
Measured against the service on 2026-10-20 (435 bodies, one Region) and
2026-10-24 (9,622 bodies in us-east-1 and eu-west-1): every read and write
operation on a provisioned table, hot-key writes and reads on an on-demand
table, a table at its OnDemandThroughput caps, and index back-pressure,
which the server does not model. No response carried x-amz-retry-after.
Compatibility. The wire change matches the service; the SDKs classify a
throttle by the name after the # in __type, so the namespace move changes
no retry. The Rust change is breaking for code outside this workspace that
constructs or destructures the three throttle variants, ThrottleResult's
throttled arms or a TableThroughput literal: the variants become struct
variants, the arms carry a ThrottleCause, and TableThroughput gains two
fields. Such code moves to the constructors (provisioned_throughput_exceeded,
throttling, request_limit_exceeded; TableThroughput::provisioned, on_demand,
on_demand_capped) and the accessors (throttling_reasons, is_throttle,
ThrottleResult::cause). No in-tree crate outside the changed files names
any of them. The change lands in the next 0.x minor.
Tests: the three classes keep their status and type name and carry their
reasons; the serializer produces the measured documents for each class and
omits the empty list; the throttle manager reports the cause and the
billing mode for the table, partition and account buckets, sizes a capped
table by its caps on both registration paths, reports a half-capped table's
cap for its direction only, and scales the balance when a table is
re-registered under a cap; every arm of the cause mapping in both
directions, with and without a resource; and seven in-process requests
through the handler against an in-memory engine (a provisioned write and
read, an on-demand hot-key write and read, a capped table's Query and
PutItem, a half-capped table's write and read, an account refusal with an
ARN-form and an invalid name, and a served request). The SQLite storage
crate becomes a dev-dependency of the server crate for those.
…index back-pressure gap
crates/server/Cargo.toml keeps the dev-dependency block from main, which already lists extenddb-storage-sqlite as a path dependency. This branch's reason for that dependency goes into main's comment. docs/differences-from-dynamodb.md keeps the warm throughput row from main and the on-demand capacity row from this branch.
Main added backup_runtime, request_timeout and admission to AppState. The build_state literal in the throttle wire tests now sets all three. It uses a BackupRuntime with one job slot, a 30 s request timeout and Admission::default(), which serve.rs also uses.
…e test Main's table name gate (#830) refuses a TableName outside the service's pattern before authorization. GetItem on the name "bad name!" now answers ValidationException, and the throttle segment does not run. The second request in account_throttle_reduces_an_arn_name_and_omits_an_invalid_one now expects that answer, with no ThrottlingReasons.
demohan
left a comment
There was a problem hiding this comment.
The provisioned-table bodies match the service. The table, index and account limits carry ThrottlingReasons with the service's reason strings and resource ARNs, and the throttle check runs after authorization and the cross-account refusal. The cap error body, the on-demand hot-key write body and cap recovery after a restart work on SQLite, PostgreSQL, MongoDB and Cassandra. Every negative control in the PR body fails as claimed. CI is green on 64 of 64 checks.
The three items below block the merge, and two of them answer requests differently than main does. I will approve once they and the test items are done.
crates/core/src/throttle.rs
Optional. The file grows from 561 to 669 lines.
| reason("KeyRangeThroughputExceeded"), | ||
| ) | ||
| } | ||
| // A hot-key read on an on-demand table carries no reasons list |
There was a problem hiding this comment.
A hot-key GetItem on an on-demand table carries ThrottlingReasons on the service: 234 of 234 throttled GetItem bodies over three runs, strongly and eventually consistent, named TableReadKeyRangeThroughputExceeded with the table ARN. Only Query omits the list (155 of 155), and this head does not put Query through the per-key bucket. So this branch runs only for GetItem, where the service sends the reason. The same statement is in crates/core/src/error/mod.rs:180, docs/differences-from-dynamodb.md:206 and two tests.
| /// on a throttle. | ||
| #[must_use] | ||
| #[allow(clippy::cast_precision_loss)] // request-unit caps are small enough for f64 | ||
| pub fn on_demand_capped( |
There was a problem hiding this comment.
The bucket of a capped on-demand table is sized at its OnDemandThroughput caps, and the service enforces those caps loosely. Fresh tables, 8 threads for 8 seconds:
- read cap 100: the service served 8,026 of 8,026, main 7,747 of 7,747, this head 903 of 7,567
- read cap 1: the service served 1,005 and 1,050 on two tables, this head 9 and 10
- write cap 1: the service 40 of 40, main 40 of 40, this head 6 of 40
After 120 seconds idle, the service let 39 requests through before refusing, and this head let 60 of 60 through, so the 300-second carry-over is not what the service does either.
| @@ -230,12 +306,18 @@ impl ThrottleManager { | |||
| if let Some(existing) = tables.get_mut(&key) { | |||
| existing.read.update_rate(throughput.rcu); | |||
There was a problem hiding this comment.
update_rate scales a negative balance by the ratio of the rates, so a debt keeps its length in seconds when the rate changes. A capped table that goes into debt stays refused after its cap is raised or removed. With a write cap of 1, one 300 KB PutItem (293 units), then UpdateTable raising the cap to 10000, the first accepted write came 292.1 s later, after 1,148 refusals naming the cap. With the cap removed, 79 of 79 writes were refused over 20 s. Main accepted the first write after UpdateTable in 0.003 s, and the service refused only for about 6 s and then accepted 93 writes in a row, over 4 runs. Keeping a negative balance as it is and scaling only a positive one, then clamping to the new maximum, keeps register_table_scales_tokens_to_the_new_cap passing. A test where a table in debt has its cap raised and the next write is allowed would hold it.
There was a problem hiding this comment.
Fixed in 7a41f53. update_rate now scales only a positive balance and clamps it to the new maximum. A debt keeps its token count and is repaid at the new rate. raising_or_removing_a_cap_repays_a_debt_at_the_new_rate in crates/core/src/throttle/cause_tests.rs puts a table capped at 1 write unit 292 units in debt. It then raises the cap to 10,000, or removes it, and expects a write 150 ms later to be allowed. It fails with the old update_rate. register_table_scales_tokens_to_the_new_cap passes with both.
I ran your sequence on local SQLite servers: one 300 KB PutItem, UpdateTable, then a write every 0.25 s.
| Build | Cap raised to 10,000 | Cap removed |
|---|---|---|
| fd9cf3a + main (b26c679) | first write accepted after 292.1 s, 1,149 refusals | 79 of 79 refused over 20 s |
| with 7a41f53 (2906a6a) | 1 refusal, then accepted at 0.26 s | 1 refusal, then accepted at 0.26 s |
| main a417b2f | accepted at 0.007 s | accepted at 0.006 s |
The one refusal is the write sent right after UpdateTable. The new rate repays 292 units in 29 ms at 10,000 units a second and in 73 ms at the 4,000 default.
| None, | ||
| Some(&operation), | ||
| ); | ||
| // The service names the throttled resource and the limit on a |
There was a problem hiding this comment.
Nothing reaches the branch that sends no reasons list: with the name check replaced by "always attach the ARN", all 524 server tests pass. Main's table name gate now refuses bad name! first, so the test kept for it expects ValidationException, and its name and the PR body still describe an account throttle. The check covers characters only, and the service refuses ab, an empty name and a 256-character name with ValidationException before any throttle. With the account bucket drained, this head attaches ThrottlingReasons to those three names. validate_table_name covers length and pattern.
There was a problem hiding this comment.
I measured the three names on DynamoDB in us-east-1, GetItem and PutItem, each request twice. ab and 256 characters get ValidationException with the length clause. An empty name gets 1 validation error detected: Value at 'TableName' failed to satisfy constraint: Member must have length greater than or equal to 1.
My first fix, 40ee656, refused these names with validate_table_name in the throttle segment. That runs before the engine reads the request. GetItem with ab and Key sent as a string gets SerializationException from DynamoDB and from main, and that refusal answered ValidationException.
781647d replaces it.
The throttle segment now skips a name that validate_table_name refuses, and the engine answers it as it does with capacity left. For an ARN of a table in this account and Region, the check reads the name the ARN carries. With the account bucket drained, a local server answered 12 requests on each build: the three names, GetItem and PutItem, each sent twice. All 12 got the answers in this table.
| Build | Answers |
|---|---|
| fd9cf3a + main (b26c679) | RequestLimitExceeded with ThrottlingReasons |
| 781647d | main's answers, no ThrottlingReasons |
GetItem still answers ResourceNotFoundException for these names, as main does. #1127 moves that length check ahead of the lookup (#1056).
Every throttle refusal now has a valid table name, so throttle_error takes the ARN as &str and the branch with no reasons list is gone. The kept test is now account_throttle_reason_names_the_table_of_an_arn. names_outside_the_table_name_rules_are_not_throttled sends ab, an empty name, 256 characters and another Region's ARN, first with capacity left and then drained, and expects the same answers. It fails without the skip.
PutItem with ab and Item sent as a string answers ValidationException on main and on this branch, where DynamoDB answers SerializationException. That order predates this PR, and #1479 has the measurements.
| /// Region, all carrying this text; the 104 index-write bodies of that run | ||
| /// carry a different message naming global secondary indexes, which the | ||
| /// server does not model). Trailing period. | ||
| pub const PROVISIONED_THROUGHPUT_EXCEEDED_MESSAGE: &str = "The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API."; |
There was a problem hiding this comment.
No test pins the three measured message texts. Dropping a trailing period, changing a word, and adding a period each leave all 1,147 core and 524 server tests passing.
There was a problem hiding this comment.
Fixed in d135fa3. With the merge of main, extenddb_core::error::error_document builds the error body, so the throttle body tests moved to core. They are now one table, throttle_error_documents_match_the_service in crates/core/src/error/throttle_tests.rs. It writes the three measured messages out as literals and compares each whole document by equality. Three mutants each fail it. The first drops the trailing period of the provisioned message. The second changes shortly to soon in the hot-key message, and the third adds a period to the caps message.
| MAX_ON_DEMAND_THROUGHPUT_MESSAGE, | ||
| reason("MaxOnDemandThroughputExceeded"), | ||
| ), | ||
| ThrottleCause::Table { |
There was a problem hiding this comment.
Optional. An on-demand table that runs out of its default 12,000 read or 4,000 write units gets AccountLimitExceeded. The API Reference uses that name for the per-table account quota, 40,000 units in ExtendDB's own limits page. Not measured on the service.
There was a problem hiding this comment.
I kept AccountLimitExceeded. The API Reference defines it for an on-demand table whose request rate made it "exceed the per-table account-level service quotas for read/write throughput". The default per-table quota is 40,000 request units each way. The 12,000 and 4,000 are what a new table sustains before it scales. The on-demand guide says: "New on-demand tables will be able to sustain up to 4,000 writes per second and 12,000 reads per second".
ExtendDB never scales a table, so its ceiling is the per-table limit it enforces, and docs/dynamodb-limits.md lists 12,000 and 4,000 in the two per-table on-demand rows. Of the other documented limit types, MaxOnDemandThroughputExceeded names a configured maximum, KeyRangeThroughputExceeded one partition key value, and ProvisionedThroughputExceeded provisioned mode. The reason the service sends for a new table past 4,000 writes a second is not measured.
Sources:
| | On-demand capacity | Automatic scaling | Fixed initial burst capacity (4000 WCU / 12000 RCU), no auto-scaling; a table with `OnDemandThroughput` caps is sized by the caps, per direction; the bucket starts with one second of the rate and accumulates unused capacity up to 300 seconds of it | | ||
| | Warm throughput | Pre-provisions partitions to the requested read and write units; raising it is a long-running operation (`Status: UPDATING` for minutes, the previous values reported meanwhile); a request above the account's table maximum is `LimitExceededException` | Stored and reported with the same shape, defaults and validation so clients that read it (the Terraform AWS provider since 6.13.0) work: the previous values are reported with `Status: UPDATING` for `control_plane_delay_seconds` after a change, then the new values `ACTIVE`; a decrease is measured against the reported values, as on the service. Nothing acts on the values: no pre-warming and no scaling at the database level. The account maximum is not known to ExtendDB and is not enforced. A provisioned table whose warm throughput was never set, or was set on one side only, reports its new units at once after a capacity change, where the service reports the old units until the table is `ACTIVE`. Switching a table to `PAY_PER_REQUEST` stores 12000 read and 4000 write units where its warm throughput is lower, and the stored values stay after a switch back to `PROVISIONED`, as on the service; the response to the switch reads the new values with `Status: UPDATING` for `control_plane_delay_seconds`, where the service answers with the previous values and `Status: ACTIVE` | | ||
| | Throttling | Always on; throttles requests that exceed provisioned/burst capacity. No setting to disable | Configurable via `throttling_enabled` runtime setting (default: `true`) | | ||
| | Throttle error bodies | A throttle names the throttled resource and the limit. A provisioned table's own capacity is `ProvisionedThroughputExceededException` with `ThrottlingReasons: [{reason: Table{Read\|Write}ProvisionedThroughputExceeded, resource: <table ARN>}]` on every read and write operation; a hot key on an on-demand table is `ThrottlingException` in the `com.amazon.coral.availability#` namespace with `throttlingReasons` (lower t) naming `TableWriteKeyRangeThroughputExceeded` on a write and no reasons list on a read; an on-demand table at its `OnDemandThroughput` caps is `ThrottlingException` with the message `Throughput exceeds the maximum OnDemandThroughput configured on table or index` and `Table{Read\|Write}MaxOnDemandThroughputExceeded`. Measured 2026-10-20 (435 bodies, one Region) and 2026-10-24 (9,622 bodies, two Regions). No `x-amz-retry-after` header | The same classes, namespaces, messages, field names and reasons for the table, hot-key and caps buckets. The account aggregate bucket sends `RequestLimitExceeded` with `Table{Read\|Write}AccountLimitExceeded`, and an on-demand table past its default ceiling sends `ThrottlingException` with the same reason: both follow the API Reference and were not produced by the measurements. A hot key on a provisioned table names `Table{Read\|Write}KeyRangeThroughputExceeded` with the provisioned class and message; the write form was captured once on 2026-10-20, the read form follows the documented grammar | |
There was a problem hiding this comment.
Optional. The row says the bodies match on every read and write operation. On a capped table, BatchWriteItem, BatchGetItem and TransactWriteItems answer 200, because the throttle keys on a top-level TableName. The service throttles all three, and TransactGetItems, with ProvisionedThroughputExceededException and ThrottlingReasons.
There was a problem hiding this comment.
2906a6a changes the row. The throttle covers GetItem, PutItem, UpdateItem, DeleteItem, Query and Scan, the operations whose request names one table in TableName. BatchGetItem, BatchWriteItem, TransactGetItems, TransactWriteItems and the PartiQL operations are not throttled.
Main throttles none of the four either. On local servers I gave a provisioned table 1 read and 1 write unit. A 100 KB PutItem and a strongly consistent GetItem of that item drained both buckets. Then PutItem and GetItem got ProvisionedThroughputExceededException, and the four operations answered 200, on main and on this branch, twice each. On a table capped at 1 and 1 the four answered 200 too. I filed #1478 with those answers and the requests that would measure the service's.
| .await; | ||
| // The first write consumes the burst; the manager is drained directly | ||
| // rather than by many writes so the test does not depend on timing. | ||
| state.throttle.consume(&account_id, table, 0.0, 2.0); |
There was a problem hiding this comment.
Optional. These drains leave the bucket at about -1 second of rate, so one second of scheduler delay turns a refusal into a 200. Draining by 1e9, as the account test does, removes the timing.
There was a problem hiding this comment.
Fixed in 8cdea49. The wire tests and the cause tests now drain by 1e9. The on-demand hot-key tests cannot drain that far through the table without emptying the table bucket too. They drain the partition bucket while the table is not registered, and the request registers the table again from DescribeTable, as after a restart. register_table_scales_tokens_to_the_new_cap keeps its write of 1.5 units, because that write measures the scaled balance of one token.
Main now builds the error body in core (extenddb_core::error::error_document), and the server's error_response calls it. The throttle reasons member that this branch added to error_response moves into error_document, after CancellationReasons and before Item. The server and the WebAssembly adapter then send the same throttle body.
Main builds the error body in extenddb_core::error::error_document, so the throttle body tests move from the server's error_response to core. They are now one table of errors and the documents they produce. The table writes out the three measured messages, so a change to PROVISIONED_THROUGHPUT_EXCEEDED_MESSAGE, THROTTLING_EXCEPTION_MESSAGE or MAX_ON_DEMAND_THROUGHPUT_MESSAGE fails it. Each earlier test compared a body with the constant that built it.
update_rate scaled a negative balance by the ratio of the rates, so a debt kept its length in seconds. A table capped at 1 write unit took a 293-unit write. It then stayed refused for 292 s after UpdateTable raised the cap to 10,000, and for as long after the cap was removed. A positive balance is still scaled to the new burst window and clamped to its maximum. A debt now keeps its token count and is repaid at the new rate.
The throttle segment checked only the characters of the table name, and the table name gate refuses every name outside the pattern before it. A name of a bad length (empty, 2 or 256 characters) and the ARN of a table in another Region reached the throttle. With the account bucket drained, they got RequestLimitExceeded with a ThrottlingReasons list. The service answers ValidationException to each of them, whatever the capacity. validate_table_name now refuses them before any bucket is read. The refusal records the request count and the user error, as the engine's refusal of the same names did. GetItem with such a name now answers ValidationException where it answered ResourceNotFoundException. Every throttle refusal now has a valid table name. So throttle_error always names the table ARN, and the branch that sent no reasons list is gone.
The throttle tests drained a bucket to about one second of its rate below zero. A delay of one second between the drain and the request turned the refusal into a 200. The tests now drain by 1e9, as the account test does. The on-demand hot-key tests drain the partition bucket while the table is not registered. The table bucket is then full when the request registers the table again.
The differences row for the throttle bodies did not say which operations the throttle covers, and read as every read and write operation. The throttle keys on the request's top-level TableName, so it covers GetItem, PutItem, UpdateItem, DeleteItem, Query and Scan. BatchGetItem, BatchWriteItem, TransactGetItems, TransactWriteItems and the PartiQL operations are not throttled.
The previous commit refused such a name with ValidationException in the throttle segment, before the engine reads the request. DynamoDB answers a member of the wrong JSON type first. GetItem with TableName "ab" and Key sent as a string gets SerializationException from DynamoDB and from main, and the refusal answered ValidationException. The throttle segment now skips a name that validate_table_name refuses. An ARN of a table in this account and Region is checked by the name it carries. The engine then answers these names with throttling on as it does with throttling off, and the throttle adds no class and no reasons list. The refusal and its metric recording are removed. GetItem with "ab" answers ResourceNotFoundException again, as on main. The length check before the lookup belongs in the engine handlers.
The namespace test checked the three `__type` values that the error document table now writes in full, and the TransactionCanceledException row checked a document that `error_document_includes_cancellation_reasons` pins. Both go. The core tests share one ARN constant. The name test drops `bad name!`, which the table name gate refuses before the throttle segment. It also drops the reasons check: the equality with the answer given with capacity left covers it.
|
I merged main at a417b2f (b26c679). Since #1009, core's
This round leaves 532-1 and 532-2 as they are. Settling them needs throttled traffic on live tables, which I have not run. |
demohan
left a comment
There was a problem hiding this comment.
At fa154a2 a debt is repaid at the new rate after a cap is raised or removed, the names outside the table name rules reach the engine, and the test items are done; the rule I suggested for the debt holds a table when its rate goes down, and the hot-key and cap items are as they were.
- A table capped at 1 write unit and 292 units in debt is refused once after its cap is raised, then accepts at 0.26 s, on SQLite and PostgreSQL; removing the new guard fails
raising_or_removing_a_cap_repays_a_debt_at_the_new_rate. With the account bucket drained,ab, an empty name, 256 characters, an eu-west-1 ARN andbad name!get the answers they get with capacity left, as the service gives, and removing the skip or forming the resource from the rawTableNamefails a test. The three messages are compared whole, the drains are1e9, and the dropped tests are covered elsewhere. Provisioned throttle bodies match the service for six operations, fmt, clippy and the 1.91.1 check are clean, core (1176) and server (533) tests pass, and CI is green on 65 of 65. - GetItem on a hot key of an on-demand table still carries no reasons list. On the service in us-east-1, 200 of 200 GetItem refusals carry
TableReadKeyRangeThroughputExceededwith the table ARN and 110 of 110 Query refusals carry none; here 356 of 356 GetItem refusals on SQLite and 231 of 231 on PostgreSQL carry none, so the "5,615 of 5,615" in the body and inerror/mod.rs:183does not hold for GetItem. on_demand_cappedstill enforces the cap exactly. With a cap of 100 and 8 threads for 8 s the service and main served every PutItem (6,656 and 6,405 on the service, 6,650 on main) and this head 903 and 901; with a cap of 1 the service served 678 and 803 and this head 9 to 12.
I will approve once the debt rule holds when the rate goes down, and the hot-key read reasons and the cap follow the service.
| // (the balance below zero that an operation larger than the | ||
| // balance leaves) keeps its token count and is repaid at the new | ||
| // rate. | ||
| if self.tokens > 0.0 { |
There was a problem hiding this comment.
This keeps a debt's token count when the rate goes down too, which is the rule my earlier comment suggested and it is wrong in that direction. A provisioned table at WCU 100, one 300 KB PutItem, UpdateTable to WCU 1, then a 1 KB PutItem every 0.25 s: the service refused 0 of 98 in both runs, main 76 of 99 with the first write accepted at 2.0 s, and this head 99 of 99 over 25 s on SQLite and PostgreSQL, with the first write accepted at 199.8 s in a 240 s run. Keeping the count when the rate rises and scaling the debt when it falls would hold both directions, with a row for a lowered rate beside raising_or_removing_a_cap_repays_a_debt_at_the_new_rate.
| | On-demand capacity | Automatic scaling | Fixed initial burst capacity (4000 WCU / 12000 RCU), no auto-scaling; a table with `OnDemandThroughput` caps is sized by the caps, per direction; the bucket starts with one second of the rate and accumulates unused capacity up to 300 seconds of it | | ||
| | Warm throughput | Pre-provisions partitions to the requested read and write units; raising it is a long-running operation (`Status: UPDATING` for minutes, the previous values reported meanwhile); a request above the account's table maximum is `LimitExceededException` | Stored and reported with the same shape, defaults and validation so clients that read it (the Terraform AWS provider since 6.13.0) work: the previous values are reported with `Status: UPDATING` for `control_plane_delay_seconds` after a change, then the new values `ACTIVE`; a decrease is measured against the reported values, as on the service. Nothing acts on the values: no pre-warming and no scaling at the database level. The account maximum is not known to ExtendDB and is not enforced. A provisioned table whose warm throughput was never set, or was set on one side only, reports its new units at once after a capacity change, where the service reports the old units until the table is `ACTIVE`. Switching a table to `PAY_PER_REQUEST` stores 12000 read and 4000 write units where its warm throughput is lower, and the stored values stay after a switch back to `PROVISIONED`, as on the service; the response to the switch reads the new values with `Status: UPDATING` for `control_plane_delay_seconds`, where the service answers with the previous values and `Status: ACTIVE` | | ||
| | Throttling | Always on; throttles requests that exceed provisioned/burst capacity. No setting to disable | Configurable via `throttling_enabled` runtime setting (default: `true`) | | ||
| | Throttle error bodies | A throttle names the throttled resource and the limit. A provisioned table's own capacity is `ProvisionedThroughputExceededException` with `ThrottlingReasons: [{reason: Table{Read\|Write}ProvisionedThroughputExceeded, resource: <table ARN>}]` on every read and write operation; a hot key on an on-demand table is `ThrottlingException` in the `com.amazon.coral.availability#` namespace with `throttlingReasons` (lower t) naming `TableWriteKeyRangeThroughputExceeded` on a write and no reasons list on a read; an on-demand table at its `OnDemandThroughput` caps is `ThrottlingException` with the message `Throughput exceeds the maximum OnDemandThroughput configured on table or index` and `Table{Read\|Write}MaxOnDemandThroughputExceeded`. Measured 2026-10-20 (435 bodies, one Region) and 2026-10-24 (9,622 bodies, two Regions). No `x-amz-retry-after` header | The throttle covers GetItem, PutItem, UpdateItem, DeleteItem, Query and Scan, the operations whose request names one table in `TableName`, and sends the same classes, namespaces, messages, field names and reasons for the table, hot-key and caps buckets. BatchGetItem, BatchWriteItem, TransactGetItems, TransactWriteItems and the PartiQL operations are not throttled. The account aggregate bucket sends `RequestLimitExceeded` with `Table{Read\|Write}AccountLimitExceeded`, and an on-demand table past its default ceiling sends `ThrottlingException` with the same reason: both follow the API Reference and were not produced by the measurements. A hot key on a provisioned table names `Table{Read\|Write}KeyRangeThroughputExceeded` with the provisioned class and message; the write form was captured once on 2026-10-20, the read form follows the documented grammar | |
There was a problem hiding this comment.
Optional. SearchVectors also names one table in a top-level TableName and is not throttled, so "the operations whose request names one table in TableName" covers it and the not-throttled list leaves it out.
What
Amazon DynamoDB names the throttled resource and the limit on a throttle error: a reasons list with one
{reason, resource}entry. In it,reasonisResourceType + OperationType + LimitType, andresourceis the table or index ARN. ExtendDB's three throttle errors carried a message string only. The server's own throttle refusal sent one fixed provisioned-capacity body for every bucket and billing mode.The three throttle variants of
DynamoDbError(ProvisionedThroughputExceededException,ThrottlingException,RequestLimitExceeded) become struct variants with amessageand areasonslist, built throughprovisioned_throughput_exceeded,throttlingandrequest_limit_exceededand read throughthrottling_reasonsandis_throttle.extenddb_core::error::error_document, which builds every error body, renders the list asThrottlingReasonson the first and third and asthrottlingReasonsonThrottlingException, and omits it when empty.ThrottlingExceptionmoves to thecom.amazon.coral.availability#namespace. Message constants carry the measured texts for a table's own capacity, a hot key and theOnDemandThroughputcaps, and the documented text for the account quota.The throttle manager reports which bucket refused (the table, the partition key or the account aggregate), with the table's billing mode. An on-demand table whose
OnDemandThroughputcaps are set is sized by the caps, per direction. A table capped on writes only keeps the default read ceiling, and it reports the caps limit on a write refusal alone. As with every bucket, it starts with one second of its rate and accumulates unused capacity up to 300 seconds of it. When a table's rate changes, a positive balance keeps its share of the burst window. A debt keeps its token count, and the new rate repays it. The server maps that cause onto the body the service sends:ProvisionedThroughputExceededExceptionThrottlingReasonsTable{Read|Write}ProvisionedThroughputExceededThrottlingExceptionthrottlingReasonsTableWriteKeyRangeThroughputExceededThrottlingExceptionThrottlingExceptionthrottlingReasonsTable{Read|Write}MaxOnDemandThroughputExceededProvisionedThroughputExceededExceptionThrottlingReasonsTable{Read|Write}KeyRangeThroughputExceededThrottlingExceptionthrottlingReasonsTable{Read|Write}AccountLimitExceededRequestLimitExceededThrottlingReasonsTable{Read|Write}AccountLimitExceededThe resource is the table ARN
DescribeTablereturns. The account bucket can refuse before the engine reads the name. For an ARN-formTableNameof a table in this account and Region, the server forms the resource from the bare name. The throttle skips a name thatvalidate_table_namerefuses: empty, shorter than 3 or longer than 255 characters, or outside the pattern. It also skips the ARN of a table in another Region. The engine answers those as it does with capacity left, and the throttle adds no class and no reasons list. The buckets are per table and per partition key. There is no per-index capacity. So theIndexreason forms, which the service sends for an under-provisioned global secondary index, are not modelled. The differences doc says so.Why
A client that reads
ThrottlingReasons(the SDKs expose it on the parsed exception) learns which resource and which limit to act on. Against ExtendDB that member was absent on every throttle. TheThrottlingExceptionnamespace also differed from the service's. The server also sent the provisioned-capacity message for an on-demand table's hot key and for the account aggregate, which name different limits on the service.I measured the service on 2026-10-20 (435 bodies, one Region) and on 2026-10-24 (9,622 bodies in us-east-1 and eu-west-1). The 2026-10-24 run used boto3 with retries off and captured raw bodies from the response hook. The measurements cover:
OnDemandThroughputcaps (52 reads, 48 writes)No response carried
x-amz-retry-after. Every reasons list present carried exactly one entry.Testing done
In the core crate, the three classes keep their status and type name, carry their reasons through the accessor and answer
is_throttle. The reason entry serializes with the two lower-case field names. One table test oferror_documentcovers the document of each class, with the three measured messages written out. Each row writes the full__type, so the table also holds that onlyThrottlingExceptionmoves to the availability namespace. Its rows also cover the empty list omitted under both spellings, the caps body and the documentedRequestLimitExceededcasing.The throttle manager tests cover the cause and billing mode for the table, partition and account buckets. They also cover a capped table sized by its caps, with absent and negative caps keeping the default ceiling. A half-capped table reports its cap for its direction only. Re-registration moves the mode and scales a positive balance to the new rate. Another test puts a table in debt and raises or removes its cap: the throttle allows a write 150 ms later.
The server tests cover every arm of the cause mapping in both directions. They also cover the throughput extraction for provisioned, on-demand and capped descriptions on both registration paths. One path reads the response body. The lazy path reads the typed description after a restart. Eight in-process tests run through
handle_requestagainst an in-memory SQLite engine. Between them they send a provisioned write and read, an on-demand hot-key write and read, and a capped table'sQueryandPutItem. They also send a half-capped table's write and read, an account refusal of an ARN-form name, and a served request.The names test sends four names outside the table name rules, first with capacity left and then with the account bucket drained. It compares the answers. The tests drain a bucket by 1e9 units, so a delay before the request does not refill it. The SQLite storage crate becomes a dev-dependency of the server crate for those.
Negative controls ran on a clean committed tree, and I restored each one after. Each of these fails the test named after it:
ThrottlingExceptionback to the dynamodb namespace: the core document tableshortlychanged tosoonin the hot-key message, or a period added to the caps message: the core document tableTableNameto the resource, or checking it in place of the name an ARN carries: the account-arm wire testFive
backup_storetests of the server crate fail on the test host because another user owns its/tmp. They fail the same way on every branch there, and CI runs them.Changes since the 24 November review
error_documentsince feat(wasm): [Add WebAssembly browser support for ExtendDB #1009, so the throttle reasons member moved there from the server'serror_response.throttle_errortakes the table ARN as&str, and the branch with no reasons list is gone.bad name!row of the names test, which the table name gate refuses first. It changes test modules only.Itemtype).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 and adds no option; the Rust shape change is stated under Breaking changes and follows RFC-0002's release model (a 0.x minor).
Breaking changes
On the wire, throttle bodies gain the reasons member and
ThrottlingExceptionchanges its__typeprefix; both match the service, and botocore, the Java v2, Go v2, Rust and JavaScript v3 SDKs classify a throttle by the name after#, so no retry decision changes. For Rust code outside this workspace, the three throttle variants change from tuple to struct variants on the#[non_exhaustive]DynamoDbError(construct throughprovisioned_throughput_exceeded,throttling,request_limit_exceeded; read throughthrottling_reasons,is_throttle,message);ThrottleResult::ThrottledReadandThrottledWritecarry aThrottleCause(read throughcause());TableThroughputgainsread_cappedandwrite_capped(build throughprovisioned,on_demand,on_demand_capped). No in-tree crate outside the changed files names any of them. The change lands in the next 0.x minor under RFC-0002's release model.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.