-
Notifications
You must be signed in to change notification settings - Fork 107
Kafka notifier: do not wait until timeout when there is no backlog to process, ie. no message in the partition queue #1315
Conversation
… process, ie. no message in the partition queue
While this approach works, i think we can resolve this issue in a more reliable way. eg, if the user sets the "offset" config item to 'newest' then the bootimeOffset would be > 0, but we should also call I suggest a few changes:
|
I'm not sure why in this case bootTimeOffsets[partition] would be > 0. It seems to be independent from what the "offset" config item is set to. For that reason I believe my change to be reliable, even in that case.
That seems like a good idea to make the code more obvious.
I agree this code belongs to
If
I'm going to think that through a little more to figure out what an elegant solution would be. Perhaps just subtracting 1 to the result of |
Yes, exactly.
Not when consumePartition() starts. Currently, the Simply put, my idea here is to just call |
Yes but that is unrelated to the "offset" config item. Hence I don't see why it would break. |
Yep, agreed. That's exactly what I described in:
|
What I was trying to say was that I am working on a patch doing what you are suggesting with a slight twist. |
Your proposed changes wouldn't break anything. They just dont cover all scenarios where there are no messages to consume. eg if the config has 'offset' set to 'newest' nothing will be consumed until a new message is published to the partition. I think the confusion here is due to what c.client.GetOffset() returns. If you ask kafka for the "newest" offset, it will give you the offset number that will be used for the next message to be received, not the offset of the last message received by the broker. |
Yes! I understood my mistake now. I had the return value of So the patch I have locally takes care of that. |
- keep bootTimeOffsets local to consumePartition and renamed it to lastAvailableOffsetAtStartup - at startup invoke GetOffset() to retrieve the explicit index in all cases ('oldest', 'newest', timestamp) - factored duplicated code into updateProcessBacklog() and updateMetrics() - when consumePartition() starts, check if backlog has been processed; fixes all cases of backlog processing stuck when no messages need to be received. Note: partitionLagMetric was previously set to GetOffset(..., OffsetNewest) - msg.Offset and is now set to GetOffset(..., OffsetNewest) - msg.Offset - 1. Other metrics remained unchanged.
Ok, I took a stab at it. @woodsaj what do you think of it? |
mdata/notifierKafka/cfg.go
Outdated
@@ -125,16 +124,9 @@ func ConfigProcess(instance string) { | |||
partitionLogSize = make(map[int32]*stats.Gauge64) | |||
partitionLag = make(map[int32]*stats.Gauge64) | |||
|
|||
// get the "newest" offset for all partitions. | |||
// when booting up, we will delay consuming metrics until we have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of this comment needs to be cleaned up. All this loop is doing is initialising stats for each partition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks great.
Rationalised NotifierKafka's backlog processing:
Note: partitionLagMetric was previously set to GetOffset(..., OffsetNewest) - msg.Offset and is now set to GetOffset(..., OffsetNewest) - msg.Offset - 1. Other metrics remained unchanged.
Fixes #1316