{"id":589,"date":"2021-03-07T18:27:00","date_gmt":"2021-03-08T00:27:00","guid":{"rendered":"https:\/\/lab.rapternet.us\/?p=589"},"modified":"2021-02-06T20:46:49","modified_gmt":"2021-02-07T02:46:49","slug":"nextcloud-file-lock-error-in-joplin","status":"publish","type":"post","link":"https:\/\/lab.rapternet.us\/?p=589","title":{"rendered":"NextCloud File Lock Error in Joplin"},"content":{"rendered":"\n<p>I encountered a problem recently on the Joplin desktop app where it couldn&#8217;t synchronize due to a file lock being stuck in NextCloud. It uses a file in the jopline data directories to determine sync status and lock status on files being edited, and this file was stuck locked in NextCloud with no way to delete it. I performed some searching, finding some blog posts on the subject and <a href=\"https:\/\/help.nextcloud.com\/t\/file-is-locked-how-to-unlock\/1883\">found this on how to solve it<\/a>. I&#8217;ll be going through the manual solution to this problem and updating the process with my experience.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p><strong>Manually disable locking state:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Put Nextcloud in maintenance mode: edit <code>config\/config.php<\/code> and change this line:<br><code>'maintenance' =&gt; true,<\/code><ul><li>Running NextCloud in docker, you&#8217;ll need to go to the path that you have mounted to \/var\/www\/html in the container. For me this was in my NextCloud\/html folder, so I went to NextCloud\/html\/config\/config.php<\/li><\/ul><\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/config.php-last-lines.png\" alt=\"\" class=\"wp-image-592\" width=\"365\" height=\"124\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/config.php-last-lines.png 365w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2021\/01\/config.php-last-lines-300x102.png 300w\" sizes=\"auto, (max-width: 365px) 100vw, 365px\" \/><figcaption>Last Few Lines of Config.php Modified for maintenance mode<\/figcaption><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Empty table <code>oc_file_locks<\/code>: Use tools such as phpmyadmin or connect directly to your database and run (the default table prefix is <code>oc_<\/code>, this prefix can be different or even empty):<br><code>DELETE FROM oc_file_locks WHERE 1<\/code><ul><li>Running this from phpmyadmin, I saw that there would be 98k rows affected, this did make me nervous<\/li><\/ul><\/li><li>disable maintenance mode (undo first step).<\/li><li>Make sure your cron-jobs run properly (you admin page tells you when cron ran the last time): <a href=\"https:\/\/docs.nextcloud.org\/server\/13\/admin_manual\/configuration_server\/background_jobs_configuration.html\">https:\/\/docs.nextcloud.org\/server\/13\/admin_manual\/configuration_server\/background_jobs_configuration.html 1.9k<\/a><\/li><\/ul>\n\n\n\n<p><strong>Permanent solution (if it happens regularly)<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>on your <strong>own server<\/strong>: Use redis for this feature. It is faster and so far no problems have been reported. You can follow the instructions for memory-caching in the docs: <a href=\"https:\/\/docs.nextcloud.org\/server\/13\/admin_manual\/configuration_server\/caching_configuration.html#id4\">https:\/\/docs.nextcloud.org\/server\/13\/admin_manual\/configuration_server\/caching_configuration.html#id4 6.4k<\/a><\/li><li><strong>Shared hosting<\/strong> (others who can\u2019t install redis): You can disable the file locking, edit your configuration file <code>config\/config.php<\/code>:<br><code>'filelocking.enabled' =&gt; false,<\/code><br>However, disabling is not a good solution. You can run into problems when several processes try to write to a file (especially online editors in the web-interface). In single-user and single-client environments, it\u2019s probably less of a problem.<\/li><\/ul>\n\n\n\n<p>After running the manual method, everything worked properly, Joplin was able to synchronize and I saw no other side effects immediately afterwards. I&#8217;ll update this blog post if anything crops up. This only took 15 minutes, which I was nervous this maintenance would turn into a longer ordeal. I use Joplin for outlining and writing my blog posts away from my PC and then adding the content later to my blog or wiki depending on what it is. So keeping Joplin working was important to me.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I encountered a problem recently on the Joplin desktop app where it couldn&#8217;t synchronize due to a file lock being stuck in NextCloud. It uses a file in the jopline data directories to determine sync status and lock status on files being edited, and this file was stuck locked in NextCloud with no way to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lab.rapternet.us\/?p=589\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;NextCloud File Lock Error in Joplin&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":590,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[12,11],"class_list":["post-589","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","tag-joplin","tag-nextcloud"],"_links":{"self":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=589"}],"version-history":[{"count":8,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/589\/revisions"}],"predecessor-version":[{"id":692,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/589\/revisions\/692"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/media\/590"}],"wp:attachment":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}