Exception during scan

Nextcloud version (eg, 20.0.5): 22.2.0
Operating system and version (eg, Ubuntu 20.04): Debian 10.11 Buster
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.38 (Debian)
PHP version (eg, 7.4): 7.3.29

The issue you are facing:
I upload files via ftp to the nextcloud server, there is a cron job to scan the folder with these files. Today it shows the following error when starting a scan.
Exception during scan: “files/d784bebd6ba0b461c83d360f8cdc848e”(“home::rec::scanner::”) is locked
#0 /var/www/html/nextcloud/lib/private/Files/Storage/Common.php(752): OC\Lock\DBLockingProvider->acquireLock(‘files/d784bebd6…’, 2, ‘home::rec::scan…’)
#1 /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(591): OC\Files\Storage\Common->acquireLock(‘scanner::’, 2, Object(OC\Lock\DBLockingProvider))
#2 /var/www/html/nextcloud/lib/private/Files/Cache/Scanner.php(333): OC\Files\Storage\Wrapper\Wrapper->acquireLock(‘scanner::’, 2, Object(OC\Lock\DBLockingProvider))
#3 /var/www/html/nextcloud/lib/private/Files/Utils/Scanner.php(259): OC\Files\Cache\Scanner->scan(’’, true, 3)
#4 /var/www/html/nextcloud/apps/files/lib/Command/Scan.php(156): OC\Files\Utils\Scanner->scan(’/rec’, true, NULL)
#5 /var/www/html/nextcloud/apps/files/lib/Command/Scan.php(212): OCA\Files\Command\Scan->scanFiles(‘rec’, ‘/rec’, Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#6 /var/www/html/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/nextcloud/core/Command/Base.php(168): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(1009): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/nextcloud/lib/private/Console/Application.php(209): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/nextcloud/console.php(99): OC\Console\Application->run()
#13 /var/www/html/nextcloud/occ(11): require_once(’/var/www/html/n…’)
#14 {main}

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. I do not know how to remove this error
  2. I do not know how to remove this error
  3. I do not know how to remove this error

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php $CONFIG = array ( 'passwordsalt' => '', 'secret' => '', 'trusted_domains' => array ( 0 => 'localhost', 1 => '', ), 'datadirectory' => '/var/www/html/nextcloud/data/', 'dbtype' => 'mysql', 'version' => '22.2.0.2', 'overwrite.cli.url' => 'http://localhost', 'dbname' => 'nextcloud', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'nextclouduser', 'dbpassword' => '', 'installed' => true, 'instanceid' => '', ); The output of your Apache/nginx/system log in `/var/log/____`: Thanks

If you have a lot of file operations, files can be locked in the database (File is locked - how to unlock), normally this can’t happen to new files that aren’t indexed yet. If you have many users, many parallel uploads or in general many file operations, you should consider using redis.

The main storage is considered to be exclusive to Nextcloud. So every time running the file-scan is not the preferred method, in this case you should take a look at the external storage function which can just be some exchange-folder on your file system. Nextcloud expects changes by external processes in contrast to the main storage. It is automatically scanned upon access.

I have one user, one file type, one file source, one storage location. The cron is set to scan every minute. Files arrive one file every 15 minutes.

I read the instruction: File is locked - how to unlock how to use phpmyadmin with nextcloud?

What other options are there to remove the lock?

Thank you

ok done, figured out how to remove the lock. How to avoid further blocking?