fix(redshift): keep a parameter or subnet group deleted during a modify from coming back (#8644)

deleteClusterParameterGroup and deleteClusterSubnetGroup now read and delete the group under the service's lock (mutate), which modifyClusterParameterGroup, resetClusterParameterGroup and modifyClusterSubnetGroup hold from their read to their write. A delete can no longer answer success between a modify's read and its write and have that write put the group back. The parameter group's deletion event is still emitted after the lock.
This commit is contained in:
mrfelek authored and GitHub committed 2026-11-16 16:08:52 -04:00
1 parent 70921dea2c
commit 2ca478b7ba
2 files changed
+56 -13

No files matched your search

@@ -3102,13 +3102,17 @@ public class RedshiftService implements ManagedSecretRotator {
}
public ClusterParameterGroup deleteClusterParameterGroup(String parameterGroupName) {
Optional<ClusterParameterGroup> groupOpt = parameterGroups.get(regionalKey(parameterGroupName));
if (groupOpt.isEmpty()) {
throw new AwsException("ClusterParameterGroupNotFound", "Cluster parameter group " + parameterGroupName + " not found", 404);
}
ClusterParameterGroup group = groupOpt.get();
parameterGroups.delete(regionalKey(parameterGroupName));
parameterGroups.flush();
// The read and the delete under the service's lock (mutate), which modifyClusterParameterGroup and
// resetClusterParameterGroup hold from their read to their write, so a delete can't land in between and be
// undone by their write; the event is emitted after it.
ClusterParameterGroup group = mutate(() -> {
ClusterParameterGroup found = parameterGroups.get(regionalKey(parameterGroupName))
.orElseThrow(() -> new AwsException("ClusterParameterGroupNotFound",
"Cluster parameter group " + parameterGroupName + " not found", 404));
parameterGroups.delete(regionalKey(parameterGroupName));
parameterGroups.flush();
return found;
});
emitEvent(RedshiftEventCatalog.PARAMETER_GROUP_DELETED, parameterGroupName,
"Cluster parameter group '" + parameterGroupName + "' was deleted at " + eventTime() + ".");
return group;
@@ -3267,11 +3271,16 @@ public class RedshiftService implements ManagedSecretRotator {
}
public ClusterSubnetGroup deleteClusterSubnetGroup(String name) {
ClusterSubnetGroup group = subnetGroups.get(regionalKey(name))
.orElseThrow(() -> new AwsException("ClusterSubnetGroupNotFoundFault", "Cluster subnet group " + name + " not found", 400));
subnetGroups.delete(regionalKey(name));
subnetGroups.flush();
return group;
// The read and the delete under the service's lock (mutate), which modifyClusterSubnetGroup holds from its
// read to its write, so a delete can't land in between and be undone by that write.
return mutate(() -> {
ClusterSubnetGroup group = subnetGroups.get(regionalKey(name))
.orElseThrow(() -> new AwsException("ClusterSubnetGroupNotFoundFault",
"Cluster subnet group " + name + " not found", 400));
subnetGroups.delete(regionalKey(name));
subnetGroups.flush();
return group;
});
}
// ── Snapshot Copy Grant Operations ───────────────────────────────────────