SMB external storage shows no files

I’ve tried to add a SMB share to a nextcloud instance with the external storage app, but when I enter the folder on Nextcloud it either keeps loading forever or tells me there are no files. I’ve tried running

occ files:scan user

But it throws an error about a locked file

Exception during scan: “files/d8473000a2bdbccb8xxxxxxxxxxxxxx” is locked
#0 /var/www/nextcloud/lib/private/Files/Storage/Common.php(713): OC\Lock\DBLockingProvider->acquireLock(‘files/d8473000a…’, 2)
#1 /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(592): OC\Files\Storage\Common->acquireLock(‘scanner::’, 2, Object(OC\Lock\DBLockingProvider))
#2 /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(592): OC\Files\Storage\Wrapper\Wrapper->acquireLock(‘scanner::’, 2, Object(OC\Lock\DBLockingProvider))
#3 /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(592): OC\Files\Storage\Wrapper\Wrapper->acquireLock(‘scanner::’, 2, Object(OC\Lock\DBLockingProvider))
#4 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(331): OC\Files\Storage\Wrapper\Wrapper->acquireLock(‘scanner::’, 2, Object(OC\Lock\DBLockingProvider))
#5 /var/www/nextcloud/lib/private/Files/Utils/Scanner.php(245): OC\Files\Cache\Scanner->scan(’’, true, 3)
#6 /var/www/nextcloud/apps/files/lib/Command/Scan.php(172): OC\Files\Utils\Scanner->scan(’/emilian.mitoca…’, true, NULL)
#7 /var/www/nextcloud/apps/files/lib/Command/Scan.php(249): OCA\Files\Command\Scan->scanFiles(‘emilian.mitocar…’, ‘/emilian.mitoca…’, false, Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#8 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(251): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/nextcloud/core/Command/Base.php(162): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/nextcloud/3rdparty/symfony/console/Application.php(946): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/nextcloud/3rdparty/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/nextcloud/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/nextcloud/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/nextcloud/console.php(96): OC\Console\Application->run()
#15 /var/www/nextcloud/occ(11): require_once(’/var/www/nextcl…’)
#16 {main}

I’ve tried to manually remove the lock as described here but this doesn’t fix it and the lock just gets recreated. I’ve also tried to add the SMB share on another Nextcloud instance as a test and it works without a problem. Both servers are configured the same, so I wonder what happened on the first server and how can I fix it?

Note: both servers have redis caching for locks enabled

Nextcloud version: 14.0.4
Operating system and version: Ubuntu 16.04
Apache or nginx version: Apache 2.4.18
PHP version: 7.0