Warning: The database is used for transactional file locking

I’m running Nextcloud 27.0.0.1. Since a recent update I have been getting the following warning in my admin overview.

  • The database is used for transactional file locking. To enhance performance, please configure memcache, if available. See the documentation :arrow_upper_right: for more information.

I already have APCu configured as explained here:
https://docs.nextcloud.com/server/19/admin_manual/configuration_server/caching_configuration.html#id1

I do not see the need for installing a Redis server for transitional file locking because I am the only person using this nextcloud server, how do I get rid of this warning message in my admin overview?

1 Like

I decided to install Redis, in the end it wasn’t too much effort and now the warning is gone.

4 Likes

Hi, I am getting the same warning after updating form 26.0.2 to 27.0.0.

There are some warnings regarding your setup.

  • The database is used for transactional file locking. To enhance performance, please configure memcache, if available. See the documentation :arrow_upper_right: for more information.

Any ideas how to solve it without switching to redis?

No but installing and configuring Redis wasn’t hard.

  1. Install packages: dnf install php-pecl-redis5 redis
  2. Configure redis: /etc/redis/redis.conf
unixsocket /var/run/redis/redis.sock
unixsocketperm 660
  1. Enable and start redis: systemctl enable redis --now
  2. Add apache to the redis group: usermod -aG redis apache
  3. Add redis to your nextcloud configuration.
'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => array(
     'host' => '/var/run/redis/redis.sock',
     'port' => 0,
     'timeout' => 0.0,
      ),
  1. Restart php-fpm: systemctl restart php-fpm

If you are running Ubuntu the packages and configuration files will be a be named differently.

4 Likes

Yes, I am running ubuntu, I will try it later today. Thanks!

I just looked it up on an Ubuntu test vm I have.

  1. Install redis: apt install redis php-redis
  2. Configure redis: /etc/redis/redis.conf
unixsocket /var/run/redis/redis.sock
unixsocketperm 660
  1. Restart redis: systemctl restart redis
  2. Add apache to the redis group: usermod -aG redis www-data
  3. Add redis to your nextcloud configuration.
'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\OC\Memcache\Redis',
  'redis' => array(
     'host' => '/var/run/redis/redis.sock',
     'port' => 0,
     'timeout' => 0.0,
      ),
  1. Done since it doesn’t look like Ubuntu use php-fpm.
4 Likes

I just went from NC26 to NC27 on Debian 11. I then upgraded to PHP 8.2 as per the recommendation in the admin page.

I fixed the remaining errors but was left with the one detailed in this post.

Hydranet’s redis instructions (adjusted for Debian) fixed the remaining issue.

I appreciate your help.

Now when I run

php occ files:scan --all

I get the following errors. I assume the command is trying to lock the files and redis is having a problem.

Also none of my videos play in Nextcloud any more. if I remove redis the function comes back.

Do you get the same issue or is it just my environment?

Starting scan for user 1 out of 2
Exception during scan: No such file or directory
#0 /var/www/html/nextcloud/lib/private/RedisFactory.php(137): Redis->pconnect()
#1 /var/www/html/nextcloud/lib/private/RedisFactory.php(178): OC\RedisFactory->create()
#2 /var/www/html/nextcloud/lib/private/Memcache/Redis.php(66): OC\RedisFactory->getInstance()
#3 /var/www/html/nextcloud/lib/private/Memcache/Redis.php(126): OC\Memcache\Redis->getCache()
#4 /var/www/html/nextcloud/lib/private/Lock/MemcacheLockingProvider.php(65): OC\Memcache\Redis->add()
#5 /var/www/html/nextcloud/lib/private/Files/Storage/Common.php(765): OC\Lock\MemcacheLockingProvider->acquireLock()
#6 /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(607): OC\Files\Storage\Common->acquireLock()
#7 /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(607): OC\Files\Storage\Wrapper\Wrapper->acquireLock()
#8 /var/www/html/nextcloud/lib/private/Files/Cache/Scanner.php(339): OC\Files\Storage\Wrapper\Wrapper->acquireLock()
#9 /var/www/html/nextcloud/lib/private/Files/Utils/Scanner.php(269): OC\Files\Cache\Scanner->scan()
#10 /var/www/html/nextcloud/apps/files/lib/Command/Scan.php(164): OC\Files\Utils\Scanner->scan()
#11 /var/www/html/nextcloud/apps/files/lib/Command/Scan.php(219): OCA\Files\Command\Scan->scanFiles()
#12 /var/www/html/nextcloud/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute()
#13 /var/www/html/nextcloud/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run()
#14 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run()
#15 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#16 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#17 /var/www/html/nextcloud/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run()
#18 /var/www/html/nextcloud/console.php(100): OC\Console\Application->run()
#19 /var/www/html/nextcloud/occ(11): require_once(‘…’)
#20 {main}
Starting scan for user 2 out of 2
Exception during scan: Redis server went away
#0 /var/www/html/nextcloud/lib/private/Memcache/Redis.php(126): Redis->set()
#1 /var/www/html/nextcloud/lib/private/Lock/MemcacheLockingProvider.php(65): OC\Memcache\Redis->add()
#2 /var/www/html/nextcloud/lib/private/Files/Storage/Common.php(765): OC\Lock\MemcacheLockingProvider->acquireLock()
#3 /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(607): OC\Files\Storage\Common->acquireLock()
#4 /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(607): OC\Files\Storage\Wrapper\Wrapper->acquireLock()
#5 /var/www/html/nextcloud/lib/private/Files/Cache/Scanner.php(339): OC\Files\Storage\Wrapper\Wrapper->acquireLock()
#6 /var/www/html/nextcloud/lib/private/Files/Utils/Scanner.php(269): OC\Files\Cache\Scanner->scan()
#7 /var/www/html/nextcloud/apps/files/lib/Command/Scan.php(164): OC\Files\Utils\Scanner->scan()
#8 /var/www/html/nextcloud/apps/files/lib/Command/Scan.php(219): OCA\Files\Command\Scan->scanFiles()
#9 /var/www/html/nextcloud/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute()
#10 /var/www/html/nextcloud/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run()
#11 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run()
#12 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#13 /var/www/html/nextcloud/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#14 /var/www/html/nextcloud/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run()
#15 /var/www/html/nextcloud/console.php(100): OC\Console\Application->run()
#16 /var/www/html/nextcloud/occ(11): require_once(‘…’)
#17 {main}

If you get that error the redis service is not running.

I don’t have any videos on my Nextcloud, but if I place one and than do a scan it appears and I am able to play the video.

Ok. i probably just messed something up. Thanks for your response.

I will give it another go tomorrow.

Thanks for this info, I installed redis and added the below into my nextcloud config.php

‘memcache.local’ => ‘\OC\Memcache\APCu’,
‘filelocking.enabled’ => true,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ => array(
‘host’ => ‘/var/run/redis/redis-server.sock’,
‘port’ => 0,
‘timeout’ => 0.0,
),

Running ls -lh /var/run/redis
-rw-rw---- 1 redis redis 6 Jun 17 08:47 redis-server.pid
srwxrwx— 1 redis redis 0 Jun 17 08:47 redis-server.sock

Lastly my redis config I tried this
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 660

With all this configured I am still getting - The database is used for transactional file locking. To enhance performance, please configure memcache

Any help pointing me in the right direction would greatly appreciated.

Did you add the apache or www-data user to the redis group?

Thank you for that suggestion, I added the www-data user to the redis group and restarted redis & apache
members redis
redis www-data

Unfortunately still getting the warning.

What happens when you do a file scan as the www-data user, share the output?

I’m facing the same issue as @techman2005 .
*Nextcloud instance on Debian (Raspberry Pi OS more specifically)
*Installed Redis the way you said
*Added www-data to the redis group
*Edited my php.conf file

Ran sudo -u www-data php occ files:scan --all, got 0 errors:

Starting scan for user 1 out of 1
±--------±-------±-------±-------------+
| Folders | Files | Errors | Elapsed time |
±--------±-------±-------±-------------+
| 6164 | 109933 | 0 | 00:09:50 |
±--------±-------±-------±-------------+

Still the warning persists.

Instructions by Hydranet work great. I added apache to redis but it did not work, no preview or image loads, it was a permission issue.

Because I use a hosting control panel (virtualmin) that creates mydomainuser for each website I had to add mydomainuser to the redis group and now it seems to work fine. Because it starts php-fpm as that specific user and not only apache.

No scan errors

±--------±------±-------±-------------+
| Folders | Files | Errors | Elapsed time |
±--------±------±-------±-------------+
| 1480 | 22528 | 0 | 00:01:36 |
±--------±------±-------±-------------+

I got the same error when I upgraded to 27.0.0 and went ahead and installed redis on Debian and all okay after some trial and error

Hello,

I have the same message : The database is used for transactional file locking.
I don’t how to proceed, my nextcloud is hosted on Docker.
Do you know how to add redis on an existing nextcloud docker with redis for example ?

Thanks

Hey techman2005 and LeoFender, not sure if you guys were able to fix this issue or not but I upgraded mine this afternoon, then ran into the same issue as you guys. I only installed redis and didn’t install php-redis. So after installing php-redis, I did a reboot then the warning message was gone.

1 Like

@jml Add this to your Docker compose file:

  redis:
    image: redis:alpine
    restart: always

That’s all it takes to bring up a Redis container.

Then, since you’re interested in reconfiguring an existing NC stack, all you need to add are the following lines to your Nextcloud config.php (replacing any matching existing parameter lines):


'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
     'host' => 'localhost',
     'port' => 6379,
],


You can see some Compose examples here:

And some docs on Redis setup here:

https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html#organizations-with-single-server

Further optimizations are possible beyond this, but the above is a fully functioning and highly typical setup (particularly for a small organization or home user).

I’d personally also add the following to my Docker Compose, even though you’re updating an existing installation, since it more properly documents it in the compose file (i.e. in the same way it’d be if you’d built it with Redis from the start) in case you ever need to rebuild:

  app:
    [...]
    environment:
      - REDIS_HOST=redis

1 Like