mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(firehose): serialise flusher ticks so two polls cannot buffer the same records (#4141)
This commit is contained in:
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());
|
||||
|
||||
Reference in new issue
Block a user