Closed arun1ram closed 1 year ago
@arun1ram, thanks for the report.
You mention:
When 2 or more threads (or in a distributed environment - 2 or more instances) are invoking the JdbcMutableAclService#updateAcl() method concurrently, one of the threads succeeds but others fail with DeadlockLoserDataAccessException
and:
I expect that an ACL will be created if it does not already exist and the ACL entries (corresponding to the permissions) are added successfully.
but these statements seem to contradict each other (since your first statement indicates the operation is still successful)? Further you haven't provided enough information or a detailed enough sample to reproduce the behavior. Additionally, the behavior you're describing could be database vendor specific.
In order to proceed, it would be very helpful for you to provide more information (database vendor, additional error details) and a complete minimal sample that allows reproducing the issue with an available open source database and minimal setup. Are you able to provide this? Also, do you have a specific recommendation for how to resolve the issue?
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
@sjohnr Thanks for your response. The statements are not contradictory because they are referring to what happens to the 2 threads (or instances in a distributed environment). The first thread succeeds and the second one fails. My expectation is that both threads will succeed. I am using MySQL as the backend database. This contains all the ACL related tables. I do have a reproducer that illustrates this problem. I need a few days to remove proprietary code from it. I can then share it with you.
@sjohnr Please note that I have now added error details to the issue.
@arun1ram I have reviewed your database logs and do not see enough information to determine anything new, and you have not provided a minimal sample. As I mentioned, your description of the problem states that you expect the ACL to be created, and it appears that does happen. The deadlock that occurs in your code is related to your concurrent attempt to do so on two threads, and is not in the framework's control.
The MutableAclService
exposes two operations that you are using, createAcl
and updateAcl
. My suggestion would be to wrap the update/create operation in a transaction to see if that resolves the issue. If that doesn't work, you can also add exception handling to your code and log and/or ignore the deadlock exception thrown by the MySQL driver.
I don't see anything that the JdbcMutableAclService
implementation can do to prevent your error, other than swallowing exceptions which I don't believe the framework should do. I'm going to close this issue for now. If you have additional thoughts as to what you believe the framework is doing incorrectly (aside from propagating exceptions, which I believe is correct) let me know. If you have suggestions for how the docs could be updated to better reflect correct usage of the JdbcMutableAclService
(such as transaction and error handling), that would be great too.
Describe the bug When 2 or more threads (or in a distributed environment - 2 or more instances) are invoking the JdbcMutableAclService#updateAcl() method concurrently, one of the threads succeeds but others fail with DeadlockLoserDataAccessException
To Reproduce
Expected behavior I expect that an ACL will be created if it does not already exist and the ACL entries (corresponding to the permissions) are added successfully.
Sample The following is the stacktrace of the error for the thread that fails. (The other thread is successful):
Following the is MySQL show engine innodb status command output:
A link to a GitHub repository with a minimal, reproducible sample.