These are chat archives for RBMHTechnology/eventuate

29th
Aug 2017
Rouge_yk
@hanchenyi
Aug 29 2017 05:17
@krasserm Hi, Is there possibility of replicate events when starting the EventSourcedWriter ? I mean there are two same events to be consumed by external database when the snapshot is loaded. Because the data in cassandra are serialized,, I met a problem where EventsourcedWriter write failed caused by duplicate entry of same key. Do I need use (Resolving conflicting versions in the guide tutorial) ?
Martin Krasser
@krasserm
Aug 29 2017 06:22
@hanchenyi sorry, I can't follow what you mean. Please elaborate.
Rouge_yk
@hanchenyi
Aug 29 2017 06:33
@krasserm https://github.com/hanchenyi/FirstAkkaProject/wiki/20170829-Q3-EventSourcedWriter , Here is detailed description. Thank you for your help.
Martin Krasser
@krasserm
Aug 29 2017 06:51

Since write batches are deleted asynchronously by the application (at the end of a write) it may be that the writer is re-attempting to write them after a restart if it crashed before deleting them. After restart, read() is called which allows the application to determine which batches have already been written. You can to take that information to pre-process the write batches in order to avoid constraint violations. OTOH, it may be ok for your application to just catch them, this can be a perfectly fine mechanism for idempotency, if the sequence number is part of the primary key.

Please note that this has nothing to do with event duplication. A writer will never receive duplicate events, regardless if it is recovered from a snapshot or from scratch.

Rouge_yk
@hanchenyi
Aug 29 2017 07:42
@krasserm Thanks. Here is some supplement of what I think. https://github.com/hanchenyi/FirstAkkaProject/wiki/20170829-Q4-EventSourcedWriter
Martin Krasser
@krasserm
Aug 29 2017 07:50
If you can atomically update the progress (table) together with your other writes, then you'll be able to avoid constraint violations from the sequence number alone (by ignoring those batches that have a sequence number <= the read sequence number or progress). Otherwise you still may see constraint violations if the writer writes the data but crashes before writing the progress.
Rouge_yk
@hanchenyi
Aug 29 2017 08:06
@krasserm Thanks for your careful guidance. Thank you.
Martin Krasser
@krasserm
Aug 29 2017 08:06
@hanchenyi you're welcome!