Well, I finally found a post that mentioned to run this in the root of nextcloud:
sudo -u www-data php occ files:scan --all
That fixed it.
Well, I finally found a post that mentioned to run this in the root of nextcloud:
sudo -u www-data php occ files:scan --all
That fixed it.
Hei,
sudo -u www-data php occ files:scan --all
Not worked for meā¦
Still i cannot delete folderā¦
I get this message:
Exception while scanning: File entry could not be inserted with insertIfNotExist() but could also not be selected with getId() in order to perform an update. Please try again.
Help ?
Ok, then it most probably is a file System error.
You should let your filesystem be checked with scandisk (Windows Filesystems) or e2fsck (Linux Filesystems). Search the Internet for detailed tutorials.
Greetings
Tried all of the above and cant get a Folder deleted. Deadlock found error
Is a sudo -u www-data php occ files:scan ā do also check for file if iām using Object Storage as primary way to keep files?
I tried the above steps, didnāt work for me.
Also the table got some entries with lock state -1 or 2. What do those mean? Do I have to delete them aswell?
For those that do not know how to connect or even the owncloud database name in mysql (mariadb) , follow these instructions :
0 - put your nextcloud under maintenance mode on config.php , so no one access it while you are doing changes .
1st - open your config.php in your nextcloud server folder under āconfigā folder .
2nd - there should be a field the like this : " ādbnameā => " , in this field there is your database name .
3rd - open a terminal window and execute under a root account :
then connect to nextcloud database with the following command :
after this point all you have to do is to issue the sql command to delete all data inside the oc_file_locks table
-DELETE FROM oc_file_locks WHERE 1;
then after this point all you have to do is :
\q
to close sql prompt and you are done .
Remove the maintenance mode from config.php and start uploading your files over web interface or dav .
I have similar troubles with a Nextcloud installation that I migrated from an Owncloud installation that Iām running on a Synology diskstation.
This is the database command that I tried:
DELETE FROM owncloud.file_locks WHERE file_locks.lock=1;
but this did not work, so later on I tried:
sudo -u http php56 occ files:scan --all
(note that I had to use the āhttpā for username instead of āwww-dataā and that I had to explicitely state the version in the php56 command.)
The scan resulted also in exceptions while scanning:
Exception while scanning: "files/0e3e13890e7b79a0edc572f53b262079" is locked #0 /volume1/web/nextcloud/lib/private/Files/Storage/Common.php(680): OC\Lock\DBLockingProvider->acquireLock('files/0e3e13890...', 1) #1 /volume1/web/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(588): OC\Files\Storage\Common->acquireLock('files/Familie/B...', 1, Object(OC\Lock\DBLockingProvider)) #2 /volume1/web/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(588): OC\Files\Storage\Wrapper\Wrapper->acquireLock('files/Familie/B...', 1, Object(OC\Lock\DBLockingProvider)) #3 /volume1/web/nextcloud/lib/private/Files/Cache/Scanner.php(148): OC\Files\Storage\Wrapper\Wrapper->acquireLock('files/Familie/B...', 1, Object(OC\Lock\DBLockingProvider)) #4 /volume1/web/nextcloud/lib/private/Files/Cache/Scanner.php(420): OC\Files\Cache\Scanner->scanFile('files/Familie/B...', 3, '157625', NULL, true) #5 /volume1/web/nextcloud/lib/private/Files/Cache/Scanner.php(388): OC\Files\Cache\Scanner->handleChildren('files/Familie', true, 3, '157625', true, 53184942) #6 /volume1/web/nextcloud/lib/private/Files/Cache/Scanner.php(391): OC\Files\Cache\Scanner->scanChildren('files/Familie', true, 3, 157625, true) #7 /volume1/web/nextcloud/lib/private/Files/Cache/Scanner.php(391): OC\Files\Cache\Scanner->scanChildren('files', true, 3, 23, true) #8 /volume1/web/nextcloud/lib/private/Files/Cache/Scanner.php(322): OC\Files\Cache\Scanner->scanChildren('', true, 3, 21, true) #9 /volume1/web/nextcloud/lib/private/Files/Utils/Scanner.php(196): OC\Files\Cache\Scanner->scan('', true, 3) #10 /volume1/web/nextcloud/apps/files/lib/Command/Scan.php(159): OC\Files\Utils\Scanner->scan('/jan') #11 /volume1/web/nextcloud/apps/files/lib/Command/Scan.php(227): OCA\Files\Command\Scan->scanFiles('jan', '/jan', false, Object(Symfony\Component\Console\Output\ConsoleOutput), false) #12 /volume1/web/nextcloud/3rdparty/symfony/console/Command/Command.php(256): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #13 /volume1/web/nextcloud/core/Command/Base.php(161): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #14 /volume1/web/nextcloud/3rdparty/symfony/console/Application.php(818): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #15 /volume1/web/nextcloud/3rdparty/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #16 /volume1/web/nextcloud/3rdparty/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #17 /volume1/web/nextcloud/lib/private/Console/Application.php(169): Symfony\Component\Console\Application->run(NULL, NULL) #18 /volume1/web/nextcloud/console.php(90): OC\Console\Application->run() #19 /volume1/web/nextcloud/occ(11): require_once('/volume1/web/ne...') #20 {main}
My Nextcloud client is still giving errors like:
Error transferring - server replied: Locked
Do you have any suggestions?
I did some further investigations and noted that the owncloud.file_locks table had some more rows where the lock was <> 0, but not 1:
SELECT * FROM owncloud.file_locks WHERE file_locks.lock<>0;
which resulted in:
+-------+------+----------------------------------------+------------+
| id | lock | key | ttl |
+-------+------+----------------------------------------+------------+ | 14 | -1 | files/0e3e13890e7b79a0edc572f53b262079 | 1459283811 | | 15 | -1 | files/4f8cbf29cadcc31429f83d792e806885 | 1459283811 | | 89 | 26 | files/e96e1dcb01f6d44a74247b4ec38f0170 | 1496838714 | | 22846 | 27 | files/46e069d0509232e543a2112007e46765 | 1496838719 | | 22848 | 26 | files/bc4e386d83896b627f63b4e7f48c2d1e | 1496838719 | | 23877 | 25 | files/27de4bb5c6042f2a920e605c9884fdcd | 1496840605 | +-------+------+----------------------------------------+------------+
I deleted the rows where the lock value is -1
DELETE FROM owncloud.file_locks WHERE id=14;
DELETE FROM owncloud.file_locks WHERE id=15;
This solved the problem that I was encountering.
Note that there are also files with a lock value of 25, 26, and 27. I did not research the meaning of these values yet, nor the meaning of -1.
Some remarks to the initial post at the top of this thread:
file_locks
WHERE file_locks.lock=1
DELETE FROM owncloud.file_locks WHERE file_locks.lock=1;
See my above posts for more details.
'maintenance' => true, 'filelocking.enabled' => false,
These two items helped me fix the problem.
I am on a shared server, so turned off file locking, and am monitoring the situation.
Thanks for the great info.
Hello,
Iām running into the locking problem and found this text. It is a very good guidance. It hould be part of the authoritive answer!
But the text of the last 2 bullets of the permanent solution seem to contradict.
Bullet 2 states "You can disable the file locking,"
Bullet 3 states "Disabling is no solution"
Is the last bullet a comment on the 2nd? Or are they talking about 2 different "disablings"
Can someone edit it to solve this once and for all?
Regards,
Bert
I had the problem with locked files too. In my case I found that I have cron job configured to start through AJAX. Problem was, that I rarely used web interface, so after I run cron.php
manually in Nextcloud install root, everything went to normal. I also configured it to run as a cron job every 15 minutes. See manual how to configure Nextcloud cron jobs.
what are the reasons of file locked ? Is it normal ?
I had this issue when I tried to delete a file, but it resulted in an Apache segmentation fault. I fixed this bug and tried to delete the file again but this time it was locked.
So I think the issue is that Nextcloud locks the file before trying delete it and then, if thereās a crash or other error, the lock is never released.
I think the UI should make it clearer what file is locked and provide some way to unlock it. Or, better, have some mechanism to prevent files from being locked and never unlocked afterwards.
Before following this suggestions, I would like to knowā¦
For what purpose file locking was created ?
I have 40.000 entries in my oc_file_locs table, that seems a little too much for me!
Also wiping out all of this locks, seems a bit dangerous to me just to fix 1 problem (I canāt delete a folderā¦)
As far as i know its there, so that you no other process can access the file while it is written, or otherwise processed.
The issue is, that there is maybe a logical inconsistency, since i could not find an ā1ā entries under the lock column. If you delete all entries, they will be rebuild automatically when you exit maintenance mode, but this time in a correct order. I tried this on a testsystem, before applying this on our production mashine, and it worked just fine.
Keep in mind, i drew some assoumtions here. I would be happy if someone could either confirm this, or correct me if nessecary.
Thank you for your answer.
I would also like to have some confirmation⦠like⦠is it normal to have 40.000 locks in a database?
Is my locking system working good? I have around 100.000 files.
I also have 5 main directories owned by a āadminā owner and shared with the others, so everyone uploads files in that directories.
I made this choice so that the āadminā user still owns the files if someone go rogue.
Is this the reason why I have 50% of files locked ?
If you have that many locks in your database you have a serious problem. Use Redis for transactional file locking as said in the first post by @tflidd.
If they are stored in your database you donāt use transactional locking as described here: : https://docs.nextcloud.com/server/13/admin_manual/configuration_files/files_locking_transactional.html