confluentinc/kafka-streams-examples

Punctuate being invoked in Transformer at Irregular intervals

piyuverma opened this issue · 1 comments

I am using Local State Store in a Transformer for later processing of records and getting them processed at a scheduled interval using punctuate().
But, i have observed the behaviour of punctuate(..) to be unpredictable.
I tried with num.stream.threads as 1 and more also, with Source Topic of 1 Partition and punctuate interval of 10 seconds. A single thread is running, since there is just 1 partition. However, punctuate(..) is being called at every 0th and 8th second. And, i also tried with increasing the number of threads and punctuate intervals, still the similar observation.

Have attached the screenshots for better reference.

Screenshot 2020-01-16 at 2 02 21 AM

Screenshot 2020-01-16 at 12 45 43 PM

Screenshot 2020-01-16 at 12 46 03 PM

Screenshot 2020-01-16 at 12 46 11 PM

Screenshot 2020-01-16 at 12 48 31 PM

Screenshot 2020-01-16 at 12 46 42 PM

mjsax commented

What do you mean by is being called at every 0th and 8th second. Note that there will always be some inpricission, but if you register a wall-clock time punctuation, the first call-back should be a wallClockTimeWhenYouCallSchedule + punctuationIntervalMs and than following the interval, for example you call schedule at time "3" with 10 seconds interval, that you should get callbacks at 13, 23, 33, 43... etc

Note, that is may happen that an punctuation might be called a little bit delayed, but it should never be call too early. Using the example above:

14, 23, 34, 43, 55, 64... etc

Can you provide more details at which timestamps you see the callback being executed?

If the "jitter" you see in the execution intervals is too large for your use case, you can try to reduce consumer configuration max.poll.records.