-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/kgo: bugfix ConsumePreferringLagFn
adjustPreferringLag adds back topics and partitions that the user did not specify. For partitions specifically, we reuse a partition map for all topics rather than create potentially dozens of partition maps. Previously, the code did not clear out the partition map entirely before moving onto the next topic. If a second topic had fewer partitions than a first topic, then we would add back fake partitions into our fetch, and when we went to build a fetch request, we would panic because the consumer offset pointer to use for the fake partition didn't exist. We now properly clear the map entirely between topics. Additionally, this fixes a bit of the previous behavior w.r.t. ordering: we documented that any unchanged ordering was preserved -- i.e. if you only wanted one partition at the front, the prior ordering for the remaining partitions was unchanged. The implementation did not honor this -- we iterated over maps to add back topics & partitions the user did not specify, and map iteration is unordered. We now iterate over the original input and compare if the input still exists in the map, and if so, add back. This makes adjusting slower, but _hopefully_ the impact is not noticeably worse. The integration tests are improved slightly, but I've been unable to trigger this in the integration tests -- instead, I recreated this locally. * One broker * Create two topics, one with one partition, the other with 2 * Produce 5mil messages to each topic * Group consume to the end so there is no lag * Seek before the end for the one-topic partition, seek one partition of the two-partition topic to the beginning, the other at the end * Redo the consumer The above will panic on the last step without this commit, and will not panic with this commit. Closes #310.
- Loading branch information
Showing
4 changed files
with
48 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters