serverinfo icon indicating copy to clipboard operation
serverinfo copied to clipboard

Number of files missing

Open bcutter opened this issue 4 years ago • 7 comments

Expected behaviour

Turn to server info page, you should see the total number of files right above the free storage numbers.

Actual behaviour

number of files value is 0 (zero)

Server configuration

Nextcloud version: (see Nextcloud admin page) 21.0.2.1

Not sure since when exactly this information is missing, latest and only change was updating from 21.0.1.1 to 21.0.2.1 some while (2021-05-25) ago.

bcutter avatar Jun 04 '21 16:06 bcutter

Hi, I have the same problem, my monitoring tool shows since the update to 21.0.2 (around 24.5) the num_files of 0.

conrad784 avatar Jun 11 '21 09:06 conrad784

So do we need to point someone from core/server to this as suspected latest update caused this issue?

bcutter avatar Jun 11 '21 12:06 bcutter

I can absolutely confirm from my own monitoring that this issue emerged exactly as soon as version 21.0.2.1 of nextcloud was deployed over version 21.0.1.1 (I stumbled upon this issue while trying to figure out why my file count dropped to zero at the end of May; I'm both reassured and worried that I'm not the only one), so this definitely sounds like an issue someone from core/server should look at. (EDIT: I have also looked into rebuilding the filecache, cleaning it up, and none of that helped)

Lymkwi avatar Jun 11 '21 16:06 Lymkwi

Caused by missing background job. If there is no background job support you will have to update the instance to get latest serverinfo app. To check background job support:

cat /var/www/html/nextcloud/apps/serverinfo/appinfo/info.xml | grep UpdateStorageStats
        <job>OCA\ServerInfo\Jobs\UpdateStorageStats</job>

To check jobs:

MariaDB [nextcloud]> select * from oc_jobs where class='OCA\\ServerInfo\\Jobs\\UpdateStorageStats';
+-------+----------------------------------------+----------+------------+--------------+-------------+--------------------+
| id    | class                                  | argument | last_run   | last_checked | reserved_at | execution_duration |
+-------+----------------------------------------+----------+------------+--------------+-------------+--------------------+
| 13706 | OCA\ServerInfo\Jobs\UpdateStorageStats | null     | 1623481803 |   1623482103 |           0 |                  0 |
+-------+----------------------------------------+----------+------------+--------------+-------------+--------------------+

If nothing found try re-enabling serverinfo:

sudo -u www-data php -f /var/www/html/nextcloud/occ app:disable serverinfo
sudo -u www-data php -f /var/www/html/nextcloud/occ app:enable serverinfo

ghost avatar Jun 12 '21 07:06 ghost

Perfect!

✅ Background job support ❌ Jobs: returned nothing (empty set) ✅ After disabling and reenabling the app and waiting few minutes: job exists and number is being created

So this is a perfect hotfix. How to put this in next core or serverinfo version?

(Fixed for me but will keep this issue open until an automatic fix is available.)

bcutter avatar Jun 13 '21 21:06 bcutter

Once it's done it will stay working. However it seems that ServerInfo needs a migration class or something which triggers re-enabling. And how it should be implemented has to be decided by the maintainers.

ghost avatar Jun 13 '21 22:06 ghost

Perfect!

white_check_mark Background job support x Jobs: returned nothing (empty set) white_check_mark After disabling and reenabling the app and waiting few minutes: job exists and number is being created

So this is a perfect hotfix. How to put this in next core or serverinfo version?

(Fixed for me but will keep this issue open until an automatic fix is available.)

I will point out that there is still a slight regression because of this new behaviour, though I do not know how/if it can be fixed (and it probably deserves its own issue anyways) : those metrics cannot be updated more frequently than background jobs are ran. Previously, the file count exported by serverinfo would be almost instantaneously updated. Now, if you run cron jobs every fifteen minutes, you won't be able to get those metrics updated more frequently than once every fifteen minutes, which can be a pain if you have a service (say, Prometheus) fetching data once every fifteen seconds.

I'm glad the metrics are back at least, I just wish they could be updated instantaneously like previously.

Lymkwi avatar Jun 25 '21 21:06 Lymkwi

The storage stats collection was indeed moved to a background job in v21.0.2 and set to run (by default) every 3 hours. It is configurable:

https://github.com/nextcloud/serverinfo/tree/master#configuration

The manual fix is easy enough, but it's a little baffling this state even arose for you. 😕

Installs/updates of the serverinfo app (either directly or, more likely, by upgrading NC since it's a default app) automatically trigger registration/re-registration of the background job.

Installs have to be triggering this properly because otherwise no one would have this job and we'd all have zero to this day. Same for updates, unless it was something serverinfo specific (which would be really odd because 99% of job management is in core not the app). An issue in core with job registration would (should) be really obvious since it would impact loads of things throughout NC. The only possible thing even remotely connected I can find is nextcloud/server#30358.

@Lymkwi wrote:

I will point out that there is still a slight regression because of this new behaviour, though I do not know how/if it can be fixed (and it probably deserves its own issue anyways) : those metrics cannot be updated more frequently than background jobs are ran. Previously, the file count exported by serverinfo would be almost instantaneously updated. Now, if you run cron jobs every fifteen minutes, you won't be able to get those metrics updated more frequently than once every fifteen minutes, which can be a pain if you have a service (say, Prometheus) fetching data once every fifteen seconds.

There are always trade-offs. 😄 In theory you might run NC's cron.php more frequently. All registered background jobs set their own intervals - so running the overall background job manager more often than the typical 5 minutes is theoretically possible. Though it's possible there are some assumptions that it'll be at least 5 minutes. Don't have time to look at the code right now, but feel free: https://github.com/nextcloud/server/blob/master/cron.php. And, yeah, any follow-up on this bit should get it's own Issue.

joshtrichards avatar May 29 '23 15:05 joshtrichards

We recommend running cron.php every 5 minutes.

If you need faster updates for the statistics: php occ serverinfo:update-storage-statistics

The query to find the number of files is expensive with a huge number of files.

kesselb avatar May 29 '23 18:05 kesselb