Skip to content

Commit

Permalink
compensate for ls offset (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
mensfeld authored Jan 16, 2025
1 parent 0acaa0f commit 00b7ee4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/karafka/web/tracking/consumers/sampler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,12 @@ def enriched_consumer_groups
partition_details[:transactional] = k_partition_details[:transactional]

# Seek offset is always +1 from the last stored in Karafka
stored_offset = k_partition_details[:seek_offset] - 1
seek_offset = k_partition_details[:seek_offset]
stored_offset = seek_offset - 1

# In case of transactions we have to compute the lag ourselves
# -1 because ls offset (or high watermark) is last + 1
lag = partition_details[:ls_offset] - stored_offset
lag = partition_details[:ls_offset] - seek_offset
# This can happen if ls_offset is refreshed slower than our stored offset
# fetching from Karafka transactional layer
lag = 0 if lag.negative?
Expand Down

0 comments on commit 00b7ee4

Please sign in to comment.