spring-modulith
spring-modulith copied to clipboard
Identical events not handled properly, not sure if intentional
If I publish one event multiple times then
UPDATE EVENT_PUBLICATION
SET COMPLETION_DATE = ?
WHERE
LISTENER_ID = ?
AND SERIALIZED_EVENT = ?
Will update completion date on all of the records in the database: ones already completed and ones not even processed yet.
Should there be a unique constraint on listener_id and serialized_event or probably a better way to find the current record to update?
Actually stumbled upon this one by getting deadlocks when sending a lot of identical events and was wondering how a simple create then update once can deadlock :)
EDIT: I understand that modulith tries to guarantee at least once delivery so it doesn't break that but I still have that feeling that this could be handled in a more transparent way, would failing to process an identical event be considered bad?
So I'm thinking at minimum there should be a check for COMPLETION_DATE to be NULL so that history does not get changed. Also maybe LIMIT 1 but this is less important since it doesn't affect at least once behaviour.
I'm willing to contribute if what I'm saying actually makes sense.
I would love this issue to be solved as well.
We also ran into this issue. We had to place a random UUID into our event to prevent the completion date of already completed events from beeing changed by newly completed events.