fix(firehose): serialise flusher ticks so two polls cannot buffer the same records (#4141)

This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-22 07:38:26 -05:00
1 parent 83ae2b4697
commit 86493303cd
1 file changed
+8 -1
@@ -237,7 +237,14 @@ public class FirehoseService implements ResourceProvider {
buffers.keySet().forEach(this::flushByKey);
}
void tickSafely() {
/**
* Ticks never overlap: {@code flushExecutor} is single threaded, and the source poll is a
* read of the shard iterator, a fetch and an advance that is not atomic across the three, so
* two concurrent ticks would fetch the same records twice and buffer them twice. Tests drive
* this method directly alongside the scheduled tick, which is the only way a second caller
* arises, so the guarantee is stated here rather than left to the executor.
*/
synchronized void tickSafely() {
try {
pollKinesisSources();
flushDueBuffers(clock.instant());