Skip to content
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

[BUG] Deadlock during synchronization in MutableStore #578

Open
Marcel348 opened this issue Sep 27, 2023 · 0 comments
Open

[BUG] Deadlock during synchronization in MutableStore #578

Marcel348 opened this issue Sep 27, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Marcel348
Copy link

Marcel348 commented Sep 27, 2023

Reproduce:

  1. Make unsuccessful write to store.
    In other words call store.write.
    UpdaterResult returned by post function in Updater should be something like UpdaterResult.Error.Exception(Exception(""))
  2. Adjust Api so that post function in Updater will return UpdaterResult.Success in next calls.
  3. Read data from store
    In other words call store.stream.

Result:
No data will come to flow because deadlock happened during synchronization.

Cause of bug:
Function tryEagerlyResolveConflicts is called in RealMutableStore.
withThreadSafety is called in first line of the function. It calls storeLock.lock() for the first time.
updateWriteRequestQueue is called in the block of withThreadSafety.
Function withWriteRequestQueueLock is called in updateWriteRequestQueue.
withThreadSafety is called in withWriteRequestQueueLock.
It calls storeLock.lock() for the second time in the same thread that causes deadlock.

Example app. Store is used in com/example/dropboxstore/ui/screens/store/StoreViewModel.kt
Store-deadlock.zip

@Marcel348 Marcel348 added the bug Something isn't working label Sep 27, 2023
@Marcel348 Marcel348 changed the title [BUG] Deadlock during synchonization in MutableStore [BUG] Deadlock during synchronization in MutableStore Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🆕 Triage
Development

No branches or pull requests

1 participant