...
- Where should the code live in? Should it live with operators, state backends, or both? We may also need something in operators or state backends (e.g. operators/StreamingRuntimeContext/KeyedStateStore) to have access to TimerService
We may need to experiment and prototype before finalizing this decision. How to distinguish TTL timers from user timers so that
they don't interfere with each other?
weuser timers are always invoked before TTL timers?
the TTL timers do not interfere with user-configured timers, specifically, what happens if a user configures a timer
Upon discussion, we believe that the user timer should always be invoked first. We need a good strategy to ensure that, when a user timer and a TTL timer are configured for the same time
as a Ttl timer? Upon discussion,
we believe that theuser
-configuredtimer
shouldis always
be invoked we distinguish user and TTL timers?triggered first.
But how canCurrently, timer service does not support timer tags
,. We have two kinds of timers now and we
mayneed
to finda better
of achieving the purpose, either adding support for timer tags or some other waysway of maintaining both of them.
Option1: We can add a tag for each timer to InternalTimer
Option2: let InternalTimerService maintains user timers and TTL timers separately, by adding to it the following new APIs:Code Block language java public void registerTtlProcessingTimeTimer(N namespace, long time); public void registerTtlEventTimeTimer(N namespace, long time);
And implementation classes of InternalTimerService should add two new sets of timers, e.g. processingTtlTimeTimersQueue and eventTtlTimeTimersQueue for HeapInternalTimerService. Upon onProcessingTime() and advanceWatermark(), they will first iterate through ProcessingTtlTimeTimer and EventTtlTimeTimer before iterating the ProcessingTimeTimers and EventTimeTimer.
The biggest advantage, compared to option 1, is that it doesn't impact existing timer-related checkpoint/savepoint and migrations.
Test Plan
Normal unit, integration, and end-to-end tests
...