Replies: 1 comment
-
The republication on startup was switched to be disabled by default in 1.1 for exactly that reason. There's also the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a modulith application running in a docker container, and I want to scale it out horizontally (i.e. run more docker containers, all connected to the same database).
The
PersistentApplicationEventMulticaster
bean'safterSingletonsInstantiated
method retrieves incomplete event publications from the database by callingregistry.get().findIncompletePublications()
, then for each event publication, it calls the respective listener viapublications.forEach(this::invokeTargetListener)
.There doesn't appear to be any locking at the database level going on here, so if multiple modulith runtimes (eg. docker containers) are starting up around the same time, they may attempt to invoke the listener for the very same event publication together. Do I understand that right? Another way this could happen: If container A publishes 100 events, and their listeners are all in progress handling those events while container B spins up and queries for incomplete publications.
Some potential approaches to prevent this:
A. Pessimistically lock the event publication row on retrieval in findIncompletePublications
B. Each modulith application context could "claim" the event publications it intends to invoke before it actually invokes it.
Beta Was this translation helpful? Give feedback.
All reactions