mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(dynamodb): scope streams and sequence counters by account (#4116)
This commit is contained in:
1 parent
008ddea054
commit
d53ea39be9
3 files changed
+105
-2
No files matched your search
+4
-2
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user