Skip to content

Conversation

@jbertram
Copy link
Contributor

This commit mitigates a number of different potential race conditions involving configuration changes. Consider the storeAddressSetting method in o.a.a.a.c.p.i.j.AbstractJournalStorageManager. It mutates mapPersistedAddressSettings twice - once to delete an entry and once to put an entry. If another thread executes the recoverAddressSettings method in between these two operations it will not contain the record that is being stored. This same race condition exists for a number of different maps.

This commit mitigates the race condition by ensuring that the relevant map is mutated only once (i.e. via put).

This commit also refactors a number of methods to avoid duplicated code.

There are no tests associated with this change since there's no deterministic way to induce the race condition. It relies on static analysis and existing tests to validate the fix and detect regressions.

@jbertram
Copy link
Contributor Author

The full test-suite is green on this.

Copy link
Member

@brusdev brusdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution is very robust, the only drawback I can find is the possibility of multiple records for the same item when the deletion fails. Those leacked records could be detected/removed when the journal is loaded to mitigate this issue.

@jbertram jbertram force-pushed the ARTEMIS-4197 branch 2 times, most recently from 4c0bfb6 to 5ba24a1 Compare December 15, 2025 16:28
@jbertram
Copy link
Contributor Author

@brusdev, I refactored this a bit to avoid orphaned records.

@jbertram
Copy link
Contributor Author

Full test-suite looks good on this.

@brusdev
Copy link
Member

brusdev commented Dec 16, 2025

@jbertram can you rebase your branch to resolve the conflicts?

This commit mitigates a number of different potential race conditions
involving configuration changes. Consider the storeAddressSetting method
in o.a.a.a.c.p.i.j.AbstractJournalStorageManager. It mutates
mapPersistedAddressSettings twice - once to delete an entry and once to
put an entry. If another thread executes the recoverAddressSettings
method in between these two operations it will not contain the record
that is being stored. This same race condition exists for a number of
different maps.

This commit mitigates the race condition by ensuring that the relevant
map is mutated only once (i.e. via put).

This commit also refactors a number of methods to avoid duplicated code.

There are no tests associated with this change since there's no
deterministic way to induce the race condition. It relies on static
analysis and existing tests to validate the fix and detect regressions.
@jbertram
Copy link
Contributor Author

@brusdev, done!

Copy link
Member

@brusdev brusdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbertram nice work! I'm running the full test suite again just for the sake of safety before merging it.

@brusdev brusdev merged commit fd91f9f into apache:main Dec 16, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants