[PHP] Error: opendir(): failed to open dir: File name too long, lots of slashes in path

Nextcloud version (eg, 18.0.2): 20.0.2
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.29
PHP version (eg, 7.1): 7.2

The issue you are facing:

I am getting the same error ~10x per minute for multiple days already. [PHP] Error: opendir(...
In the error there is a path with a lot of slashes and I don’t know why they are there.

What I tried so far:

Rebooting server, when doing this it took 30min for mariadb to be force closed, after that the issue was still there.
Looking at logs and mariadb, but since I don’t have enough experience I don’t know what to do with it but i suspect it is a query(not sure about correct term) that is stuck/looping.

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

I saw it a few days ago but didn’t have time to try to fix it, today it is still showing the same error in the log multiple times per minute.

Steps to replicate it:

I don’t know why this started happening.

The output of your Nextcloud log in Admin > Logging:

[PHP] Error: opendir(/media/nextcloud/Username/files/Misc sorted/folder1/folder2/folder3///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////folder4/folder5///////////folder6///Graphics////Lang): failed to open dir: File name too long at /var/www/nextcloud/lib/private/Files/Storage/Local.php#131

at 2020-11-28T14:13:41+00:00

This is repeated ~10x per minute for multiple days.
There is a variation in the exact path, folder4 and higher are different, I cannot tell if it si a repeating pattern or that it is going trough all possible subfolders in folder3(which is possible since its a big folder).

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

<?php
$CONFIG = array (
  'instanceid' => '',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' =>
  array (
    0 => '192.168.2.10',
    1 => '',
  ),
  'datadirectory' => '/media/nextcloud',
  'dbtype' => 'mysql',
  'version' => '19.0.3.1',
  'overwrite.cli.url' => '',
  'dbname' => 'nextcloud_db_glados',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud_glados',
  'dbpassword' => ''
  'installed' => true,
  'lost_password_link' => 'disabled',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'htaccess.RewriteBase' => '/',
  'mysql.utf8mb4' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'default_locale' => 'nl',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'updater.release.channel' => 'stable',
);

The output of your Apache/nginx/system log in /var/log/____:
Nothing relevant as far as I can tell, if needed will include later.

The output of status in mariadb:

MariaDB [(none)]> status
--------------
mariadb  Ver 15.1 Distrib 10.1.47-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Connection id:          40876
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server:                 MariaDB
Server version:         10.1.47-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:            /var/run/mysqld/mysqld.sock
Uptime:                 3 days 2 hours 32 min 43 sec

Threads: 9  Questions: 756510584  Slow queries: 1  Opens: 237  Flush tables: 1  Open tables: 231  Queries per second avg: 2818.982
--------------

I like to use the search function of this forum because it allows you to find answers without posting a new issue again and again. E.g. it took me less than 5s to find this report :wink:

Due to the fact that the issue has create in July and has alos already been closed, I would recommend to update your server to a more recent version than v19.0.3.:

1 Like

Thanks for your reaction and sorry for not finding that, I did search but probably not with the correct search terms :stuck_out_tongue:.

Updating didn’t fix it sadly, I am now on v20.0.2 but I still get the same entries in the log. Could it be that an old task is still running? Is there a way to stop it?

Actually, to fix the issue we did not go to a more recent release, but we did some code changes which helped. At that time 19.0.3 was the most recent release - and your experience shows that it was wise not to update in the meantime because that would have reversed our changes.

We implemented code changes that have been described here: https://github.com/nextcloud/server/pull/21723

This fix from bug 21723 doesn’t seem to appear in a current release, so you would probably need to make those code changes yourself or wait until they have integrated the fix into the distribution.

If you like I can look what exactly was changed when I am back in the office on Monday.

1 Like

I didn’t notice that is was still an open pull request, I tried manually applying the 2 changes in it, but it didn’t change anything for me.

First i put the server in maintenance mode, then I changed the 2 files, then I put it out of maintenance mode.
I am not really familiar with php or how the nextcloud server runs internally, could it still be running a cached version of the files? Or still executing old queued tasks?

A new problem since updating is that my server is now constantly at 90% cpu usage by mysqld and php on a Intel i5-6400, it could be related. Before updating I did notice it was too high as well at 20%.

I would appreciate it if you have time to help on Monday(or later I m not in a rush).

Maintenance mode is not enough. You might want to restart the web server running Nextcloud (in my system systemctl restart apache2) and maybe, if that doesn’t remove the activity, even manually kill the nextcloud process which performs the scan.

1 Like

The error is gone now after restarting, thanks a lot for the help.