Check if the read lock is held before exiting
Check if the read lock is held before exiting.
@huyhu Does this actually fix your use case? Do you have any tests for this PR? I'm worried this PR only masks an underlying issue (why did the transaction try to release a lock that it didn't hold in the first place?)
I would agree it is important to find the underlying cause of the issue, however, adding this check does stop a fatal exception that takes down an application. I, too, have encountered this error several times in the past few months, and I have not been able to isolate it to anything in particular. (I am using the mutex locking scheme--ie. direct--with async tasks, request the least permission necessary for db activity, and wait retries where applicable).
Perhaps adding -- if (held) {remove} / else {log} -- type of solution would suffice without reviewing all the locking logic and retaining this bug.