fix(dynamodb): reject UpdateTable GSI changes AWS refuses (#4714)

* fix(dynamodb): reject UpdateTable GSI changes AWS refuses

UpdateTable accepted more than one GSI create or delete in one request,
and a GSI create or delete together with a BillingMode or throughput
change. Real DynamoDB answers the first with LimitExceededException
("Only 1 online index can be created or deleted simultaneously per
table") and the second with ValidationException ("You cannot create or
delete index while updating table IOPS"). Both checks run before the
table changes.

updateTableDeleteAllGsis deleted two GSIs in one request, which AWS
rejects, so it now deletes them in two requests; its end state is the
same.

Fixes #4572

* fix(dynamodb): share the online index limit across GSI and vector index changes

The limit now carries the AWS Subscriber limit prefix, counts GSI and vector index operations together, and an index change is also refused alongside table OnDemandThroughput.

* refactor(dynamodb): keep one copy of the UpdateTable index-count check

The service already refuses more than one online index operation before anything changes, so the handler's duplicate check is dropped. Integration tests for this change now use the deleteTable helper and clean up their tables.
This commit is contained in:
Sam Fakhreddine authored and GitHub committed 2026-10-09 23:23:41 -04:00
1 parent 8502565287
commit fdb21de095
4 files changed
+321 -6

No files matched your search

@@ -2316,7 +2316,8 @@ public class DynamoDbService {
if (newAttrDefs != null) {
knownAttrDefs.addAll(newAttrDefs);
}
validateVectorIndexUpdates(table, vectorIndexCreates, vectorIndexDeletes, knownAttrDefs,
validateVectorIndexUpdates(table, vectorIndexCreates, vectorIndexDeletes,
gsiCreates.size() + gsiDeletes.size(), knownAttrDefs,
billingMode != null ? billingMode : table.getBillingMode());
if (readCapacity != null) {
@@ -2372,13 +2373,14 @@ public class DynamoDbService {
* current lifecycle state.
*
* <p>AWS allows one online index operation per table at a time. That limit binds the table,
* not the request, so two creates in one request and a create issued while an earlier index
* not the request, and GSI creates and deletes count against it too, so two creates in one
* request and a create issued while an earlier index
* still builds are refused the same way. Deleting an index that is still in its resource
* allocation phase is refused with a different error, and the same delete is accepted once
* the index reaches backfilling.
*/
private void validateVectorIndexUpdates(TableDefinition table, List<VectorIndexCreate> creates,
List<String> deletes,
List<String> deletes, int gsiOperations,
List<AttributeDefinition> attributeDefinitions,
String billingMode) {
validateVectorIndexMembers(creates);
@@ -2389,7 +2391,7 @@ public class DynamoDbService {
"One or more parameter values were invalid: Vector indexes are only supported "
+ "for PAY_PER_REQUEST tables", 400);
}
if (creates.isEmpty() && deletes.isEmpty()) {
if (creates.isEmpty() && deletes.isEmpty() && gsiOperations == 0) {
return;
}
for (VectorIndexCreate create : creates) {
@@ -2421,7 +2423,8 @@ public class DynamoDbService {
.count();
// Deleting an index that is still backfilling takes over the slot that index already
// holds, so it does not need one of its own.
long onlineOperations = building + creates.size() + deletes.size() - deletesOfBuildingIndexes;
long onlineOperations = building + creates.size() + deletes.size() + gsiOperations
- deletesOfBuildingIndexes;
if (onlineOperations > 1) {
throw new AwsException("LimitExceededException",
"Subscriber limit exceeded: Only 1 online index can be created or deleted "
@@ -1755,6 +1755,12 @@ public class NativeDynamoDbJsonHandler {
}
}
if ((gsiCreates.size() + gsiDeletes.size() > 0) && (request.has("BillingMode")
|| request.has("ProvisionedThroughput") || request.has("OnDemandThroughput"))) {
throw new AwsException("ValidationException",
"You cannot create or delete index while updating table IOPS", 400);
}
if (!gsiThroughputUpdates.isEmpty()) {
TableDefinition currentTable = dynamoDbService.describeTable(tableName, region);
for (GsiThroughputUpdate gsiUpdate : gsiThroughputUpdates) {