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

Fix auto-commit bug and make a feature of auto-commit #1687

Closed
wants to merge 1 commit into from

Conversation

lqiz
Copy link

@lqiz lqiz commented May 5, 2020

I believe that the sarama-cluster hasn’t designed the auto-commit feature. What we have to do is updating the offset via MarkOffset/MarkMessage after consuming the message.

Here is its reason:

Offset manager is completely independent of the consumer. flushToBroker in main-loop has only flush offset to the broker but it doesn’t update the offset.
It has no relation between the offset updating and the consumer in sarama. Currently, the offset updating depends on the Markoffset after consuming the message.
If auto-commit want to be supported in sarama, it should update the offset when fetching messages. After offset updating, the main-loop will handle commit things left.

So this fix is made via updating the offset.

@lqiz lqiz requested a review from bai as a code owner May 5, 2020 16:09
time.Sleep(time.Second)
}
}()

Choose a reason for hiding this comment

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

What are you doing?! You mark all fetched messages consumed every second? And not respect to the closing event (ctx.Done() or parent.closed), which cause goroutine leak.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks a lot for you review.
I want to implement the auto-commit feature. Yes, closing event should be respected.

Choose a reason for hiding this comment

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

IIRC, the auto-commit feature already exists.

Copy link
Author

Choose a reason for hiding this comment

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

See this thread, #1570
The auto-commit feature won't work, and i have add analysis in the desc of this fix.

@dnwe
Copy link
Collaborator

dnwe commented Jun 24, 2020

@lqiz thanks for putting this PR together. I think that the functionality you were looking for has now been covered as part of the merged PR #1699 which correctly disables the auto-commit loop if you choose to disable auto-commits, and provides a Commit() func on the consumer group to elect when you'd like to commit.

Feel free to come back if you think there is still some capability missing here though.

@dnwe dnwe closed this Jun 24, 2020
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.

None yet

3 participants