druid icon indicating copy to clipboard operation
druid copied to clipboard

Appending Segments and Scaling Real-time Ingestion

Open fjy opened this issue 12 years ago • 4 comments

A fairly common use case that comes up with real-time ingestion is that after a segment is built and handed-off, additional (delayed) events may come in. These events could be directly appended onto an existing segment if segments were were mutable, but after hand-off, this is not the case. Druid's atomic update model requires entirely rebuilding a segment with the updated data before an older segment for the same time range can be invalidated. In many cases, entirely rebuilding a segment is costly to only updates a few events. Druid does allow sharding of data for a given time range, but the number of shards often needs to be known ahead of time. Moreover, Druid's query model is such that all shards for a given time range must be present in the system before a query successfully completes.

The linear shard spec was introduced as a means of getting around this problem. Druid can query for all linear shards and merge the results together. There is no notion of a "complete" set with linear shard specs, the broker merges the results of as many linear shard specs as are present. The problem with the linear shard spec is that if ever one shard were lost, valid looking results would still be returned, however, the total result would be lacking events from the missing shard.

One other way of solving this problem is to introduce a new task in the indexing service. The task can create a new segment metadata entry that clones an existing entry but updates the shard spec (and descriptor.json) of this new entry. In this sense, we could potentially have multiple segments that point to the same deep location, but possess different metadata. The task can then create a new segment with an updated shard spec that contains the updated events. The shard spec we would need to use is the numbered shard spec. This solution would still allow for atomic updates. The work done here should also be usable for dynamically scaling up ingestion in the indexing service.

fjy avatar Mar 05 '14 03:03 fjy

Any updates on this issue. Its really a showstopper for me

mdeora avatar Jan 30 '16 13:01 mdeora

Is there any work going on this issue. We have similar use case in which we want to modify the segment in realtime.

singhania avatar Nov 09 '17 10:11 singhania

why linear shard segments can not be merged by coordinator? @fjy @gianm

licl2014 avatar Feb 25 '18 10:02 licl2014

Does the ability for the Kafka indexing service to create segments for late data coupled with enabling auto compaction for the datasource address this?

vogievetsky avatar Jun 09 '19 04:06 vogievetsky