Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlockBuilder: Refactor the consume cycle logic #8329

Merged
merged 7 commits into from
Jun 12, 2024

Conversation

codesome
Copy link
Member

@codesome codesome commented Jun 10, 2024

@narqo this moves some logic out of consumePartition and into the nextConsumeCycle. Main aim of this is to make consumePartition() simpler where it just starts consuming from the partition until the given cycle end time. We also pass the block start and end times, and the last seen record as part of arguments.

We now do all the heavy lifting in nextConsumeCycle, where we call consumePartition() in parts when it is lagging. We calculate the timestamps appropriately.

@codesome codesome requested a review from narqo June 10, 2024 22:56
@codesome codesome force-pushed the bb-tests-and-fixes branch 2 times, most recently from 331ea4b to 712b67d Compare June 10, 2024 23:37
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
@codesome codesome force-pushed the bb-tests-and-fixes branch from 712b67d to af11016 Compare June 11, 2024 02:06
codesome added 2 commits June 11, 2024 17:27
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
@codesome codesome marked this pull request as ready for review June 12, 2024 00:20
@codesome codesome requested a review from a team as a code owner June 12, 2024 00:20
@codesome codesome requested review from narqo and removed request for a team June 12, 2024 00:20
@@ -28,7 +28,7 @@ import (
)

type builder interface {
process(ctx context.Context, rec *kgo.Record, blockMin, blockMax int64, recordProcessedBefore bool) (_ bool, err error)
process(ctx context.Context, rec *kgo.Record, lastBlockMax, blockMax int64, recordProcessedBefore bool) (_ bool, err error)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the name because technically it is not a blockMin, rather the max of the last cycle

narqo and others added 2 commits June 12, 2024 11:36
Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Comment on lines 507 to 509
for i := range req.Topics[0].Partitions {
if req.Topics[0].Partitions[i].Partition == commitRec.Partition {
req.Topics[0].Partitions[i].Metadata = &meta
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the commit metadata. Debugging through the kgo library I saw that this string was not being overridden. By default kgo sets it to member ID (which is what we were seeing).

See 3e5e03f for the fix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have written unit tests for this. I will clean it up and push it as well.

codesome added 2 commits June 12, 2024 13:16
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
@codesome codesome merged commit 665b747 into blockbuilder Jun 12, 2024
20 of 28 checks passed
@codesome codesome deleted the bb-tests-and-fixes branch June 12, 2024 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants