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

Ensure write and order guarantees with Producer.committableSink #1265

Closed
wants to merge 3 commits into from

Conversation

seglo
Copy link
Member

@seglo seglo commented Nov 25, 2020

References #1242

Enforce enable.idempotence when using the Producer.committableSink. This will ensure that produced messages are recorded once and in the order they were sent to the broker. Some caveats with this solution:

  • The broker must be version 0.11 or greater
  • max.in.flight.connections must be <= 5 (enforced by setting enable.idempotence=true)
  • acks must be set to all (enforced by setting enable.idempotence=true)

@seglo
Copy link
Member Author

seglo commented Nov 25, 2020

Initial benchmarks indicate enforcing enable.idempotence with Producer.committableSink has little to no effect on producer throughput. It could be that other Alpakka Kafka performance penalties outweigh any performance loss provided by this setting, or it could be that our benchmark infrastructure scale is just not sufficient to observe a notable difference. Either way, if this fixes the dropped/unordered messages it may be an acceptable solution when using Producer.committableSink.

@seglo
Copy link
Member Author

seglo commented Nov 26, 2020

@PrathikPuthran The intention is that using enable.idempotence could resolve the issue you raised in #1242. Can you try this PR, or just add enable.idempotence to your ProducerSettings yourself?

@seglo
Copy link
Member Author

seglo commented Dec 9, 2020

@PrathikPuthran Hello again. Let me know if you have time to check if this setting resolves the issue for you. If it does then we can make this the default for 2.1.0.

@PrathikPuthran
Copy link

@seglo Sorry for the delay. Would this work if custom partitioning is used in the kafka producer?

@seglo
Copy link
Member Author

seglo commented Dec 10, 2020

@seglo Sorry for the delay. Would this work if custom partitioning is used in the kafka producer?

@PrathikPuthran Yes, I don't see why not. All it's doing is using sequence numbers (per destination partition for the length of the producer session) to ensure message ordering and for the broker to determine if any messages have been missed or duplicated. Missed messages will result in a fatal exception, dupes will be de-duped silently on the broker side. Your broker must be at least version 0.11.

@PrathikPuthran
Copy link

Yes but if send to one broker partition fails (if one broker is unhealthy) but the send for some other broker partition succeeds with messages of higher offsets you would still be committing offsets out of order I think?

@seglo
Copy link
Member Author

seglo commented Dec 10, 2020

Yes but if send to one broker partition fails (if one broker is unhealthy) but the send for some other broker partition succeeds with messages of higher offsets you would still be committing offsets out of order I think?

I did some digging and I can't find an official statement that callbacks can return out of order with enable.idempotence=true, but I think it's implied that this should not happen. If you can reliably reproduce this commit out of order issue I would encourage you to try it anyway. Otherwise it may take awhile for me to verify it myself.

@seglo
Copy link
Member Author

seglo commented Feb 3, 2021

This may be better served as a note in the docs on Producer.committableSink, instead of enforcing a Producer property.

@seglo
Copy link
Member Author

seglo commented Feb 3, 2021

If someone can confirm if enable.idempotence resolves the issue I'll refresh this PR with a docs update. Closing for now.

@seglo seglo closed this Feb 3, 2021
@ennru ennru deleted the seglo/wip-commit-sink-ordering branch July 5, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants