Cannot Aquire Sync Lock

Operating System & Joplin Version

Operating System (desktop): MacOS X El capitan v.10.11.6
Joplin Version: 1.0.242

Issue

Last error: Error: Cannot acquire sync lock: either the lock could be written but not read back. Or it was expired before it was read again.

I am syncing Joplin to Dropbox but came with that error message above.

Hi, I have (kind of) the same problem.

Upgrading the Android App did something to the Notez and sync (partially) does not work anymore.

Android 10 / Joplin1.0.339 < = > sync to Nextcloud OK
Win 7 / Appimage 1.0.242 < = > sync to Nextcloud OK

Arch Linux / Appimage 1.0.242 < = > sync to Nextcloud: " Last error: Error: Cannot acquire sync lock: either the lock could be written but not read back. Or it was expired before it was read again.
"

Do you know if sync is particularly slow on your devices? Normally the lock has a 3 minutes expiration date, so if it takes more than 3 minutes to make a connection this error will happen. Does it happen every time you sync?

Hi laurent,

I looked a little closer to this. As far as I can tell everything works fine on Win10 and Android. Problem is with Linux.

  • the aforementioned error occurs almost instantly after hitting the ‘synchronize’ button.
  • I tried wiping my dot files and re-configuring Joplin with the Nextcloud-path – same
  • I tried using a different (empty) note target on Nextcloud. Joplin fails to sync, this time without error message, but with a sync symbol rotating forever. While other gui elements still work (selecting notes, going to options etc), the cancel button doesn’t. On the storage, it creates a lock file in the locks folder, but nothing else. It fails to upload the 5 welcome example notes.
  • As a test: using local storage as sync destination works fine.

It could mean that the app cannot create the lock file at all. Could you check that there's a lock dir on the sync target?

Hi I checked: there is a lock dir on the Nextcloud target and the app creates a lock file there (exclusive_desktop_…json). I checked whether it is created by this particular Client (shutting down Clients on other machines). Deleting it and re-hitting the sync button gives the same result (file is created, error msg comes up).
Briefly there appears a second file ‘sync_desktop…’ (or similar) which immediately disappears again.

It’s strange that it creates an exclusive lock because that should only be when upgrading the sync target.

When you start the app, what do you see? The upgrade screen or the regular screen (with notebooks and notes)?

Also could you open the database.sqlite file and check what’s the value of sync.upgradeState in the settings table?

I have the similar files created in Dropbox (exclusive_desktop…json). For some reason it stopped showing me the upgrade banner even though the app did not show the “upgrade complete” on my Mac.

Hi again, so it shows the usual notes but no upgrade screen. I am currently using the Appimage, directly placed to a local /bin folder.

In the database file, I could not find a sync.upgradeState field in the settings table. Only some fields like
sync.3.context, sync.7.auth, sync.5.syncTargets, sync.target, sync.5.path, sync.5.username , sync.5.password, sync.5.context

sync target is 5. What may or may not be related is that
‘sync.5.syncTargets’ seems to contain the result of some failed http request(?) '{"https://URLTONEXTCLOUDINSTACE/remote.php/webdav/Notez":{“error”:"Cannot parse JSON: \n<html class=\“ng-csp\” data-placeholder-focus=\“false\” lang=\“en-GB\” data-locale=\“en_GB\” >\n\t< etc.

but something similar also occurs in the database for the WIN10 machine (which works and syncs).

HI, I decided to connect Joplin with OneDrive instead to see if it was because I was messing with Dropbox. Joplin on my Ipad pro synced to OneDrive with no issues, however when I tried it on my MacOS X Capitan v.10.11.6, the same error message appears (Joplin v.1.0.242).

Hi,

I hope the this entry is related to the same issue. I have just upgraded Joplin desktop version to 1.0.242 in Windows 10 and a after a few seconds an orange banner appears at the top with the following text:

The sync target needs to be upgraded before Joplin can sync. The operation may take a few minutes to complete and the app needs to be restarted. To proceed please click on the link. Restart and upgrade

When clicking on the link "restart and upgrade" (I cannot see what the address is), a Joplin window appears with the following text:

Joplin upgrade in progress...
Please wait while the sync target is being upgraded. It may take a few seconds or a few minutes depending on the upgrade. The application will automatically restart once it is completed.

Nothing else appears to happen. I use dropbox to sync the notes. If I can be helpful on getting additional information, please let me know.

Okay, maybe some additional piece of information. I observed some different behavior, this time no error message but still sync does not seem to work.

Linux/Appimage 1.0.242: I wiped the settings folder again, starting fresh. For synchronization, I enter an empty folder on Nextcloud. The “check synchronization configuration” button works, gives positive result ("…appears to be correct").

Joplin starts synchronization: makes a folder called “locks” on the Nextcloud. The synchronization indicator keeps spinning. It creates an "exclusive_desktop_…json file. What I didn’t notice before is that this file is uploaded again and again in a loop (about 10 times in a minute).

Sync cancel button doesn’t work.

Killing the application and restarting shows the notes. When pushing the sync button, it starts uploading the exclusive_desktop file again and again. This time no error message occurs (at least for ~15 minutes), but syncing is also not done.

@xmhk, how does the “exclusive_desktop_…json” file look? Normally it should be “exclusive_desktop_CLIENTID.json” where “CLIENTID” is a 32 characters hexadecimal string. Is that what you have?

What does the Nextcloud access log say? Are there any failing POST or GET requests for this “exclusive_desktop_…json” file?

The only way your issue could happen is if the app can write the lock file but when it tries to get it back, it gets something different, which means it tries again to create it. Maybe it’s 31 characters instead of 32 or some strange behaviour like this.

In fact perhaps I could replicate the bug if I could access your server. Is there any chance you could create a test user on it (you could PM me the identifiers)?

Yes the exclusive_desktop… has the format you described, with 32 characters for the client ID in the filename.

For the Nextcloud instance, I am only a user, it’s not me controlling the instance. This is why I cannot access the logs, at least as far as I can see there is nothing like that visible from the web interface.
Actually I tried a second, different instance (also not mine) there it’s exactly the same.

If it helps, one of my accounts is at https://cloud.tab.digital/ , they also offer a free 8 GB account for their Nextcloud instance.

Maybe if somebody else reading here has some Nextcloud instance he or she could temporarily give me a user account, I am happy to help with further tests.

I have the same problem with the appimage 1.0.242 on Linux OpenSuSE. Im syncing the database over WebDAV.

I am having the same Sync lock error on Android <> dropbox.

My mac syncs ok with Joplin. Even my Android phone syncs fine. But my Android tablet gets this error:

Last error: Error: Cannot acquire sync lock: either the lock could be written but not read back. Or it was expired before it was read again.

1 Like

Hi, I checked whether it works with Dropbox, so I created an account. Behavior for 1.0.242 on Linux is similar as described for Nextcloud above

Joplin starts synchronization: makes a folder called “locks” on the Nextcloud. Dropbox The synchronization indicator keeps spinning. It creates an "exclusive_desktop_…json file.

I can not see different versions of the file as in Nextcloud (maybe Dropbox recognizes it’s the very same content), but Joplin keeps sending and receiving data (now for ~15 Minutes) constantly. nethogs shows in this time it send about 2 MB and also received 2 MB of data

Sync cancel button doesn’t work (as before)

Killing the application and restarting shows the notes. When pushing the sync button, same behavior as before (sync indicator spins, Joplin sends and receives data.

In your test with Dropbox, did you start from a new profile or an existing one? If you start from an existing one, could you open the status screen and let me know how many notes, folders, tags, etc the profile has?

By the way did you use e2ee?

Sorry for all the questions but if I can replicate the issue I can definitely fix it, but so far I haven’t managed.

Also could you check your system time and compare it to the real time? https://time.gov/ Is it the exact same time? I’m just thinking that having the system time off by a few minutes might cause this bug.

Yes that’s it, I can replicate by setting the clock a few minutes ahead, so that might be your issue too.