fix(dynamodb): scope streams and sequence counters by account (#4116)

This commit is contained in:
Daniël van Ziel authored and GitHub committed 2026-10-04 07:39:38 -04:00
1 parent 008ddea054
commit d53ea39be9
3 files changed
+105 -2

No files matched your search

@@ -46,7 +46,8 @@ public class DynamoDbStreamService {
private final ConcurrentHashMap<String, ConcurrentLinkedDeque<DynamoDbStreamRecord>> records =
new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, AtomicLong> streamRecordCounts = new ConcurrentHashMap<>();
private final AtomicLong sequenceCounter = new AtomicLong(0);
/** Per stream (the stream ARN embeds account + region + table) so accounts never share a counter. */
private final ConcurrentHashMap<String, AtomicLong> sequenceCounters = new ConcurrentHashMap<>();
private final ObjectMapper objectMapper;
@@ -142,6 +143,7 @@ public class DynamoDbStreamService {
if (sd != null) {
records.remove(sd.getStreamArn());
streamRecordCounts.remove(sd.getStreamArn());
sequenceCounters.remove(sd.getStreamArn());
LOG.infov("Deleted stream for table {0}", tableArn);
}
}
@@ -160,7 +162,7 @@ public class DynamoDbStreamService {
return;
}
long seq = sequenceCounter.incrementAndGet();
long seq = sequenceCounters.computeIfAbsent(sd.getStreamArn(), k -> new AtomicLong()).incrementAndGet();
String sequenceNumber = String.format("%021d", seq);
JsonNode sourceItem = newItem != null ? newItem : oldItem;