Skip to content

Nextcloud File Locking gets out of sync #1940

Open

Description

@schemil053

Sometimes the nextcloud android app break and fails to sync a note. Only opening the file in the browser and closing it again resolves it

Steps to reproduce

This issue is not 100% reproducible every time, but I found it using that way:

  1. Use Android app to edit notes
  2. Edit the file with the website again (after closing the android app)
  3. Use the Android app again to edit again

Expected behaviour

The app syncs fine

Actual behaviour

The Server logs an error (attached below)

And the notes app shows an error that is not able to sync. Only if you go to the website, open and close the note, the sync works again

Server

  • Notes app version: 6.0.1
  • Nextcloud version: 34.0.1
  • OS: Debian/LXC
  • Web server: apache2 2.4.68-1~deb13u1
  • PHP version: 8.4.23
  • Database: mariadb

Nextcloud is ran behind an apache proxy server

Client

  • Browser (incl. version): Firefox ESR 140.12.0
    • OS: Debian Trixie with Wayland

The other Client is Android 16 using the latest available version of the notes android app

Log files

{
  "reqId": "REDACTED",
  "level": 3,
  "time": "2026-07-17T04:12:11+00:00",
  "remoteAddr": "REDACTED",
  "user": "REDACTED",
  "app": "notes",
  "method": "PUT",
  "url": "/index.php/apps/notes/api/v1/notes/23228?",
  "scriptName": "/index.php",
  "message": "Controller failed with OCP\\Lock\\ManuallyLockedException",
  "userAgent": "Mozilla/5.0 (Android) Nextcloud-android/34.0.1",
  "version": "34.0.1.2",
  "exception": {
    "Exception": "OCP\\Lock\\ManuallyLockedException",
    "Message": "\"files/Notizen/Privat/Todo.md\" is locked, existing lock on file: files_lock/1ed743bc-1034-40ef-9711-3a5ab33e994c",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/apps/files_lock/lib/Storage/LockWrapper.php",
        "line": 213,
        "function": "checkPermissions",
        "class": "OCA\\FilesLock\\Storage\\LockWrapper",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php",
        "line": 150,
        "function": "file_put_contents",
        "class": "OCA\\FilesLock\\Storage\\LockWrapper",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 1235,
        "function": "file_put_contents",
        "class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 680,
        "function": "basicOperation",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Node/File.php",
        "line": 56,
        "function": "file_put_contents",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/notes/lib/Service/Note.php",
        "line": 174,
        "function": "putContent",
        "class": "OC\\Files\\Node\\File",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/notes/lib/Controller/NotesApiController.php",
        "line": 174,
        "function": "setContent",
        "class": "OCA\\Notes\\Service\\Note",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/notes/lib/Service/Util.php",
        "line": 25,
        "function": "{closure:OCA\\Notes\\Controller\\NotesApiController::update():164}",
        "class": "OCA\\Notes\\Controller\\NotesApiController",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/notes/lib/Controller/Helper.php",
        "line": 135,
        "function": "retryIfLocked",
        "class": "OCA\\Notes\\Service\\Util",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/apps/notes/lib/Controller/NotesApiController.php",
        "line": 164,
        "function": "handleErrorResponse",
        "class": "OCA\\Notes\\Controller\\Helper",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 165,
        "function": "update",
        "class": "OCA\\Notes\\Controller\\NotesApiController",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 78,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
        "line": 137,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Route/Router.php",
        "line": 324,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/base.php",
        "line": 1159,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/index.php",
        "line": 25,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/nextcloud/apps/files_lock/lib/Storage/LockWrapper.php",
    "Line": 82,
    "message": "Controller failed with OCP\\Lock\\ManuallyLockedException",
    "exception": "{\"class\":\"OCP\\Lock\\ManuallyLockedException\",\"message\":\"\\\"files/Notizen/Privat/Todo.md\\\" is locked, existing lock on file: files_lock/1ed743bc-1034-40ef-9711-3a5ab33e994c\",\"code\":0,\"file\":\"/var/www/nextcloud/apps/files_lock/lib/Storage/LockWrapper.php:82\",\"trace\":\"#0 /var/www/nextcloud/apps/files_lock/lib/Storage/LockWrapper.php(213): OCA\\FilesLock\\Storage\\LockWrapper->checkPermissions()\\n#1 /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(150): OCA\\FilesLock\\Storage\\LockWrapper->file_put_contents()\\n#2 /var/www/nextcloud/lib/private/Files/View.php(1235): OC\\Files\\Storage\\Wrapper\\Wrapper->file_put_contents()\\n#3 /var/www/nextcloud/lib/private/Files/View.php(680): OC\\Files\\View->basicOperation()\\n#4 /var/www/nextcloud/lib/private/Files/Node/File.php(56): OC\\Files\\View->file_put_contents()\\n#5 /var/www/nextcloud/apps/notes/lib/Service/Note.php(174): OC\\Files\\Node\\File->putContent()\\n#6 /var/www/nextcloud/apps/notes/lib/Controller/NotesApiController.php(174): OCA\\Notes\\Service\\Note->setContent()\\n#7 /var/www/nextcloud/apps/notes/lib/Service/Util.php(25): OCA\\Notes\\Controller\\NotesApiController->{closure:OCA\\Notes\\Controller\\NotesApiController::update():164}()\\n#8 /var/www/nextcloud/apps/notes/lib/Controller/Helper.php(135): OCA\\Notes\\Service\\Util::retryIfLocked()\\n#9 /var/www/nextcloud/apps/notes/lib/Controller/NotesApiController.php(164): OCA\\Notes\\Controller\\Helper->handleErrorResponse()\\n#10 /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(165): OCA\\Notes\\Controller\\NotesApiController->update()\\n#11 /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(78): OC\\AppFramework\\Http\\Dispatcher->executeController()\\n#12 /var/www/nextcloud/lib/private/AppFramework/App.php(137): OC\\AppFramework\\Http\\Dispatcher->dispatch()\\n#13 /var/www/nextcloud/lib/private/Route/Router.php(324): OC\\AppFramework\\App::main()\\n#14 /var/www/nextcloud/lib/base.php(1159): OC\\Route\\Router->match()\\n#15 /var/www/nextcloud/index.php(25): OC::handleRequest()\\n#16 {main}\"}",
    "CustomMessage": "Controller failed with OCP\\Lock\\ManuallyLockedException"
  },
  "id": "REDACTED"
}

Activity

  1. schemil053 commented on Jul 18, 2026

    @schemil053
    Author
  2. spintike commented on Jul 20, 2026

    @spintike

    Same issue here with nearly the same parameters (versions etc.) and checking the server log.

  3. thmsaurel commented on Jul 23, 2026

    @thmsaurel

    I have the same issue using mostly a text editor with local synchronization.
    The issue seems related to the web editior.

  4. heapifyman commented on Jul 23, 2026

    @heapifyman

    I noticed that the notes file (.md) is marked as locked in the Nextcloud Files App

    Image

    after it was edited in the Nextcloud Notes App (web app).

    Afterwards the Nextcloud Notes App (Android) was not able to sync the note anymore with the exception mentioned above.

    This seems to happen only if the Notes App (web) is set to use "Rich Text".

    Image

    The file does not get locked when selecting "Plain text" or "Preview"

  5. robsteady commented on Jul 25, 2026

    @robsteady

    Thank you, @heapifyman ! This has been driving me insane. I even set up a Joplin server and started using that because I could not find a fix. I switched the Notes app to Plain text and now everything works as expected again.

  6. MegaV0lt commented on Jul 26, 2026

    @MegaV0lt

    I get also sync error in app

    App Version: 34.0.0
    App Version Code: 340000090
    App Flavor: fdroid
    
    Files App Version Code: 340000190 (PROD)
    
    ---
    
    OS Version: 6.1.138-android14-11-g6ab8c9a86a33-ab14396278(OS3.0.302.0.WNNEUXM)
    OS API Level: 36
    Device: rothko
    Manufacturer: Xiaomi
    Model (and Product): 2407FPN8EG (rothko_eea)
    
    ---
    
    java.lang.Exception: {"errorType":"OCP\\Lock\\ManuallyLockedException"}
    [com.nextcloud.android.sso.InputStreamBinder.processRequestV2(InputStreamBinder.java:440), com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestAndBodyStreamV2(InputStreamBinder.java:113), com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestV2(InputStreamBinder.java:96), com.nextcloud.android.sso.aidl.IInputStreamService$Stub.onTransact(IInputStreamService.java:112), android.os.Binder.execTransactInternal(Binder.java:1428), android.os.Binder.execTransact(Binder.java:1372)]
    	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.pushLocalChanges(NotesServerSyncTask.java:150)
    	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.run(NotesServerSyncTask.java:99)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:520)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:328)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1100)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:1572)
    
    
    java.lang.Exception: {"errorType":"OCP\\Lock\\ManuallyLockedException"}
    [com.nextcloud.android.sso.InputStreamBinder.processRequestV2(InputStreamBinder.java:440), com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestAndBodyStreamV2(InputStreamBinder.java:113), com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestV2(InputStreamBinder.java:96), com.nextcloud.android.sso.aidl.IInputStreamService$Stub.onTransact(IInputStreamService.java:112), android.os.Binder.execTransactInternal(Binder.java:1428), android.os.Binder.execTransact(Binder.java:1372)]
    	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.pushLocalChanges(NotesServerSyncTask.java:150)
    	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.run(NotesServerSyncTask.java:99)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:520)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:328)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1100)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:1572)
    
    
  7. larwood commented on Aug 20, 2026

    @larwood

    This is still an issue in Notes 6.0.2

  8. eziocangialosi commented on Aug 27, 2026

    @eziocangialosi

    I got the exactly same issue

    App Version: 34.0.1
    App Version Code: 340000190
    App Flavor: fdroid
    
    Files App Version Code: 340010090 (PROD)
    
    ---
    
    OS Version: 6.1.129-android14-11-gbb141a09b4e0-ab13735664(1786759659)
    OS API Level: 36
    Device: FP6
    Manufacturer: Fairphone
    Model (and Product): Fairphone 6 (lineage_FP6)
    
    ---
    
    java.lang.Exception: {"errorType":"Exception"}
    [com.nextcloud.android.sso.InputStreamBinder.processRequestV2(InputStreamBinder.java:440), com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestAndBodyStreamV2(InputStreamBinder.java:113), com.nextcloud.android.sso.InputStreamBinder.performNextcloudRequestV2(InputStreamBinder.java:96), com.nextcloud.android.sso.aidl.IInputStreamService$Stub.onTransact(IInputStreamService.java:112), android.os.Binder.execTransactInternal(Binder.java:1421), android.os.Binder.execTransact(Binder.java:1365)]
    	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.pushLocalChanges(NotesServerSyncTask.java:150)
    	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.run(NotesServerSyncTask.java:99)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:524)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:317)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651)
    	at java.lang.Thread.run(Thread.java:1119)
    
    

    The issue disappear when I switch the Display mode from "Rich text" to "Plain text" in the webapp as saying @heapifyman just upward.

    As everyone here i got the "file lock" error in the server logs (Nextcloud Hub 26 Spring 34.0.2 with Notes 6.0.2)

  9. eziocangialosi commented on Aug 28, 2026

    @eziocangialosi

    A workaround appears possible: undo the change made in the Android app (to revert to a version matching the one in the web app). Deselect the note in the web app, then re-apply the change in the Android app; synchronization should then be possible.

    Note that the note file appears to be locked as long as the note is selected in the web app (even if the changes have already been applied).
    If a change is made in the Android app while the note is selected (and thus locked) in the web app, a ManuallyLockedException will be thrown until the Android app matches the version existing on the server.

  10. larwood commented on Sep 15, 2026

    @larwood

    This is still an issue in Notes 6.1.0

  11. cheywood commented on Sep 16, 2026

    @cheywood
    Contributor

    Behaviour seen with Notes 6.1.0:

    1. Open note in web Notes rich text editor using Firefox-based browser (Zen)
    2. Close tab in browser
    3. Make change to note in API consumer (Iotas)
    4. See attempt to push that note's changes via API fail due to note being locked (423 status code)
  12. JL710 commented on Sep 27, 2026

    @JL710

    I updated my nextcloud aio yesterday to 34.0.4 and notice this issue since then with the latest app version 35.0.0.

    A workaround that somewhat works for me is the one from @eziocangialosi. As long as there is no open browser tab with the note open, the sync works (again). As soon as that is not the case, the note seems unable to push.

  13. sallyhaj commented on Oct 1, 2026

    @sallyhaj

    I have similar issue:

    • Versions: Nextcloud server 35.0.0.10, files_lock 35.0.0, Notes Android 35.0.0.
    • Steps: edit a note in the web editor, close the tab, then sync an Android device that has its own
      unsent edit to the same note.
    • Result: PUT /apps/notes/api/v1/notes/<id> returns 423 with OCP\Lock\ManuallyLockedException, and the
      app only shows {"errorType":"Exception"}.
    • Workarounds: occ text:reset <fileId> clears it at once. Setting files_lock lock_timeout to 30 makes
      the lock expire by itself, but the device still fails for up to 30 minutes.
  14. staticdev commented on Oct 5, 2026

    @staticdev

    I have same issue after upgrading to NC 35.0.1, notes 6.1.0 and I use as well the android app on version 35.0.0.

    A short workaround I found for those suffering with this: nextcloud-occ files:lock --unlock <NOTE_ID> <YOUR_NEXTCLOUD_USERNAME>

  15. melo0187 commented on Oct 14, 2026

    @melo0187

    16. I have same issue after upgrading to NC 35.0.1, notes 6.1.0 and I use as well the android app on version 35.0.0.
    A short workaround I found for those suffering with this: nextcloud-occ files:lock --unlock <NOTE_ID> <YOUR_NEXTCLOUD_USERNAME>

    I even went this far: occ app:disable files_lock
    Funny enough things work better now in my humble opinion. If the web UI encounters a conflict it makes it very clear and easily resolvable.

  16. sallyhaj commented on Oct 15, 2026

    @sallyhaj

    Note: This comment with the help of AI:
    Some more findings since my last comment (Notes 6.1.0, Text 9.0.0, files_lock 35.0.0, Notes Android 35.0.0):

    • The root cause is in Text: nextcloud/text#9042. The web rich editor takes a files_lock lock (owner Text) when it opens the note. The lock leaks when the editor goes away without calling /close.
      files_lock lock_timeout defaults to -1, so the leaked lock never expires.
    • Reproduced again today from the access log: web Notes opened the note (PUT /apps/text/session/<id>/create), synced for about a minute, then stopped without ever sending /close.
      The lock stayed.
    • The same phone can edit the note but not sync it. Android Notes in rich mode joins the existing Text session (directEditing), and its edits save fine through Text. Meanwhile the same app's sync, PUT /apps/notes/api/v1/notes/<id>, gets 423 ManuallyLockedException on every retry.
    • nextcloud/text#9355 (merged 2026-10-13) is not the fix. It only refreshes the lock icon in the Files list after close. It doesn't release the lock.
    • A safer workaround than files:lock --unlock or disabling files_lock: occ text:reset <fileId> without --force. It refuses if the editor still holds unsaved changes. The <id> in the failing PUT is the file id.
    • Suggestion for Notes: even after Text is fixed, a note that's really open in the web editor will still return 423. Could the API return a clear "note is open in the editor" error that Android can show, instead of {"errorType":"Exception"}?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneed to reproduceIssue that has not been reproduced

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions