kafka-go icon indicating copy to clipboard operation
kafka-go copied to clipboard

Exactly once

Open Jarema opened this issue 6 years ago • 11 comments

Describe the solution you'd like Company I work for is using kafka as one of ways to communicate between services and GO is one of core languages we use.

We would love to use kafka-go, as it's API looks much nicer than Sarama, yet we have two requirements:

  • exactly once support for producer (so indepotence flag) suppoer
  • transactions support

With the latter I see #216 being in progress. How the situation looks with the former one?

We could contribute if help is needed, though we need to know current state before moving forward.

Supporting documentation https://www.confluent.io/blog/exactly-once-semantics-are-possible-heres-how-apache-kafka-does-it/

Jarema avatar Mar 15 '19 17:03 Jarema

Hi @Jarema ,

I'm not aware of any current work toward exactly once support. If your team is willing to tackle that part, any contribution is welcome !

Pryz avatar Mar 15 '19 18:03 Pryz

Hi @Pryz. I will look into it. The problem is we have tight deadline on this and my decision depends on cost of implementation of at least exactly one feature.

In theory, it doesn't sound complicated:

  • each producer session has its own PID and a sequence number.
  • with each request, producer sends the PID and sequence
  • producer uses indepotence flag
  • if producer does not get ACK for a message, it resends it
  • if broker gets the same message as previous, but ACK was lost, it will send ACK duplicate message

So, with my limited kafka API knowledge and very limited kafka-go client knowledge it means that:

  • we need to add idepotence key when creating producer session
  • we need to iterate the seq key on each write
  • we need to check ACK duplicate response and treat it as a proper response (maybe current logic will handle that already if ACK is "similar enough".

Does it sound ok for you? If yes, I'll have a deeper look into kafka-go codebase to see how much work is needed to be done.

Jarema avatar Mar 16 '19 07:03 Jarema

@Jarema Idempotence flag is also a requirement for supporting transactions. You can read it here: https://docs.google.com/document/d/11Jqy_GjUGtdXJK94XGsEIK7CP1SnQGdp2eF0wSw9ra8/edit# Look at pages 21-22. Please notify me about your PRs.

VictorDenisov avatar Mar 16 '19 20:03 VictorDenisov

Hi @Jarema , any news on this?

sneko avatar Jan 15 '20 10:01 sneko

Still interested... to do event sourcing not guaranteeing the idempotency from Kafka sounds bad :(

sneko avatar Jan 20 '20 18:01 sneko

Hi @achille-roussel ,

Is idempotence flag a work in progress on your side? It would unlock a lot of possibilities instead of switching over confluent-kafka-go.

Thank you,

sneko avatar Jan 31 '20 12:01 sneko

Hi @achille-roussel,

I would like to pick this up :) I'll start digging this weekend. Please point me towards any useful starting points/docs apart from #216. Cheers.

live-wire avatar Jan 22 '21 20:01 live-wire

Thanks for volunteering @live-wire !

achille-roussel avatar Jan 22 '21 22:01 achille-roussel

any update on this?

0x4139 avatar Mar 15 '21 16:03 0x4139

Bump

teddyknox avatar Mar 20 '21 15:03 teddyknox

any update? such a desired feature for transactional workloads

baganokodo avatar Nov 14 '21 18:11 baganokodo