nextcloud / nextcloud/server

[Bug]: Automatic (not on-demand) preview generation of max.jpg files still fills disk

Open
#58,320 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 32-feedback bug feature: previews and thumbnails
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

We use Nextcloud to offer a backup solution for our clients. It is mostly used for long-term storage (backups) of large amounts of photos.
Around the upgrade to Nextcloud 30, we started to notice that the amount of data and the number of files (inodes) began growing faster than before. This behavior may have existed in earlier versions as well.

This is caused by preview max.jpg images already being created in many preview sub folders, instead of being generated on the fly.
As most photos are never being looked at in the web interface this causes a lot of preview max.jpg images and preview folders to exists which are never used. Causing a lot of storage use, IO and hundred thousands of inodes.

Now we manually cleanup those preview folders, but this is also removing crop.jpg/max.jpg of photos clients are actually viewing in the web interface.

This issue might be related to this issue where specifically the generation of crop.jpg preview images was already fixed. However max.jpg and many folders are still generated, although as far as I can see in the code, this might not be caused by the blur hash logic.

Steps to reproduce
1 Connect desktop client to Nextcloud
2 Copy some images to a folder
3. Wait for background jobs to complete or run `php occ background-job:worker`

Or:
1. Create empty folder in web client NextCloud - Dont go in to the folder to prevent on the fly previews.
2. Drag images in to folder - Dont go in to the folder to prevent on the fly previews.
3. Wait for background jobs to complete or run php occ background-job:worker

To monitor the preview folder for create events:
inotifywait -m -r -e create /path/to/preview/folder

Output:

/home/user/www/data/appdata_example/preview/c/1/ CREATE,ISDIR 6
/home/user/www/data/appdata_example/preview/c/1/6/5/d/9/4/334083/ CREATE 804-822-max.jpg
/home/user/www/data/appdata_example/preview/8/ CREATE,ISDIR 2
/home/user/www/data/appdata_example/preview/8/2/c/6/6/5/f/334084/ CREATE 2882-2590-max.jpg
/home/user/www/data/appdata_example/preview/4/ CREATE,ISDIR a
/home/user/www/data/appdata_example/preview/4/a/9/5/d/b/d/334085/ CREATE 448-411-max.jpg
/home/user/www/data/appdata_example/preview/5/e/ CREATE,ISDIR 3
/home/user/www/data/appdata_example/preview/5/e/3/0/5/7/8/334086/ CREATE 4096-2720-max.jpg
etc ...
Expected behavior

We would expect these 'max.jpg' preview images just be created when browsing through folders with the web interface on the fly.
So preview images only exists when photo folders are actually looked in to by the client.

Nextcloud Server version

32

Operating system

RHEL/CentOS

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "*"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "31.0.13.1",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "nc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "updatechecker": false,
        "skeletondirectory": "",
        "default_language": "nl",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "dbindex": 0,
            "timeout": 1.5
        },
        "loglevel": 0,
        "log_type": "errorlog",
        "maintenance": false,
        "theme": ""
    }
}
List of activated Apps
Enabled:
  - purple_theme: 1.0.6
  - app_api: 5.0.2
  - cloud_federation_api: 1.14.0
  - dav: 1.33.0
  - federatedfilesharing: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.2
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - lookup_server_connector: 1.19.0
  - oauth2: 1.19.1
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - settings: 1.14.0
  - theming: 2.6.1
  - twofactor_backupcodes: 1.20.0
  - twofactor_totp: 13.0.0-dev.0
  - viewer: 4.0.0
  - webhook_listeners: 1.2.0
  - workflowengine: 2.13.0
Disabled:
  - accessibility: 1.10.0
  - activity: 4.0.0 (installed 2.13.4)
  - admin_audit: 1.21.0
  - bruteforcesettings: 4.0.0 (installed 2.0.1)
  - circles: 31.0.0 (installed 26.0.0)
  - comments: 1.21.0 (installed 1.10.0)
  - contactsinteraction: 1.12.1 (installed 1.1.0)
  - dashboard: 7.11.0 (installed 7.0.0)
  - encryption: 2.19.0
  - federation: 1.21.0 (installed 1.10.1)
  - files_external: 1.23.0
  - files_rightclick: 1.6.0 (installed 1.6.0)
  - files_videoplayer: 1.13.0
  - firstrunwizard: 4.0.0 (installed 2.9.0)
  - logreader: 4.0.0 (installed 2.5.0)
  - nextcloud_announcements: 3.0.0 (installed 1.9.0)
  - notifications: 4.0.0 (installed 2.8.0)
  - password_policy: 3.0.0 (installed 1.18.0)
  - photos: 4.0.0 (installed 1.2.3)
  - privacy: 3.0.0 (installed 1.4.0)
  - recommendations: 4.0.0 (installed 0.8.0)
  - related_resources: 2.0.0 (installed 1.1.0-alpha1)
  - serverinfo: 3.0.0 (installed 1.10.0)
  - sharebymail: 1.21.0 (installed 1.10.0)
  - support: 3.0.0 (installed 1.3.0)
  - survey_client: 3.0.0 (installed 1.8.0)
  - suspicious_login: 9.0.1
  - systemtags: 1.21.1 (installed 1.10.0)
  - text: 5.0.2 (installed 3.1.0)
  - twofactor_nextcloud_notification: 5.0.0
  - updatenotification: 1.21.0 (installed 1.10.0)
  - user_ldap: 1.22.0
  - user_status: 1.11.0 (installed 1.0.1)
  - weather_status: 1.11.0 (installed 1.0.0)
Nextcloud Signing status

Nextcloud Logs

Additional info

Issue both exists with new installs and existing installs with major upgrades.
Issue is tested with Nextcloud 31.0.13 and 32.0.5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue by uploading images without opening their folder, then run php occ background-job:worker while monitoring the preview path with inotifywait -m -r -e create. Trace the background preview-generation entry point responsible for max.jpg creation. Done means automatic jobs no longer create unused max.jpg previews, while previews still appear when folders are browsed on demand.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.