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

Android sync gets permanently stuck whilst seemingly doing nothing #8402

Open
robme opened this issue Jun 30, 2023 · 28 comments
Open

Android sync gets permanently stuck whilst seemingly doing nothing #8402

robme opened this issue Jun 30, 2023 · 28 comments
Labels
backlog We'll get to it... eventually... bug It's a bug sync sync related issue

Comments

@robme
Copy link

robme commented Jun 30, 2023

I'm splitting this from #8123 since it is a different issue.

This is a long-term issue going on for years described elsewhere on the internet e.g.

Environment

Joplin version: 2.11.31
Platform: Android 13
OS specifics: using Dropbox as sync mechanism, encryption enabled

Steps to reproduce

This happens randomly, so I don't know the exact cause.

  1. Open Android app.
  2. Use biometrics (fingerprint) to unlock.
  3. Joplin immediately begins a sync.
  4. Joplin stays syncing forever without showing anything other than the spinner animation.
  5. If you press 'Cancel' then it shows 'Cancelling...' forever.
  6. Force close the app.
  7. Open the app again and use fingerprint to unlock.
  8. Problem repeats from step 3.

It will continue like this forever. The only way to resolve it is to force it to get locked out by repeatedly force closing the app and opening it whilst also syncing on another device. This isn't always easy because if there is nothing to sync on desktop then it's very quick, so you have to get the timing just right to cause it to lock. After being locked out, it will regain the ability to sync.

Describe what you expected to happen

It should always be able to sync. The app is essentially unusable when this happens almost every day. I don't always have the ability to get to a computer to do the fix.

Logfile

Screenshot_20230630-194313

Screenshot_20230630-194412

@robme robme added the bug It's a bug label Jun 30, 2023
@kalvn
Copy link

kalvn commented Jul 7, 2023

Same here, except it never worked.

@joao-alemao
Copy link

I am also experiencing this issue for a while now and was looking for solutions. The syncing on the mobile app gets stuck indefinitely up until an error "Cannot acquire exclusive lock because the following clients have a sync lock on the target" appears. Do not know why this happens as no other device is syncing.

My sync target is Dropbox. This only happens on the android app.

joplin_log

@github-actions
Copy link
Contributor

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? If you require support or are requesting an enhancement or feature then please create a topic on the Joplin forum. This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

@github-actions github-actions bot added the stale An issue that hasn't been active for a while... label Aug 22, 2023
@joao-alemao
Copy link

Update: the issue is still present, fix seems to be going on desktop app and manually triggering sync, syncing on android app then works.

@github-actions github-actions bot removed the stale An issue that hasn't been active for a while... label Aug 23, 2023
@robme
Copy link
Author

robme commented Aug 30, 2023

This is so frustrating. It seems like it's not even syncing, it just gets stuck doing nothing, but saying it's syncing. From checking the log, it doesn't appear to be trying to sync.

The only way to make it realise that it isn't syncing is to force the lock to happen, as described before.

One thing I've noticed is sometimes after a successful sync it will immediately say "Syncing" again, could be related?

@npike
Copy link

npike commented Sep 1, 2023

Same issue on Android 13 syncing to dropbox...

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? If you require support or are requesting an enhancement or feature then please create a topic on the Joplin forum. This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

@github-actions github-actions bot added the stale An issue that hasn't been active for a while... label Oct 2, 2023
@robme
Copy link
Author

robme commented Oct 3, 2023

Still a problem.

@github-actions github-actions bot removed the stale An issue that hasn't been active for a while... label Oct 3, 2023
Copy link
Contributor

github-actions bot commented Nov 2, 2023

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? If you require support or are requesting an enhancement or feature then please create a topic on the Joplin forum. This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

@github-actions github-actions bot added the stale An issue that hasn't been active for a while... label Nov 2, 2023
@robme
Copy link
Author

robme commented Nov 2, 2023

No it hasn't magically fixed itself.

@github-actions github-actions bot removed the stale An issue that hasn't been active for a while... label Nov 3, 2023
@e3roll
Copy link

e3roll commented Nov 16, 2023

Hi, please prioritize this bug.
This is happening on my Android device for almost a year. There's no error on the logs. Also, this is happening with no lock (biometrics).
The only way was to do the workaround in this comment.
But now that workaround does not even work. I do the following:

  1. Disconnect wifi and mobile data on mobile.
  2. Start mobile app.
  3. Sync mobile.
  4. Wait until it says it has finished.
  5. Connect wifi or mobile data.
  6. Open desktop app.
  7. Now add a change on a note on desktop app.
  8. Sync desktop and sync mobile at the same time.
  9. Sync error on mobile is shown.
  10. Sync again on mobile.

This is very frustrating and it happens every time you try to sync. Before it was once in while.

Mobile:

  • OS: Android 13
  • App version: 2.12.3

Desktop:

  • OS: Ventura 13.1
  • Version: Joplin 2.12.18 (prod, darwin)
  • Client ID: 51ae27048a4a4062b24b9653a13bc341
  • Sync Version: 3
  • Profile Version: 43
  • Keychain Supported: Yes
  • Revision: a0a4a81

Server: dropbox

@opqriu
Copy link

opqriu commented Dec 1, 2023

Don't connect Dropbox directly from Joplin Android.
In my experience... Using an app like Dropsync will solve this problem.

https://discourse.joplinapp.org/t/i-solved-android-stopped-syncing/33988?u=ranicloudy

@graphit0
Copy link

graphit0 commented Dec 1, 2023

Trying to trace down how to reproduce the behaviour here. I have a suspicion that the behaviour is caused by syncing mobile client with unresolved conflicts. Can anyone confirm or deny?

@robme
Copy link
Author

robme commented Dec 11, 2023

I think it happens to me regardless of if there are conflicts.

Copy link
Contributor

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? If you require support or are requesting an enhancement or feature then please create a topic on the Joplin forum. This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

@github-actions github-actions bot added the stale An issue that hasn't been active for a while... label Jan 11, 2024
@kenden
Copy link

kenden commented Jan 11, 2024

This is still an issue. I still have to do often the workaround from https://www.reddit.com/r/joplinapp/comments/p9pqsh/comment/j5yqje8/

  1. Make sure android app is trying to sync.
  2. On laptop make sure there is something to sync. Then make any change add space etc.
  3. Start sync on the laptop.
    This will result in error on Android something like: 'other device is syncing/cannot get exclusive lock's
    Now android is in normal non-syncing state.
  4. Start syncing again on Android. Syncing should start working again.

@npike
Copy link

npike commented Jan 11, 2024 via email

@personalizedrefrigerator personalizedrefrigerator added sync sync related issue and removed stale An issue that hasn't been active for a while... labels Jan 12, 2024
@personalizedrefrigerator
Copy link
Collaborator

personalizedrefrigerator commented Jan 12, 2024

If the error mentions a sync lock, this is another possible workaround (originally written for OneDrive, but should also apply to Dropbox):

Posted by @personalizedrefrigerator:

This can happen if one Joplin client is still syncing (or was closed during a sync). Re-opening and re-syncing the client that was interrupted may fix the issue.

If this was caused by a Joplin client that no longer exists (e.g. was uninstalled), you can try the following:

  1. Make a backup
  2. Delete files from Apps/Joplin/locks on OneDrive

https://discord.com/channels/610762468960239627/610762468960239629/1184518156123906209

Additionally:

Posted by @laurent22:

To add up to this, the locks expire so if you wait a few minutes it should start working again

https://discord.com/channels/610762468960239627/610762468960239629/1184530213045014558

But from the comments above, the issue doesn't seem to resolve after a few minutes... If deleting the lock file helps, there may be a bug in lock file expiration.

@graphit0
Copy link

graphit0 commented Jan 12, 2024

@personalizedrefrigerator thank you. This workaround just worked for me.

The issue does seem to have something to do with lock expiration since behaviour persists seemingly indefinitely

Any tip how can one track down the process for lock to fail to expire?

I have a feeling (based on what people stated in the past related to the issue) it happens during the desktop update on new version (from 2.12 to 2.13, from 2.13 to 2.14 etc) but mobile app stays on previous version. I'll try testing this hypothesis with various parameters but at this point I'm as good as blind guessing.


Upd this hypothesis was wrong

@personalizedrefrigerator personalizedrefrigerator added the high High priority issues label Feb 3, 2024
@fellipec
Copy link

I just got in the same situation, phone stopped sync couple of days ago.

There is no error message, just stuck in syncing or cancelling if you try.

Resolved by deleting the files locks directory.

@robme
Copy link
Author

robme commented Mar 1, 2024

I have now had it happen in the Desktop app (Windows)! It just appeared to be syncing forever, and couldn't be cancelled. Then I remembered this bug, and the same fix worked but in reverse. I opened the Android app and told it to sync, then the desktop app got locked out of sync, and then it was able to sync afterwards.

@joao-alemao
Copy link

@laurent22 seems like this could be a candidate for a deeper look? Seems that the lock simply isn't released or that the behavior to nuke the /locks files could be defaulted to?
I don't mind taking a look but would need some pointers on where to turn my attention to, to be able to identify the root cause.

@roman-r-m
Copy link
Collaborator

I don't mind taking a look but would need some pointers on where to turn my attention to, to be able to identify the root cause.

Perhaps here: https://github.com/laurent22/joplin/blob/dev/packages/lib/services/synchronizer/LockHandler.ts#L136

@slimygorilla72
Copy link

slimygorilla72 commented Mar 24, 2024

I feel like this post (that I made) may have some useful info:
https://discourse.joplinapp.org/t/i-solved-android-stopped-syncing-dropbox/33988/8?u=giantchain67

In short, there may be stale files in joplin's sync location (in my case dropbox)
In this directory: Apps\Joplin\Locks
These may need to be cleared out, the android client is not happy with them (perhaps gets in an unhandled loop / error state)

@laurent22 laurent22 added backlog We'll get to it... eventually... and removed high High priority issues labels Apr 15, 2024
@RyanChimienti
Copy link

I have now had it happen in the Desktop app (Windows)! It just appeared to be syncing forever, and couldn't be cancelled. Then I remembered this bug, and the same fix worked but in reverse. I opened the Android app and told it to sync, then the desktop app got locked out of sync, and then it was able to sync afterwards.

@robme same issue here. I'm using Windows + Android + Dropbox, and the sync was hanging on Windows. The "reverse" fix did the trick for me--thanks!

@flumpis
Copy link

flumpis commented Oct 11, 2024

In short, there may be stale files in joplin's sync location (in my case dropbox) In this directory: Apps\Joplin\Locks These may need to be cleared out, the android client is not happy with them (perhaps gets in an unhandled loop / error state)

@slimygorilla72, thank you for sharing this as a clue as I am using Dropbox as my sync destination. (I am NOT using Dropsync.)

I had this issue yesterday (10/10/2024) on my Android phone, which I resolved by manually re-setting up sync on the device. I had this same issue today on a different Android device (Boox tablet) after using Joplin and syncing without issues on my phone, Windows, and Mac devices. After getting stuck in the endless sync loop on my Boox tablet, I made sure to quit out of any open instances of Joplin across all devices, but the issue persisted. I then opened Joplin on Mac and experienced the same behavior (but on my Android phone, it appeared that sync was working fine).

To cut to the chase, I checked Dropbox\Apps\Joplin\locks and saw I had FIVE lockfiles in place, one of which had a modified date of 10/10/2024 (yesterday's date). The other four locks were from dates in 2021, 2022, and 2023. I closed Joplin on all my devices, trashed all the lockfiles, and tried sync again from my Boox tablet. Lo and behold, sync started running! It has since finished and my \locks folder is now empty.

Not sure why those lockfiles had stuck around, but they didn't seem to be getting in the way. However, they could be clues to uncovering the root cause of this issue.

@personalizedrefrigerator
Copy link
Collaborator

To cut to the chase, I checked Dropbox\Apps\Joplin\locks and saw I had FIVE lockfiles in place, one of which had a modified date of 10/10/2024 (yesterday's date).

Possibly related: #11188 — sync state was not being reset to idle if an error occurred while removing sync locks.

@flumpis
Copy link

flumpis commented Oct 11, 2024

Thanks for the link to your work @personalizedrefrigerator, I would guess what observed is caused by what you are fixing. I wish I had a more exact idea of what I did around the time that latest lockfile was modified on 10/10 to be certain, but I suppose if your updates don't fix it (unlikely), I can troubleshoot again.

I don't understand all of the code you wrote but from what I can understand, the sync function looks more robust and resilient now - great work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog We'll get to it... eventually... bug It's a bug sync sync related issue
Projects
None yet
Development

No branches or pull requests