druid icon indicating copy to clipboard operation
druid copied to clipboard

Use system time in kafka-indexing-service

Open zhangxinyu1 opened this issue 9 years ago • 4 comments

We want to use system time in kafka-indexing-service, but I have a problem unsolved. That is Exception "cannot allocate segment for timestamp[]" may occur when task fails. For example, if 1、The segment Granularity of my task is 1 hour. 2、the task starts at 11:30 3、the task is killed at 12:10 4、the task use system time as timestampSpec Then, we will get the Exception when the task restarts. That is because 1、when we start the task, a pending Segment(interval=11:00-12:00, prev_segment_id=null) will be created, and a pending Segment(interval=12:00-13:00, prev_segment_id=${previous_segment_id}) will be created after 12:00. 2、And then, we kill the task at 12:10. The task with same sequence name will restart. We will find the pending Segment(prev_segment=null), but the interval of this pending Segment is 11:00-12:00. If we use system time as timestampSpec, interval(11:00-12:00) cannot match the timestamp after 12:10.

Anyone can give me some advice? ( we can give up using multi-replicas)

zhangxinyu1 avatar Aug 29 '17 09:08 zhangxinyu1

@zhangxinyu1, what are you wanting to use the system time for?

The current design is attempting to ensure that the behavior of the kafka index task is completely deterministic based on the combination of task config (hashed as part of the sequenceName) + messages in kafka. We purposely avoided using system time for anything since it would lead to non-determinism.

gianm avatar Aug 29 '17 10:08 gianm

@gianm Our users use druid to do some real-time statistics, and output results each 5 minutes (by using group by all dimensions, and the interval is latest 5 minutes). In this way, they can get results without coding. If they don't use system time, some late messages are lost. But you are right. kafka index task should be completely deterministic. Druid may be not suitable for this requirement. We should change our usage of druid. Thanks very much!

zhangxinyu1 avatar Aug 29 '17 11:08 zhangxinyu1

@zhangxinyu1 ah I see. In this case, why not just write the system time into the message itself? The Druid Kafka indexing service is capable of loading late messages.

gianm avatar Aug 29 '17 17:08 gianm

Yeah, we are planning to do it. In this way, we can ensure one message only has one timestamp.

zhangxinyu1 avatar Aug 30 '17 03:08 zhangxinyu1