Skip to content

feat: per-index throttle buckets for provisioned global secondary indexes - #587

Open
LeeroyHannigan wants to merge 15 commits into
feat/console-tabsfrom
feat/index-throttle
Open

LeeroyHannigan wants to merge 15 commits into
feat/console-tabsfrom
feat/index-throttle

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

What

A provisioned global secondary index has its own read and write capacity on the service. The server's token buckets were per table, per partition key and per account. So the server never refused an index past its capacity, and a refusal never named an index. This change gives each provisioned global secondary index a read bucket and a write bucket in ThrottleManager. It also sends the two bodies the service sends.

ThrottleManager::register_indexes replaces a table's index set from its description. A kept index keeps its balance and takes the new rate. A new index starts with one second of its rate, as a new table does. A dropped index loses its buckets, and remove_table drops them with the table. The set keeps DescribeTable order.

The manager checks a Query or Scan that names a registered index against the index's read bucket, in place of the table's, and charges that bucket. It still checks the read against the partition and account buckets, and charges them. For a write, it checks the table's write bucket and then each index's write bucket in order. The first bucket that is empty refuses it.

The manager charges a served write to the table and to each index whose key attributes its old or new item carries. PutItem, UpdateItem and DeleteItem report those index write units (DispatchMetrics::index_write_units), counted as ConsumedCapacity counts the index arms. The service charges an index the same way.

A local secondary index, or a name no registered index has, reads from the table's buckets as before. An on-demand table's indexes get no buckets. An index described with 0 in both directions gets none either. That description is the placeholder a backend describes for an index created on a provisioned table without throughput.

The server registers the indexes with the table from the CreateTable, UpdateTable and DescribeTable responses, and on the first request after a restart. It reads IndexName from a Query or Scan. On an index refusal it sends ProvisionedThroughputExceededException with the index ARN as the resource. The body for a read carries IndexReadProvisionedThroughputExceeded with the table message. The body for a write carries IndexWriteProvisionedThroughputExceeded with the index message, which has no trailing period.

ReadThrottleEvents and WriteThrottleEvents carry the refusing index as their index dimension. An index write refusal also records WriteThrottleEvents for the table, and ThrottledRequests carries no index, as the service publishes those metrics. Each record also carries the account, as every metric of the server does. Its table dimension is the metric table name, which reduces a table ARN to the name. BatchWriteItem and TransactWriteItems carry no top-level TableName, and the server's throttle segment does not check them, as before.

An UpdateTable whose GlobalSecondaryIndexUpdates Update carries ProvisionedThroughput changes the index's throughput. The table must be PROVISIONED before and after the request. The index write message names this request as the action to take. Each backend writes the units to the index's stored throughput, and the response and DescribeTable show them. The index buckets take the new rate from the response.

The engine checks the units before it reads the table, with the clauses measured against Amazon DynamoDB on 2026-11-25. After the read, it answers an Update that names no index of the table with ResourceNotFoundException, before any backend write. The service applies the new rate a few seconds after the request. Here it applies with the response.

ThrottleCause gains Index { index_name } and is Clone rather than Copy. ThrottleResult::cause returns a borrow. The enum is public and stays exhaustive, since the server matches every cause to pick the wire body. A match on it outside this workspace gains an arm, and a copy becomes a clone.

The first commit is a pure move, so the files the feature grows stay under 600 lines. It moves TokenBucket and its tests to throttle/bucket.rs, the manager tests to throttle/manager_tests.rs, and the handler's throttle segment to handler/throttle_segment.rs.

Why

Measured against Amazon DynamoDB on 2026-10-24 and 2026-10-25:

  • 648 index reads (451 Query, 197 Scan) refused with IndexReadProvisionedThroughputExceeded, the index ARN and the table message.
  • 104 BatchWriteItem and 5,876 PutItem, UpdateItem and single-item TransactWriteItems refused with IndexWriteProvisionedThroughputExceeded, the index ARN and the message The level of configured provisioned throughput for one or more global secondary indexes of the table was exceeded. Consider increasing your provisioning level for the under-provisioned global secondary indexes with the UpdateTable API.

A client that retries on the index reason gets the service's shape from the emulator. So does an operator who sizes an index from its throttle metrics.

Two behaviours are not modelled, and the differences table states them. The GSI definition has no OnDemandThroughput member, so the on-demand index caps (IndexReadMaxOnDemandThroughputExceeded) are not modelled. The server extracts no partition value for Query or Scan, so the hot index key is not modelled either.

Refs #716. This PR serves one of the index Update actions that #716 lists: ProvisionedThroughput on a table that stays PROVISIONED. The others are still refused. #1518 tracks the check order of that Update beside BillingMode PAY_PER_REQUEST.

Stacking

This branch builds on #557, which stacks on #549, #547, #536, #532 and #529. The change under review is the three commits this branch had on top of #557: the move, the feature with its tests, and the documentation. After them come the merges of #557's current head and the follow-ups below. Once #557 is on main this PR rebases onto main.

Other open PRs

#1442 (eliseong, opened 24 November) adds provisioned_below_minimum_error, which builds the same two below-1 clauses as validate_update_throughput. #1442 uses it for CreateTable and for the table's own UpdateTable throughput. validate_update_throughput builds those clauses in one place. Whichever of this PR and #1442 merges second makes it call provisioned_below_minimum_error for them. The null clauses stay here, because the helper of #1442 takes the typed ProvisionedThroughput struct.

After #1167 lands, the fields of ProvisionedThroughput go through deserialize_capacity_units. The as_i64() path of validate_update_throughput then needs the same reading of a non-integer figure, such as 1.5. Whichever of this PR and #1167 merges second aligns them.

Merge of #557's head

2e20ffbb0 merges #557 at 750c38f79, which carries #549, #547, #536 and main at 95425f5e8. Two files conflicted. In crates/server/src/handler.rs, main changed the throttle segment that this branch moves to handler/throttle_segment.rs. The merge keeps the call to throttle_segment::check, passes it main's metric table name, and drops main's inline copy, so the segment exists once. docs/differences-from-dynamodb.md keeps #536's partial batch row beside this branch's index row.

The follow-up commits:

Changes since the 24 November review

Testing done

Thirteen manager tests in throttle/index_tests.rs:

  • The index refuses an index read while the table's read bucket is full, and the charge goes to the index. The read does not consult the table's read bucket.
  • An unregistered name reads from the table.
  • The first exhausted index in order refuses a write, after the table's bucket allowed.
  • The table bucket refuses first when both are empty.
  • A write charges only the indexes it names.
  • The manager checks an index read against the account bucket and the partition bucket, and charges them.
  • register_indexes replaces the set, and a kept index keeps its balance and takes the new rate.
  • remove_table drops the index buckets.
  • A disabled manager allows and charges nothing.
  • Only an Index cause names an index.

Four helper tests:

  • The typed and the response-body descriptions give the provisioned indexes in order. They skip an index without throughput, one at 0/0, and every index of an on-demand table.
  • The server reads IndexName from Query and Scan only.
  • The Index cause maps to the two measured bodies.

Nine wire tests through handle_request against the in-memory engine:

  • The index read body, with the resource equal to DescribeTable's IndexArn, and the metric records it leaves.
  • The index write body on PutItem, UpdateItem and DeleteItem with the table at 1000 WCU, and the three records of each refusal.
  • A write charged to the index only when its item carries the index key.
  • UpdateTable raising the index's throughput ends its refusals.
  • A local secondary index refused with the table body.
  • UpdateTable deleting the index ends its refusals.
  • An UpdateTable changing only the table's throughput keeps the index buckets.
  • An index read served while the table's read bucket is drained.
  • The first request after a dropped registration registers the indexes again.

Eleven negative controls ran, each on a clean committed tree and restored after. Each failed the tests named for it:

  • The table's read bucket checked on an index read.
  • The index write buckets skipped on a write.
  • The table cause returned on an index refusal.
  • The resource built as the table ARN.
  • A trailing period on the index write message.
  • register_indexes appending instead of replacing.
  • remove_table keeping the index buckets.
  • An index read that passes its bucket skipping the table, partition and account checks.
  • An index read charged to the index only.
  • The lazy path registering no indexes.
  • The throttle event recorded without the index dimension.
cargo +1.97.0 fmt --all -- --check
cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine -p extenddb-server -p extenddb-storage-sqlite -p extenddb-storage-postgres -p extenddb-storage-mongodb -p extenddb-storage-cassandra --all-targets -- -D warnings
cargo +1.97.0 test --no-fail-fast -p extenddb-core -p extenddb-engine -p extenddb-server -p extenddb-storage-sqlite -p extenddb-storage-postgres -p extenddb-storage-mongodb -p extenddb-storage-cassandra --lib
cargo +1.97.0 test -p extenddb-engine --test batch_partial
cargo +1.97.0 test --locked -p extenddb-wasm-adapter
cargo +1.97.0 check --locked -p extenddb-engine --no-default-features --lib
cargo +1.91.1 check -p extenddb-core -p extenddb-engine -p extenddb-server -p extenddb-storage-sqlite -p extenddb-storage-postgres -p extenddb-storage-mongodb -p extenddb-storage-cassandra --all-targets

At 854a414, the lib runs pass 1189 core tests (one skipped, the golden fixture writer), 904 engine and 581 server tests. They also pass 327 SQLite (one skipped), 87 PostgreSQL, 190 MongoDB (84 skipped without a server) and 191 Cassandra tests. On the build host only, 5 server tests and 2 SQLite tests fail: the backup_store tests and backup_catalog::write_lock_tests. Another user owns a directory above their backup root. In the full parallel run one engine restore test timed out (a_stopped_heartbeat_timer_stops_the_restore_before_its_next_write). It passed alone 3 times.

batch_partial passes 18 tests, and the WebAssembly adapter its 3 tests and the corpus. tests/python/test_warm_throughput_updates.py passes 20 tests against a local server on SQLite, PostgreSQL, MongoDB and Cassandra each. With a backend's index throughput write removed, its storage test fails: the SQLite unit test, and the Python case on PostgreSQL, MongoDB and Cassandra.

At a093592, the lib runs pass 1189 core, 906 engine and 581 server tests. They also pass 327 SQLite, 87 PostgreSQL, 190 MongoDB and 191 Cassandra tests, with the same skipped tests. On the build host the same 5 server and 2 SQLite tests fail. The Python file passes 21 tests on SQLite and on MongoDB. One of them sends a new table throughput beside an Update of a missing index. With the engine's index check removed, that case fails on MongoDB, because the table takes the new throughput.

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace --lib; the integration suites run in CI)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy --all-targets -- -D warnings)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, 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 bodies are the service's measured bodies on an error path the server already sends. The backends write an index's existing throughput field. There is no Storage trait, auth, on-disk format or CLI change.

Breaking changes

extenddb_core::throttle::ThrottleCause gains the Index { index_name: String } variant and no longer implements Copy. ThrottleResult no longer implements Copy. ThrottleResult::cause returns Option<&ThrottleCause>. check_capacity_with_partition and consume_with_partition take an index_name: Option<&str> last parameter. check_capacity and consume do not change. Code outside this workspace that matches the enum exhaustively, copies it, or calls the two _with_partition methods changes.

extenddb_engine::DispatchMetrics gains the public field index_write_units, so a struct literal outside this workspace that names every field gains it.


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.

… into their own files

Pure moves with no behaviour change, so that the per-index throttle change after this commit keeps every file it grows under 600 lines.

crates/core/src/throttle.rs goes from 669 to 468 lines. TokenBucket, BURST_SECONDS and the four bucket tests move to throttle/bucket.rs; the struct and the four methods the manager calls become pub(super). The seven manager tests move to throttle/manager_tests.rs, one indent level shallower.

crates/server/src/handler.rs goes from 581 to 522 lines. The throttle segment of serve_request (lazy registration, the capacity check, the two throttle metrics and the refusal) moves to handler/throttle_segment.rs as check(state, ctx, operation, table_name, partition_value). serve_request extracts the partition value where it did before and passes it in, and the segment returns the same Refused. The moved text changes only where a parameter changed type: tn is a &str, so the DescribeTable input takes tn.to_owned(), and partition_value is already an Option<&str>.
…secondary indexes

A provisioned global secondary index has its own read and write capacity.
The service refuses a Query or Scan that names the index when the index's
read capacity is exhausted, with the table message and
IndexReadProvisionedThroughputExceeded naming the index ARN, and refuses a
base-table write held back by an index's write capacity with its own
message and IndexWriteProvisionedThroughputExceeded (measured against
Amazon DynamoDB on 2026-10-24 and 2026-10-25: 648 index reads, 104
BatchWriteItem and 5,876 PutItem, UpdateItem and single-item
TransactWriteItems).

ThrottleManager keeps a bucket pair per registered index, keyed by the
table and ordered as DescribeTable lists them. register_indexes replaces
the set: a kept index keeps its balance and takes the new rate, a new one
starts with one second of its rate, a dropped one loses its buckets;
remove_table drops them. A read naming a registered index is checked
against and charged to the index's read bucket in place of the table's,
and still against the partition and account buckets; a write is checked
against the table's write bucket and then each index's in order, and
charged to the table and every index. The index bucket logic lives in
throttle/index.rs; the manager holds the locks and the table lookup.

ThrottleCause gains Index { index_name } and is Clone rather than Copy;
ThrottleResult::cause returns a borrow. The enum is public and not
non_exhaustive: an exhaustive match on ThrottleCause outside this
workspace stops compiling until it adds the Index arm, and code that
copies a cause, or keeps the value cause() returned, has to clone it.

The server registers the indexes with the table from the CreateTable,
UpdateTable and DescribeTable responses and on the lazy registration
path, passes the IndexName of a Query or Scan through the check and the
consume call, and sends the index ARN as the resource. On an index
refusal the Read/WriteThrottleEvents record carries the index as its
index dimension and ThrottledRequests carries the table and operation
only, as the service publishes those metrics. An index described with
0/0 throughput (the placeholder for an index created on a provisioned
table without throughput) gets no buckets.
LeeroyHannigan added a commit that referenced this pull request Nov 3, 2026
The first commit sorts the body after authentication. Open pull
requests #587, #549 and #547 edit the lines around the end of the
authentication segment, so there the call conflicts with all three.
This commit moves it to immediately after the parse, where it merges
cleanly with the nine open pull requests that edit handler.rs.

On a preserve_order build an unauthenticated request now pays for the
sort, as it already pays for the parse. Without preserve_order the call
does nothing.

The comment now says which builds have preserve_order: any build that
compiles the MongoDB backend crate, which includes a build of the whole
workspace, not only the MongoDB binary.
crates/server/src/handler.rs keeps the move of the throttle segment into throttle_segment::check and the IndexName read from this branch. It keeps record_partial_batch_throttle from feat/console-tabs, and passes the metric table that feat/console-tabs computes to the moved segment.

docs/differences-from-dynamodb.md keeps the partial batch success row from feat/console-tabs and the per-index throttle row of this branch.
…etric table

feat/console-tabs brings three changes from main that the moved throttle segment and its tests did not build against. MetricsCollector::record takes the account since #955. Since #922 the throttle metrics use the metric table name. That name reduces an ARN to its table name and leaves out a name that fails the table name rules. GsiDescription has the warm_throughput and warm_throughput_record fields.

throttle_segment::check now takes the metric table and records ReadThrottleEvents, WriteThrottleEvents and ThrottledRequests under the account and that table, as the segment did before the move. The index dimension of the throttle events stays as this branch made it.

The index read wire test expects the account dimension that every record carries now. The GsiDescription of the helper tests sets both warm throughput fields to None.
The merge brings the new commits of #557 and of the PRs below it. #557 rewrites the admin page text and reads the tab identity from one identity_label call. #547 and #549 change tests, a comment and a guide sentence. No file conflicted.
The server design doc said that the server records ThrottledRequests per table and operation only. Since #955, every metric also carries the account. The sentence now says that ThrottledRequests carries no index dimension, as the service publishes it per table and operation.

@demohan demohan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The index read and index write bodies match the service: class, message, ThrottlingReasons and the index ARN, apart from the account and member order. Once a GSI's writes are exhausted, the service and this head refuse every single-item write to the table, including a delete of a missing key and a put whose condition would fail, and keep serving base-table reads and reads on other indexes. Measured on tables at 10/10 with each GSI at 1/1, three rounds each.

UpdateTable that adds or deletes an index registers or drops its buckets on all four backends, a restart registers them on the first request, and switching to PAY_PER_REQUEST drops them. No two of the four map locks are held at once, and 8 writers beside 20 concurrent UpdateTable calls gave no errors. Memory is about 134 bytes per index and 312 per table with indexes, and nothing grows over 1,000 re-registrations. Every negative control in the PR body fails as claimed. CI is green on 60 of 60 checks.

This branch is built on #532 and #557. I will approve once those land and the items below are done. The table name gate fix from #532 also needs to be applied at throttle_segment.rs:113, where this branch moved that block.

crates/engine/src/gsi_updates.rs:120

The refusal tells the client to raise the index with UpdateTable, and an UpdateTable GSI Update answers UpdateGlobalSecondaryIndex is not yet supported on all four backends. A GSI created at 1 WCU on a 1,000 WCU table refused 28 of 30 writes here; main served them all. The only ways out are deleting the index or switching billing modes. On the service, raising an exhausted index ends the refusals 1.9 and 3.4 s later, and 60 writes in a row are then served. The UpdateTable response still shows the old 1/1 there, so the new rate has to come from the request. The design doc and throttle.rs:280 say a kept index takes the new rate.

Comment thread crates/core/src/throttle/index.rs Outdated
/// bucket of the index `index_name` names when it is in `set`, `write_units`
/// to every index's write bucket. Returns whether a read was charged to an
/// index, in which case the table's read bucket is not charged.
pub(super) fn charge(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every write is charged to every index. Writing items that do not carry the GSI key, the service accepted 48 writes and then refused with the table body, and this head accepted 1 and then refused with the index body, three rounds each. Charging an index only for writes that carry its key matches the service. The differences page records the current behaviour, but the answers differ.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 92cfc50. The Developer Guide states the rule (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html#GSI.ThroughputConsiderations.Writes). It reads: "If a write to a table does not require a global secondary index update, no write capacity is consumed from the index." PutItem, UpdateItem and DeleteItem now report the write units of each global secondary index that the old or the new item projects into. They count them as ConsumedCapacity counts the index arms, and the server charges those indexes only. The check did not change: the server refuses a write while any index's bucket is empty. The test is a_write_is_charged_to_an_index_only_when_its_item_carries_the_index_key, on a table at 3 WCU with the index at 1 WCU. Without the index key, the server serves two 2 KB items and refuses the third with the table reason. With the key, it refuses the second write with the index reason. The differences page row says the same.

// Read/WriteThrottleEvents per table and per global secondary
// index; ThrottledRequests is published per table and operation
// only, so a count by table sees an index refusal too.
let refused_index = cause.index_name().map(str::to_owned);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When an index refuses a write, the service publishes WriteThrottleEvents for the table and for the index (138 and 162 in one minute, 40 and 40 in another). This head records only the index series. For index read refusals, the service publishes only the index series, which this head matches.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 92cfc50. When an index refuses a write, the segment now calls MetricsCollector::record a second time for WriteThrottleEvents, without the index dimension. An index read refusal still records the index series only. The CloudWatch metrics page (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/metrics-dimensions.html, WriteThrottleEvents) counts each event of a request on its own: "the table write, and each of the three index writes. For each event, the WriteThrottleEvents metric is incremented by one if that event is throttled". It also says that the TableName dimension returns the table's events and not the indexes'. It does not say that an index refusal counts for the table, so the rule comes from your two minutes of measurement. index_write_throttle_names_the_index_message_and_arn now asserts the nine records of its three refusals.

// account is reduced to the bare name first, and a name the
// engine would refuse gets no resource at all.
let name = crate::authz_resource::key_lookup_name(tn, &state.region, &ctx.account_id);
let resource_arn = extenddb_core::validation::validate_table_name_chars(&name)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the table's read capacity runs out, the service refuses a Query, a consistent Query or a Scan on an LSI with IndexReadProvisionedThroughputExceeded and the LSI's ARN (12 of 12). This head answers TableReadProvisionedThroughputExceeded with the table ARN (5 of 5), and index_throttle_wire_tests.rs:257 expects that body. Main answers the same, and the new index path is where the LSI ARN would go.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change in this round: settling it needs a live table, and I did not create one. At 854a414, lsi_read_throttle_is_the_table_body gets TableReadProvisionedThroughputExceeded with the table ARN for a Query naming the LSI on a drained 1 RCU table. Main (a417b2f, read from the code) sends the same class and message with no reasons list. These requests settle it: create a PROVISIONED table at 1/100 with an LSI, and drain its read capacity with base table Scans. Then send a Query, a consistent Query and a Scan naming the LSI, each twice, and read that minute's ReadThrottleEvents by table and by index. Your 12 of 12 named the LSI. If the live run answers the same, register_indexes would also take the table's LSI names, with no buckets of their own. A refusal by the table's read bucket on a read naming one would then carry the LSI ARN. That is about 25 production lines and one changed test row. If the service sends the table reason, nothing changes.

/// carrying this text with the reason
/// `IndexWriteProvisionedThroughputExceeded` and the index ARN. No trailing
/// period. An index read past its read capacity carries the table message.
pub const INDEX_WRITE_PROVISIONED_THROUGHPUT_EXCEEDED_MESSAGE: &str = "The level of configured provisioned throughput for one or more global secondary indexes of the table was exceeded. Consider increasing your provisioning level for the under-provisioned global secondary indexes with the UpdateTable API";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional. No test pins the text of the index write message. Changing "indexes" to "index" leaves every throttle test passing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in bdacbd7. The index write message is now the fourth row of throttle_error_documents_match_the_service in crates/core/src/error/throttle_tests.rs, the table that writes out the measured texts. With "indexes" changed to "index" in the constant, that test fails.

// depend on timing.
state
.throttle
.consume_with_partition(&account_id, table, 2.0, 0.0, None, Some(GSI));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional. Each drain of 2.0 against a rate-1 bucket leaves it at -1 token, so one second of scheduler delay turns a refusal into a 200. The comments at lines 138 and 166 say the test does not depend on timing and that the request count carries the table and operation only; it also carries AccountId.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 92cfc50. The index wire tests drain a bucket by DRAIN, 1,000 units. That is a debt of 999 seconds on a 1-unit bucket. A read drain also charges the account, and 1,000 is less than one second of its 80,000 units. The read test's comment no longer says the test does not depend on timing, and it names the account dimension of the request count.

A served write was charged to the write bucket of every provisioned global
secondary index of the table. The service charges an index only when the
write adds, changes or removes the item's entry in that index. The Amazon
DynamoDB Developer Guide (GSI.html#GSI.ThroughputConsiderations.Writes)
states the rule. It reads: "If a write to a table does not require a global
secondary index update, no write capacity is consumed from the index." For
example, a table had 3 WCU and its index had 1 WCU. A 2 KB item without
the index key drained the index on the first write. The second write was
then refused with the index body.

PutItem, UpdateItem and DeleteItem now report the write units of each
global secondary index that the old or the new item projects into. The
count is DispatchMetrics::index_write_units, from
capacity_helpers::index_write_units, which ConsumedCapacity uses too. On a
table with a global secondary index, these operations read the old item
for it. The server charges those units with the new
ThrottleManager::consume_index_writes, and consume_with_partition no
longer charges an index for a write. The check is unchanged: a write is
still refused while any index's write bucket is empty, as on the service.

An index write refusal now also records WriteThrottleEvents for the table,
beside the record with the index dimension. The service publishes both
series for such a refusal. An index read refusal still records the index
series only.

The index wire tests drain a bucket by 1,000 units in place of 2. On a
1-unit bucket that is a debt of 999 seconds, where 2 units left one second
of debt. The comment on the read refusal's request count names the
account dimension too.
The table of measured throttle documents wrote out three messages. The
index write message is now the fourth row, so a change to its constant
fails the test.
…Table

A write refused by an index names UpdateTable as the way to raise the
index. An UpdateTable with a GlobalSecondaryIndexUpdates Update that
carried ProvisionedThroughput answered "UpdateGlobalSecondaryIndex is not
yet supported" on every backend. So a client could end the refusals only by
deleting the index or by changing the billing mode.

On a table that is PROVISIONED before and after the request, such an
Update (with no OnDemandThroughput) is now applied. SQLite, PostgreSQL,
MongoDB and Cassandra each store the units in the index's throughput
field, in the shape that the backend's create path writes. Each answers
IndexNotFound for an Update that names no global secondary index of the
table. The UpdateTable response and DescribeTable then show the new units.
The server's index buckets take the new rate from that response, as they
do for an index that the update creates or deletes. An Update carrying
OnDemandThroughput on a provisioned table is still refused as not yet
supported. So is the index update of a switch to PROVISIONED.

The units are checked before the table is read. The answers are those of
Amazon DynamoDB on 2026-11-25, on a table name that does not exist. A
missing or null unit and a unit below 1 each give a clause at
globalSecondaryIndexUpdates.<n>.member.update.provisionedThroughput.<unit>,
write units first. UpdateGsiAction::provisioned_throughput_units reads the
units for the backends.

The service applies the new rate a few seconds after the request, and its
response still shows the old units. Here the response shows the new units,
and the rate applies with it. The differences page says so.

The new wire test of the index charge no longer binds the unused account.
An UpdateTable whose GlobalSecondaryIndexUpdates carried an Update with
ProvisionedThroughput for an index the table does not have reached the
backend. Each backend answered IndexNotFound. On MongoDB the table's own
members of the same request were written before that answer, so the
request failed and the table still changed.

The engine now looks up each such Update in the table it has read, before
any backend write. The lookup is the one the WarmThroughput path uses. It
moves into warm_throughput::gsi_named and keeps the same
ResourceNotFoundException text.

The backends keep their own checks for an index removed after the check
in the engine. A Cassandra UPDATE writes a row even when none exists, so
that backend still reads the index before its batch.

An engine test checks the text. A Python case sends a new table
throughput beside an Update of a missing index, and expects the table
unchanged. On MongoDB it fails without the check in the engine.
SQLite wrote the ProvisionedThroughputDescription literal of an index in
two places in update_table.rs. Both now call gsi_throughput_json. It sits
beside parse_gsi_throughput in table_helpers.rs and writes the shape that
parse_gsi_throughput reads.

MongoDB read the table document in two blocks of update_table. One block
clears the index throughput on a switch to PAY_PER_REQUEST. The other
stores the units of an index Update. One read now serves both blocks.
charge_read is now one expression.

The two index throttle wire tests built their metric dimensions with two
pairs of closures, and one module-level dims function now serves both.

Each Python row of the unit check on an index Update lists one tuple per
clause. Before, it was a flat list.

A manager test comment now says that the test itself charges each index
two units.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

The table name gate is in throttle_segment.rs now. The merge of #557's head (521b582) moved #536's guard there. After key_lookup_name reduces an ARN in this account and Region to its name, a name that validate_table_name refuses is not throttled. names_outside_the_table_name_rules_are_not_throttled goes through the segment, and it fails with the validate_table_name line deleted. A refusal now always names a resource, so throttle_error takes the ARN as &str. The None case and its tests are gone.

854a414 applies an Update carrying ProvisionedThroughput on a table that is PROVISIONED before and after the request. Each of the four backends already keeps a global secondary index's throughput on its index row or document. Each one now writes the new units there. Since b7affdf, the engine answers an Update that names no global secondary index of the table with ResourceNotFoundException. It answers before any backend write, as it does for WarmThroughput. The response and DescribeTable show the new units, and the index buckets take the new rate from the response. The test raising_the_index_throughput_ends_its_write_refusals drains a 1 WCU index with writes. It raises the index to 1000 and gets a 200 within 200 ms. The engine checks the units before it reads the table. It sends the answers I measured on 25 November against a table name that does not exist. A null unit and a unit below 1 get a clause at globalSecondaryIndexUpdates.1.member.update.provisionedThroughput.<unit>, write units first. The service still shows the old units in its response. Here they change at once, and the differences page says so. The engine still refuses an Update with OnDemandThroughput and the index update of a switch to PROVISIONED. The commit adds 270 production lines (164 in the four backends) and 295 test lines. The design doc and the register_indexes comment say that a kept index takes the new rate, and that is now true for a raised index.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants