A deadlock will occur if we try to close the last Realm instance while inside a manual client reset block.
When we receive a sync error we acquire a lock on the Sync instance, while locked we are required to close all open Realm instances. This last instance would try to close the sync session, but it needs to acquire the lock that was previously acquired by the sync error logic.
It was not captured in our tests because the simulated sync error method did not simulate that the error came from a different thread than the one being executed.
This PR addresses this issue by not acquiring the lock on client reset errors.
Closes https://github.com/realm/realm-java/issues/7691
A deadlock will occur if we try to close the last Realm instance while inside a manual client reset block.
When we receive a sync error we acquire a lock on the
Sync
instance, while locked we are required to close all open Realm instances. This last instance would try to close the sync session, but it needs to acquire the lock that was previously acquired by the sync error logic.It was not captured in our tests because the simulated sync error method did not simulate that the error came from a different thread than the one being executed.
This PR addresses this issue by not acquiring the lock on client reset errors.