sarama icon indicating copy to clipboard operation
sarama copied to clipboard

How can I identify a commit operation is successful?

Open ZzIris opened this issue 2 years ago • 2 comments

hello! it's i first time to learn to use sarama. I find that there is not a error return when i call sarama.ConsumerGroupSession.Commit, i should use sarama.ConsumerGroup.Errors() if i want to get a error, but i don't know the error which i get from sarama.ConsumerGroup.Errors() is really from commit operation or other operation, how can i identify a error is a commit error in another word? please give me example, thanks!!!

ZzIris avatar Jan 12 '23 07:01 ZzIris

👋 hi @ZzIris

So as you note, whilst the .Commit() call itself is a blocking operation to send the commit, the response is handled by the offset manager code and any error(s) found in the offset commit response on a per-topicpartition basis will be passed back through to the consumer's Errors channel (if you have Consumer.Return.Errors set in your conf) within this block https://github.com/Shopify/sarama/blob/1b5bb4851e9ee710271a21c71d84ff8bd8f2e391/offset_manager.go#L598-L610

Ultimately all you can do at that point is inspect the type of the Err and if it is obviously related to the commit (e.g., ErrInvalidCommitOffsetSize) you'd know, but in general the consumer group code will be taking the appropriate action (restarting / retrying etc.) and there isn't much you could do differently

Unfortunately the ability to manually-commit offsets as part of the consumer group API in Sarama was somewhat retrofitted

dnwe avatar Jan 12 '23 12:01 dnwe

@dnwe for example, in some case, my application encountering a network error for a long time, and the application will recrod the offset have consumed but fail to commit when i restart the application at this moment to prevent process again,the application will nerver know which offset is consumed but fail to commit if i can't match the error from commit operation~ how can i do? what key word of the error that I can get from sarama.ConsumerGroup.Errors()? i try to find a definition about commit error, but just find sarama.ErrTxnOffsetCommit、sarama.ErrUnstableOffsetCommit、sarama.ErrInvalidCommitOffsetSize,the commit errors are not always related to them in my opinion.

ZzIris avatar Jan 13 '23 03:01 ZzIris

Would it be acceptable (in terms of API stability) to also have Commit return the error from the offset manager (as well as forwarding it through the handlers)? All existing ~~code~~ uses should be compatible, but it would trigger some popular linters, and anyone implementing their own ConsumerGroupSession type will need to update it. (However, new methods are added to interfaces regularly so this doesn't seem like an unusual case.)

joewreschnig avatar Mar 21 '23 11:03 joewreschnig

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur. Please check if the main branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.

github-actions[bot] avatar Jul 18 '23 00:07 github-actions[bot]

@joewreschnig thanks, I pulled in your changes and rebased them under PR #2635 so we can have a think about the API compatibility changes

dnwe avatar Aug 31 '23 08:08 dnwe

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur. Please check if the main branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.

github-actions[bot] avatar Jan 08 '24 10:01 github-actions[bot]