Skip to content

Structurally identical events cause wrong publication to be selected for completion #1056

Closed
@ChristofferKarlsson

Description

@ChristofferKarlsson

If multiple equal events of the same type and same data are published in the same transaction, and then they are all processed, the event publication registry will have about half of them not marked as completed. Even though they're actually all processed without problem.

If making the event data unique in some way, there is no problem. But I can't see any constraints about events having to be unique in the documentation.

There seems to be a race condition, and turning on the SQL trace logging, I see that multiple concurrent tasks will update the COMPLETION_DATE for the same EVENT_PUBLICATION.

2025-02-16T13:56:22.211+01:00 DEBUG 147904 --- [modulith-multiple-equal-events] [         task-4] o.s.jdbc.core.JdbcTemplate               : Executing prepared SQL statement [UPDATE EVENT_PUBLICATION
SET COMPLETION_DATE = ?
WHERE
		ID = ?
]
2025-02-16T13:56:22.211+01:00 TRACE 147904 --- [modulith-multiple-equal-events] [         task-5] o.s.jdbc.core.StatementCreatorUtils      : Setting SQL statement parameter value: column index 2, parameter value [869af431-273d-4407-b2ee-e13d3289e99d], value class [java.util.UUID], SQL type unknown
2025-02-16T13:56:22.211+01:00 TRACE 147904 --- [modulith-multiple-equal-events] [         task-3] o.s.jdbc.core.StatementCreatorUtils      : Setting SQL statement parameter value: column index 2, parameter value [869af431-273d-4407-b2ee-e13d3289e99d], value class [java.util.UUID], SQL type unknown
2025-02-16T13:56:22.211+01:00 TRACE 147904 --- [modulith-multiple-equal-events] [         task-6] o.s.jdbc.core.StatementCreatorUtils      : Setting SQL statement parameter value: column index 2, parameter value [869af431-273d-4407-b2ee-e13d3289e99d], value class [java.util.UUID], SQL type unknown

I have setup a repository that reproduces the problem in a test.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions