Trashbin view wrong and inconsistent

Nextcloud version (eg, 20.0.5): 21.0.1
Operating system and version (eg, Ubuntu 20.04): Debian bullseye
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.48
PHP version (eg, 7.4): php7.4

The issue you are facing:

I have the situation that I have 3 different trashbin views on 3 loadbalanced nextcloud hosts
On node 1 I see one file and one folder.
On node2 I see nothing (empty trashbin)
On node3 I see one folder.

node1:


node2:

node3:

When I try to remove the files within the GUI I get an error (“Error while removing file from trashbin”), which is quite logical because they are not there physically.

I did then "occ trashbin:cleanup " command, nothing changed.
On the file system I have no files_trashbin directory.
The table oc_filecache in the database has 4887 entries for my user.

I tried some workarounds from this article Can't access to the trashbin - #17 by FernandoJG but it did not help (in fact inserting the ‘int’ patch made my nextcloud unusable).

So my questions are the following:

  1. How can I act to get a reasonable, consistent view of the trashbin ?
  2. Why are the non-existing trashbin entries still stored in the database? This blows up the table oc_filecache which has meanwhile ~ 6.7 Million records.

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

Steps to replicate it:

  1. Delete some files
  2. Go into trashbin
  3. Compare on all web servers

The output of your Nextcloud log in Admin > Logging:

Fatal    webdav             Exception: Failed to remove item from trashbin at apps/groupfolders/lib/Trash/TrashBackend.php line 163            2021-06-25T12:00:35+02:00

                               0. apps/files_trashbin/lib/Trash/TrashManager.php line 69
                                  OCA\GroupFolders\Trash\TrashBackend->removeItem(

                                  )
                               1. .../files_trashbin/lib/Sabre/AbstractTrash.php line 90
                                  OCA\Files_Trashbin\Trash\TrashManager->removeItem(

                                  )
                               2. 3rdparty/sabre/dav/lib/DAV/Tree.php line 179
                                  OCA\Files_Trashbin\Sabre\AbstractTrash->delete(

                                  )
                               3. 3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 281
                                  Sabre\DAV\Tree->delete(
                                                                                                                                                                           
                                  )                                                                                                                                        
                               4. 3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
                                  Sabre\DAV\CorePlugin->httpDelete(

                                  )
                               5. 3rdparty/sabre/dav/lib/DAV/Server.php line 472
                                  Sabre\DAV\Server->emit(

                                  )
                               6. 3rdparty/sabre/dav/lib/DAV/Server.php line 253
                                  Sabre\DAV\Server->invokeMethod(

                                  )
                               7. 3rdparty/sabre/dav/lib/DAV/Server.php line 321
                                  Sabre\DAV\Server->start(

                                  )
                               8. apps/dav/lib/Server.php line 332
                                  Sabre\DAV\Server->exec(

                                  )
                               9. apps/dav/appinfo/v2/remote.php line 35
                                  OCA\DAV\Server->exec(

                                  )
                              10. remote.php line 167
                                  require_once("\/srv\/node3.web.nextcloud....\/nextcloud\/apps\/dav\/appinfo\/v2\/remote.php")

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

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "node3.web.nextcloud.example.com",
            "nextcloud.example.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "21.0.1.1",
        "overwrite.cli.url": "https:\/\/nextcloud.example.com",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "overwrite.host": "nextcloud.example.com",
        "overwriteprotocol": "https",
        "memcache.local": "\\OC\\Memcache\\Memcached",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": "6379",
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "updater.release.channel": "stable",
        "trashbin_retention_obligation": "92",
        "defaultapp": "files",
        "logtimezone": "Europe\/Zurich",
        "log_rotate_size": "943718400",
        "default_phone_region": "CH",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "skeletondirectory": "\/srv\/node3.web.nextcloud.example.com\/nextcloud\/skeleton-template",
        "theme": "",
        "lost_password_link": "disabled"
    },
    "apps": {
        "accessibility": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.7.0"
        },
        "activity": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "2.14.3"
        },
        "backgroundjob": {
            "lastjob": "690108"
        },
        "bruteforcesettings": {
            "installed_version": "2.1.0",
            "types": "",
            "enabled": "yes"
        },
        "cloud_federation_api": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "1.4.0"
        },
        "comments": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "1.11.0"
        },
        "contacts": {
            "enabled": "yes",
            "types": "dav",
            "installed_version": "3.5.1"
        },
        "contactsinteraction": {
            "types": "dav",
            "enabled": "yes",
            "installed_version": "1.2.0"
        },
        "core": {
            "vendor": "nextcloud",
            "public_webdav": "dav\/appinfo\/v1\/publicwebdav.php",
            "public_files": "files_sharing\/public.php",
            "moveavatarsdone": "yes",
            "previewsCleanedUp": "1",
            "oc.integritycheck.checker": "{\"core\":{\"FILE_MISSING\":{\"3rdparty\\\/aws\\\/aws-sdk-php\\\/src\\\/data\\\/accessanalyzer\\\/2019-11-01\\\/api-2.json.php\":{\"expected\":\"8b3ccf6e51c92a8cdbf5b21d5f8d0cc97162e994f8fa4e7f7f47872d585c47...
                       "backgroundjobs_mode": "cron",
            "installed.bundles": "[\"CoreBundle\"]",
            "lastupdateResult": "{\"version\":\"21.0.2.1\",\"versionstring\":\"Nextcloud 21.0.2\",\"url\":\"https:\\\/\\\/download.nextcloud.com\\\/server\\\/releases\\\/nextcloud-21.0.2.zip\",\"web\":\"https:\\\/\\\/docs.nextcloud.com\\\/server\\\/21\\\/admin_manual\\\/maintenance\\\/upgrade.html\",\"changes\":\"https:\\\/\\\/updates.nextcloud.com\\\/changelog_server\\\/?version=21.0.2\",\"autoupdater\":\"1\",\"eol\":\"0\"}",
            "installedat": "1622577491.5242",
            "lastcron": "1624530324",
            "lastupdatedat": "1624566757",
            "theming.variables": "6f4ef1240090ef23eef18cef9374d344"
        },
        "dashboard": {
            "installed_version": "7.1.0",
            "types": "",
            "enabled": "yes"
        },
        "dav": {
            "types": "filesystem",
            "enabled": "yes",
            "chunks_migrated": "1",
            "installed_version": "1.17.1",
            "regeneratedBirthdayCalendarsForYearFix": "yes",
            "buildCalendarSearchIndex": "yes",
            "buildCalendarReminderIndex": "yes"
        },
        "federatedfilesharing": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.11.0"
        },
        "federation": {
            "types": "authentication",
            "enabled": "yes",
            "installed_version": "1.11.0"
        },
        "files": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "1.16.0",
            "cronjob_scan_files": "8500"
        },
        "files_pdfviewer": {
            "types": "",
            "enabled": "yes",
            "installed_version": "2.1.0"
        },
        "files_rightclick": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.0.0"
        },
        "files_sharing": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "1.13.1"
        },
        "files_trashbin": {
            "installed_version": "1.11.0",
            "types": "filesystem,dav",
            "enabled": "yes"
        },
        "files_versions": {
            "types": "filesystem,dav",
            "enabled": "yes",
            "installed_version": "1.14.0"
        },
        "files_videoplayer": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.10.0"
        },
        "firstrunwizard": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "2.10.0"
        },
        "groupfolders": {
            "installed_version": "9.0.2",
            "types": "filesystem,dav",
            "enabled": "yes"
        },
        "logreader": {
            "types": "",
            "enabled": "yes",
            "installed_version": "2.6.0"
        },
        "lookup_server_connector": {
            "types": "authentication",
            "enabled": "yes",
            "installed_version": "1.9.0"
        },
        "nextcloud_announcements": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "1.10.0",
            "pub_date": "Thu, 24 Oct 2019 00:00:00 +0200"
        },
        "notifications": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "2.9.0"
        },
        "oauth2": {
            "types": "authentication",
            "enabled": "yes",
            "installed_version": "1.9.0"
        },
        "password_policy": {
            "enabled": "yes",
            "types": "authentication",
            "installed_version": "1.11.0"
        },
        "photos": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.3.0"
        },
        "previewgenerator": {
            "enabled": "yes",
            "types": "filesystem",
            "installed_version": "3.1.1",
            "pid": "2476"
        },
        "privacy": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.5.0"
        },
        "provisioning_api": {
            "types": "prevent_group_restriction",
            "enabled": "yes",
            "installed_version": "1.11.0"
        },
        "recommendations": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.0.0"
        },
        "serverinfo": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.11.0"
        },
        "settings": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.3.0"
        },
        "sharebymail": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "1.11.0"
        },
        "support": {
            "types": "session",
            "enabled": "yes",
            "installed_version": "1.4.0",
            "last_notification": "1617999316",
            "SwitchUpdaterServerHasRun": "yes"
        },
        "survey_client": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.9.0"
        },
        "systemtags": {
            "types": "logging",
            "enabled": "yes",
            "installed_version": "1.11.0"
        },
        "text": {
            "types": "dav",
            "enabled": "yes",
            "installed_version": "3.2.0"
        },
        "theming": {
            "types": "logging",
            "enabled": "yes",
            "color": "#697d91",
            "logoMime": "image\/svg+xml",
            "installed_version": "1.12.0"
        },
        "twofactor_backupcodes": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.10.0"
        },
        "updatenotification": {
            "types": "",
            "enabled": "yes",
            "contacts": "3.5.1",
            "installed_version": "1.11.0",
            "previewgenerator": "3.1.1",
            "core": "21.0.2.1",
            "update_check_errors": "0",
            "groupfolders": "9.0.2"
        },
        "user_ldap": {
            "s01ldap_matching_rule_in_chain_state": "unavailable",
            "types": "authentication",
            "enabled": "yes",
            "installed_version": "1.11.0",
            "s01ldap_backup_port": "636",
            (...)
            "s01ldap_port": "636",
        },
        "user_status": {
            "installed_version": "1.1.1",
            "types": "",
            "enabled": "yes"
        },
        "viewer": {
            "types": "",
            "enabled": "yes",
            "installed_version": "1.5.0"
        },
        "weather_status": {
            "installed_version": "1.1.0",
            "types": "",
            "enabled": "yes"
        },
        "workflowengine": {
            "types": "filesystem",
            "enabled": "yes",
            "installed_version": "2.3.0"
        }
    }
}

The output of your Apache/nginx/system log in /var/log/____:

XXX.YYY.227.45 - - [25/Jun/2021:10:15:56 +0200] "POST /index.php/apps/text/session/sync HTTP/2.0" 200 1366 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Fire
fox/89.0"
XXX.YYY.227.45 - - [25/Jun/2021:10:15:57 +0200] "PROPFIND /remote.php/dav/trashbin/dxk1/trash HTTP/2.0" 207 1669 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"
XXX.YYY.227.45 - - [25/Jun/2021:10:15:59 +0200] "POST /index.php/apps/text/session/sync HTTP/2.0" 200 1366 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"
XXX.YYY.227.45 - - [25/Jun/2021:10:16:00 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/2.0" 304 182 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"
XXX.YYY.227.45 - - [25/Jun/2021:10:16:02 +0200] "POST /index.php/apps/text/session/sync HTTP/2.0" 200 1366 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"
XXX.YYY.227.45 - - [25/Jun/2021:10:16:06 +0200] "POST /index.php/apps/text/session/sync HTTP/2.0" 200 1366 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0"

Update:
I could solve the problem now by executing

occ groupfolders:trashbin:cleanup

on all nodes (and will add this as daily cron job), but it would be nice to have a more generically solution for this by nextcloud itself.

Meanwhile I changed to nextcloud 21.0.3. (unchanged settings).
When I delete some files/folders within a groupfolder I can see them in my trashbin folder - as long as the loadbalancer shifts me to another nextcloud node. Then I see only deleted files from regular (not groupfolder) directories.
Physically the deleted directory is under $NEXTCLOUD-DATA/__groupfolders/trash/4/TEST.d1625216802/
(the original name before deletion had been “TEST”, not “TEST.d$unix-timestamp”)

Neither occ files:scan $uid nor occ groupfolders:scan $gid have any effect.

=> result: When you delete any files from a shared groupfolder you will never see them again in your trashbin as soon as you are loadbalanced to another node.