spring-modulith icon indicating copy to clipboard operation
spring-modulith copied to clipboard

Identical events not handled properly, not sure if intentional

Open v3rm0n opened this issue 1 year ago • 3 comments
trafficstars

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?

v3rm0n avatar Jan 31 '24 18:01 v3rm0n

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.

v3rm0n avatar Feb 01 '24 08:02 v3rm0n

I would love this issue to be solved as well.

adel-haidar avatar Aug 02 '24 13:08 adel-haidar

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.

David-H-adesso avatar Aug 07 '24 07:08 David-H-adesso