fix(kafka source): Add commit_interval_ms option#944
fix(kafka source): Add commit_interval_ms option#9443 commits merged intomasterfrom unknown repository
commit_interval_ms option#944Conversation
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
|
Thanks, @a-rodin. Is it worth opening a follow-up issue to represent the improvement? |
|
@binarylogic I've read more topology and fanout code and think now that probably no additional issue is needed, but this PR has to be reworked to do the following:
In that case the messages will be delivered to at least one of the sinks and in case of restarts there would be no more duplicates than there are threads. |
|
@a-rodin what do you think about simply setting the In the longer term, tracking message acknowledgments and propagating them back to sources is something we'll definitely want to explore. |
|
@lukesteensen If we enable auto commit, then we need to store offsets manually. At the moment this solution seems the cleanest to me. With both autocommit and automatic offset storing there are losses of messages on each restart (I tested it and observed them). |
|
I did a few tests. In all of them Vector was reading data from a Kafka topic and writing the data to a file for around 28 seconds. The commit interval was set to 5 seconds. These are the results:
Meaning of the columns:
From the results it looks like using autocommit and automatic offset storing together result in losing one message. I was actually expecting that "Manual, immediate"/"Automatic" would also result in losing the last message, but it doesn't seem to happen. My idea in the previous comment was to replace "manual, immediate" offset storing strategy by "manual, on next poll" which would save offsets for a message when the next |
|
How were you shutting vector down for these tests? I'd hope that a clean shutdown would give us a chance to ack the final message before shutting down and not have any loss or dups. Do you think the difference auto and manual commit is that auto will do a commit on shutdown? That seems like the best outcome in your tests, but we could maybe adjust the manual strategy. |
|
@lukesteensen I was pressing Ctrl-C once each time, which should send SIGINT.
It should commit on shutdown because the
Actually, I'm leaning towards this approach (manual/auto) now because it performs well in tests and is simple to maintain. I explored the approach from my previous comment, but it seems to be necessarily cumbersome to implement (requires either moving offsets between threads or calling unsafe functions) without the corresponding safe APIs in |
👍 This sounds good to me |
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
|
@a-rodin just checking progress on this. Anything blocking merging? |
|
@binarylogic I think this is ready to merge. I've tested it manually and it works. |
|
Perfect! @lukesteensen mind approving if everything is good? |
Closes #865
This PR implements simple committing of offsets to Kafka. Previously the offsets were only stored but not committed.
I'm not very happy with the implementation though. While it is an attempt to guarantee "at least once" delivery, the issue with it is that the number of duplicates happening after a restart of Vector is quite high (with magnitude of
commit_interval* throughput).I think the approach from
rdkafka's example with autocommit and storing of the offsets only for processed messages would be more reliable, but there is a need for a way to mark each message as processed (stored to disk buffer or sinks) to store offsets only for marked messages.