Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ChristofferKarlsson opened this issue Feb 16, 2025 · 1 comment
Assignees
Labels
in: event publication registry Event publication registry type: improvement Minor improvements
Milestone

Comments

@ChristofferKarlsson
Copy link

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.

odrotbohm added a commit that referenced this issue Feb 22, 2025
…publications.

We now rather use an object identity comparison in TargetEventPublication.isAssociatedWith(…) instead of an ….equals(…) as that would return the wrong publication for identical events.
@odrotbohm
Copy link
Member

We have previously used equals(…) when trying to find the event publication currently in progress, which indeed requires the event instances to be unique even if structurally identical. I've revised that arrangement to use object identity now to avoid this limitation. Please give the 1.4 snapshots a try. The M2 release should be out in a few days.

@odrotbohm odrotbohm added this to the 1.4 M2 milestone Feb 23, 2025
@odrotbohm odrotbohm self-assigned this Feb 23, 2025
@odrotbohm odrotbohm added in: event publication registry Event publication registry type: improvement Minor improvements labels Feb 23, 2025
@odrotbohm odrotbohm changed the title Multiple identical events not being marked completed correctly Structurally identical events cause wrong publication to be selected for completion Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: event publication registry Event publication registry type: improvement Minor improvements
Projects
None yet
Development

No branches or pull requests

2 participants