Skip to content

Commit d6d7299

Browse files
committed
Fix a bug in seek.
This was hidden because of another bug in offset management
1 parent 2ce3217 commit d6d7299

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kafka/consumer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ def seek(self, offset, whence):
259259
reqs.append(OffsetRequest(self.topic, partition, -2, 1))
260260
elif whence == 2:
261261
reqs.append(OffsetRequest(self.topic, partition, -1, 1))
262+
263+
# The API returns back the next available offset
264+
# For eg: if the current offset is 18, the API will return
265+
# back 19. So, if we have to seek 5 points before, we will
266+
# end up going back to 14, instead of 13. Adjust this
267+
deltas[partition] -= 1
262268
else:
263269
pass
264270

0 commit comments

Comments
 (0)