-
Notifications
You must be signed in to change notification settings - Fork 300
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
FISH-6291 Fix Data Synchronization Issue in a @Clustered @Singleton #6302
Conversation
…ingleton When @clustered @singleton service was executed from different threads, the initialization created new instances.
Signed-off-by: Andrew Pielage <pandrex247@hotmail.com>
Signed-off-by: Andrew Pielage <pandrex247@hotmail.com>
Signed-off-by: Andrew Pielage <pandrex247@hotmail.com>
Jenkins test please |
have you looked at CDI version? Does that work correctly? Otherwise LGTM, good job! |
Looks like the CDI version is susceptible to the same issue. See Pandrex247#4 |
updated CDI version of clustered singletons
@lprimak Test executedApplicationScoped Bean
REST endpoint
Deployment Group test utilising standard Managed Executor
|
Remove static imports, move methods, and add explanative comment Signed-off-by: Andrew Pielage <pandrex247@hotmail.com>
Signed-off-by: Andrew Pielage <pandrex247@hotmail.com>
Jenkins test please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, went carefully thought the code, discussed...
Thanks for the explanatory comments, @Pandrex247!
LGTM
Description
Fixes the concurrent synchronisation issue with clustered singletons by applying the lock at the point of reading from Hazelcast, rather than at the point of executing the method.
Without this change multiple threads would read the singleton state from Hazelcast at the same time, and then lock/wait for the lock to release. This means that when the lock is released and they proceed with their own execution they won't have received the updates that any other execution on another thread will have written to Hazelcast.
The lock on reading from Hazelcast should still retain respect for definition of
@AccessTimeout
s on methods to prevent it locking indefinitely.@lprimak if you're hovering about I know clustered singletons are your baby 😜
Important Info
Dependant PRs
None
Blockers
None
Testing
New tests
None
Testing Performed
Ran Petr's reproducer attached to the Jira issue (adjusted for Jakarta EE 10 and Java 11) on a single instance, adjusted with my own logging and so that it only removes 6 items per invocation. I also added a call for it to print out what it locally sees the sequence as in the browser.
RestResource.java
SingletonClusteredEJB.java
Test 1 - DAS Default Config
[6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
[12, 13, 14, 15, 16, 17, 18, 19]
Test 2 - Deployment Group - Non-standard Executor
[12, 13, 14, 15, 16, 17, 18, 19]
Test 3 - Deployment Group - Non-standard Executor with AccessTimeout
@AccessTimeout(2000)
to thehello
method[3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
(or something similar - it might also manage to remove the3
, but the result on both instances should be the same)Testing Environment
Windows 11, Zulu 11.0.19
Documentation
N/A
Notes for Reviewers
When I was testing, I dropped in Hazelcast 5.3.0 rather than the 5.2.2 still defined in the pom - this fixes the NPEs that get spammed from Hazelcast.
I left Bean Managed Concurrency alone. It should not lock on this and therefore the concurrency exceptions will still be present. I understood the spec description of BMC to mean that a user would need to order and control concurrent access rather than us.