Transactional file locking with redis not working

Steps to reproduce

Expected behaviour

File locking works

Actual behaviour

Main page doesn’t render, client can’t access

Server configuration

Operating system: Gentoo

Web server: nginx

Database: sqlite3

PHP version: 7.2

ownCloud version: 10.4.0

Updated from an older ownCloud or fresh install: fresh

Where did you install ownCloud from: gentoo repository

Everything works as long as I don’t try to use redis, either for caching or file locking. APCu seems to be working.
Here’s a snippet from config.php:
‘memcache.local’ => ‘\OC\Memcache\APCu’,
‘filelocking.enabled’ => ‘true’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ =>
array (
‘host’ => ‘/tmp/redis.sock’,
‘port’ => 0,
),

I guess modules are there as redis and apcu show in php -m

User nginx belongs to redis group

I’ve edited redis.conf as follows:
unixsocket /tmp/redis.sock
unixsocketperm 700
bind 127.0.0.1
port 0

Tried with permissions 750 and 770 on the socket - no luck

What am I missing?

  1. You can try removing the line with:
‘port’ => 0,
  1. Alternatively put it the line back in and change the host to:
‘host’ => ‘127.0.0.1’,
1 Like

Thanks for that tip.

Curiously, it doesn’t work though. What does it tell us though if neither loopback nor socket work for me?

Also, I’d like to use socket as it seems way faster from what I can see from running redis-benchmark.

Redis is not the bottleneck. It almost never is.

Can you try using the standard redis port, I think it is 6379, obviously you’ll have to adjust both redis-server and owncloud configuration. I just want to rule out that the redis php library doesn’t have a problem with port 0.

1 Like

If you want to improve the performance of your ownCloud I would rather recommend to upgrade to MariaDB/MySQL here.

1 Like

Thanks for a quick reply,

I tried:

‘redis’ =>
array (
‘host’ => ‘127.0.0.1’,
‘port’ => 6379,
‘timeout’ => 0,
),

and in redis.conf:
port 6379
bind 127.0.0.1
timeout 0

and commented out
unixsocket /tmp/redis.sock
unixsocketperm 770

No luck.

Is your redis actually running? Have you checked with

# If you're using systemd, you can display the status of the service
systemctl status redis
# This tells you all the services listening on an IP:Port combination on your server
ss -tulpen

Perhaps there is something wrong with the redis server configuration, and the service doesn’t even start, or crashes after a few seconds/minutes.

1 Like

rc-service redis status

  • status: started

ss -tulpen | grep redis
tcp LISTEN 0 511 127.0.0.1:6379 0.0.0.0:* users:((“redis-server”,pid=1541,fd=6)) uid:75 ino:10534586 sk:17 <->

1 Like

Here goes snippet from nginx error log:

2020/04/17 16:01:51 [error] 5342#5342: *74 FastCGI sent in stderr: “PHP message: PHP Warning: fopen(/var/www/cloud.mydomain.com/htdocs/owncloud/config/config.php): failed to open stream: Permission denied in /var/www/cloud.mydomain.com/htdocs/owncloud/lib/private/Config.php on line 239
PHP message: PHP Warning: flock() expects parameter 1 to be resource, boolean given in /var/www/cloud.mydomain.com/htdocs/owncloud/lib/private/Config.php on line 249
PHP message: PHP Fatal error: Uncaught Error: Call to a member function getValue() on null in /var/www/cloud.mydomain.com/htdocs/owncloud/lib/base.php:1019
Stack trace:
#0 /var/www/cloud.mydomain.com/htdocs/owncloud/index.php(83): OC::crashLog(Object(Exception))
#1 {main}
thrown in /var/www/cloud.mydomain.com/htdocs/owncloud/lib/base.php on line 1020” while reading response header from upstream, client: client.ip.here, server: cloud.mydomain, request: “GET /index.php/login HTTP/2.0”, upstream: “fastcgi://127.0.0.1:9000”, host: “cloud.mydomain”
2020/04/17 16:01:52 [error] 5342#5342: *74 open() “/var/www/cloud.mydomain.com/htdocs/owncloud/favicon.ico” failed (2: No such file or directory), client: client.ip.here, server: cloud.mydomain, request: “GET /favicon.ico HTTP/2.0”, host: “cloud.mydomain”
2020/04/17 16:01:52 [info] 5342#5342: *74 client canceled stream 27 while sending request to upstream, client: client.ip.here, server: cloud.mydomain, request: “GET /favicon.ico HTTP/2.0”, upstream: “fastcgi://127.0.0.1:9000”, host: “cloud.mydomain”
2020/04/17 16:01:52 [error] 5342#5342: *74 FastCGI sent in stderr: “PHP message: PHP Warning: fopen(/var/www/cloud.mydomain.com/htdocs/owncloud/config/config.php): failed to open stream: Permission denied in /var/www/cloud.mydomain.com/htdocs/owncloud/lib/private/Config.php on line 239
PHP message: PHP Warning: flock() expects parameter 1 to be resource, boolean given in /var/www/cloud.mydomain.com/htdocs/owncloud/lib/private/Config.php on line 249
PHP message: PHP Fatal error: Uncaught Exception: Could not acquire a shared lock on the config file /var/www/cloud.mydomain.com/htdocs/owncloud/config/config.php in /var/www/cloud.mydomain.com/htdocs/owncloud/lib/private/Config.php:250
Stack trace:
#0 /var/www/cloud.mydomain.com/htdocs/owncloud/lib/private/Config.php(64): OC\Config->readData()
#1 /var/www/cloud.mydomain.com/htdocs/owncloud/lib/base.php(135): OC\Config->__construct(’/var/www/cloud…’)
#2 /var/www/cloud.mydomain.com/htdocs/owncloud/lib/base.php(523): OC::initPaths()
#3 /var/www/cloud.mydomain.com/htdocs/owncloud/lib/base.php(1058): OC::init()
#4 /var/www/cloud.mydomain.com/htdocs/owncloud/core/templates/404.php(7): require_once(’/var/www/cloud…’)
#5 {main}
thrown in /var/www/cloud.mydomain.com/htdocs/owncloud/lib/private/Config.php on line 250” while reading response header from upstream, client: client.ip.here, server: cloud.mydomain, request: “GET /favicon.ico HTTP/2.0”, upstream: “fastcgi://127.0.0.1:9000”, host: “cloud.mydomain”

Hey,

i think you have some permission issues on the config.php which could be caused by editing the config.php or similar.