Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files still exists after retention time #121

Open
inno-it opened this issue May 28, 2021 · 18 comments
Open

Files still exists after retention time #121

inno-it opened this issue May 28, 2021 · 18 comments

Comments

@inno-it
Copy link

inno-it commented May 28, 2021

Hello,

I have the problem, that old files won't get deleted.
The files are uploaded to an external storage and getting tagged properly.
But after the retention time the file still exists.

Steps to reproduce

  1. Upload files
  2. Files get correctly tagged
  3. File won't get deleted after retentinon

Operating system: Debian 10
Web server: Apache 2.4.38
Database: MySql
PHP version: 7.3.27
Nextcloud version: 21.0.2

List of activated apps:

  • accessibility: 1.7.0
  • activity: 2.14.3
  • bruteforcesettings: 2.1.0
  • cloud_federation_api: 1.4.0
  • contactsinteraction: 1.2.0
  • dav: 1.17.1
  • federatedfilesharing: 1.11.0
  • federation: 1.11.0
  • files: 1.16.0
  • files_automatedtagging: 1.11.0
  • files_external: 1.12.0
  • files_retention: 1.10.1
  • files_rightclick: 1.0.0
  • files_sharing: 1.13.1
  • files_trashbin: 1.11.0
  • files_versions: 1.14.0
  • logreader: 2.6.0
  • lookup_server_connector: 1.9.0
  • notifications: 2.9.0
  • oauth2: 1.9.0
  • password_policy: 1.11.0
  • privacy: 1.5.0
  • provisioning_api: 1.11.0
  • recommendations: 1.0.0
  • serverinfo: 1.11.0
  • settings: 1.3.0
  • sharebymail: 1.11.0
  • support: 1.4.0
  • survey_client: 1.9.0
  • systemtags: 1.11.0
  • text: 3.2.0
  • theming: 1.12.0
  • twofactor_backupcodes: 1.10.0
  • updatenotification: 1.11.0
  • viewer: 1.5.0
  • workflowengine: 2.3.0

Best regards!

@bjo81
Copy link

bjo81 commented Aug 15, 2021

Same issue here:
Screenshot 2021-08-15 at 11-53-53

Retention time for tag "signal" is one day after creation, so it should have been deleted.

@JensSpanier
Copy link

I think since update to Nextcloud 22 I have the same issue:

Bildschirmfoto 2021-11-02 um 10 17 09
Bildschirmfoto 2021-11-02 um 10 17 30

@LocalAreaNitwit
Copy link

Exactly the same issue here.
2022-01-16-125855_843x267_scrot

2022-01-16-125926_1798x396_scrot

Nextcloud Official docker image version 23.0.0.

@Kryptopirat
Copy link

Same here.

@nickvergessen
Copy link
Member

Are your background jobs running properly?
Are they executed with the correct user so it can remove files from the data directory?
Is there anything in the nextcloud.log ?

@manu-p
Copy link

manu-p commented Oct 11, 2022

Hi, same issue here.

NC 24.0.5 / Retention 1.13.2

Files that have become eligible to deletion are not deleted, while notification is being done one day before.

Background jobs are running properly, using the same user as files owner (www-data) and here's what you find for the last 2 days in nextcloud.log (grep retention nextcloud.log):

{"reqId":"KJY85fZ9RBvAL3GUMgrc","level":3,"time":"2022-10-10T08:25:21+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Call to a member function getUID() on null","userAgent":"--","version":"24.0.5.1","exception":{"Exception":"Error","Message":"Call to a member function getUID() on null","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":157,"function":"notifyNode","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":151,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","Line":272,"CustomMessage":"--"}}
{"reqId":"iPsCyIYb1HfGlg2KCtHz","level":3,"time":"2022-10-10T09:05:04+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"/NC backups/nextcloud-1week has no owner","userAgent":"--","version":"24.0.5.1","exception":{"Exception":"OCP\\Files\\NotFoundException","Message":"/NC backups/nextcloud-1week has no owner","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/Filesystem.php","line":805,"function":"getOwner","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Storage.php","line":111,"function":"getOwner","class":"OC\\Files\\Filesystem","type":"::"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Storage.php","line":226,"function":"getUidAndFilename","class":"OCA\\Files_Versions\\Storage","type":"::"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Hooks.php","line":82,"function":"markDeletedFile","class":"OCA\\Files_Versions\\Storage","type":"::"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Hook.php","line":106,"function":"pre_remove_hook","class":"OCA\\Files_Versions\\Hooks","type":"::"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1290,"function":"emit","class":"OC_Hook","type":"::"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1160,"function":"runHooks","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":355,"function":"basicOperation","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/Folder.php","line":388,"function":"rmdir","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":242,"function":"delete","class":"OC\\Files\\Node\\Folder","type":"->"},{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":154,"function":"expireNode","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":151,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/lib/private/Files/View.php","Line":1702,"CustomMessage":"--"}}
{"reqId":"iPsCyIYb1HfGlg2KCtHz","level":3,"time":"2022-10-10T09:05:04+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Call to a member function getUID() on null","userAgent":"--","version":"24.0.5.1","exception":{"Exception":"Error","Message":"Call to a member function getUID() on null","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":157,"function":"notifyNode","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":151,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","Line":272,"CustomMessage":"--"}}
{"reqId":"2feLW1pMbtqgDKcsWFQS","level":3,"time":"2022-10-11T08:30:03+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"/NC backups/nextcloud-1day has no owner","userAgent":"--","version":"24.0.5.1","exception":{"Exception":"OCP\\Files\\NotFoundException","Message":"/NC backups/nextcloud-1day has no owner","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/Filesystem.php","line":805,"function":"getOwner","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Storage.php","line":111,"function":"getOwner","class":"OC\\Files\\Filesystem","type":"::"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Storage.php","line":226,"function":"getUidAndFilename","class":"OCA\\Files_Versions\\Storage","type":"::"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Hooks.php","line":82,"function":"markDeletedFile","class":"OCA\\Files_Versions\\Storage","type":"::"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Hook.php","line":106,"function":"pre_remove_hook","class":"OCA\\Files_Versions\\Hooks","type":"::"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1290,"function":"emit","class":"OC_Hook","type":"::"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1160,"function":"runHooks","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":355,"function":"basicOperation","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/Folder.php","line":388,"function":"rmdir","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":242,"function":"delete","class":"OC\\Files\\Node\\Folder","type":"->"},{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":154,"function":"expireNode","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":151,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/lib/private/Files/View.php","Line":1702,"CustomMessage":"--"}}
{"reqId":"2feLW1pMbtqgDKcsWFQS","level":3,"time":"2022-10-11T08:30:03+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Call to a member function getUID() on null","userAgent":"--","version":"24.0.5.1","exception":{"Exception":"Error","Message":"Call to a member function getUID() on null","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":157,"function":"notifyNode","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":151,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","Line":272,"CustomMessage":"--"}}
{"reqId":"ScFxtBuZzVSvqPoNoufR","level":3,"time":"2022-10-11T09:05:20+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"/NC backups/nextcloud-1week has no owner","userAgent":"--","version":"24.0.5.1","exception":{"Exception":"OCP\\Files\\NotFoundException","Message":"/NC backups/nextcloud-1week has no owner","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/Filesystem.php","line":805,"function":"getOwner","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Storage.php","line":111,"function":"getOwner","class":"OC\\Files\\Filesystem","type":"::"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Storage.php","line":226,"function":"getUidAndFilename","class":"OCA\\Files_Versions\\Storage","type":"::"},{"file":"/var/www/nextcloud/apps/files_versions/lib/Hooks.php","line":82,"function":"markDeletedFile","class":"OCA\\Files_Versions\\Storage","type":"::"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Hook.php","line":106,"function":"pre_remove_hook","class":"OCA\\Files_Versions\\Hooks","type":"::"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1290,"function":"emit","class":"OC_Hook","type":"::"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1160,"function":"runHooks","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":355,"function":"basicOperation","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/Folder.php","line":388,"function":"rmdir","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":242,"function":"delete","class":"OC\\Files\\Node\\Folder","type":"->"},{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":154,"function":"expireNode","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":151,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/lib/private/Files/View.php","Line":1702,"CustomMessage":"--"}}
{"reqId":"ScFxtBuZzVSvqPoNoufR","level":3,"time":"2022-10-11T09:05:20+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Call to a member function getUID() on null","userAgent":"--","version":"24.0.5.1","exception":{"Exception":"Error","Message":"Call to a member function getUID() on null","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","line":157,"function":"notifyNode","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\Files_Retention\\BackgroundJob\\RetentionJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":95,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":151,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php","Line":272,"CustomMessage":"--"}}

@manu-p
Copy link

manu-p commented Oct 13, 2022

Hi, is there anything more I can provide to help to sort it out?

@nickvergessen
Copy link
Member

Currently there is a lack of time on my side, but I will make sure to look into it before releasing the next version

@manu-p
Copy link

manu-p commented Oct 13, 2022

Thanks @nickvergessen, we look forward to have this "Featured" app running as it is supposed to.

@Brombotron
Copy link

Hi, I do have a similar problem, although not exactly the same.
In my instance of nextcloud file retention only works with certain tags.
If I create a new tag and set up the retention, everything works fine for a while but stops working after a few weeks/months.
Setting up the retention again does not help, the only workaround I could find, is to create a new tag and set up the retention again.

Backgroundjobs are running properly.
NC 25.0.3 | Retention 1.14.1

List of active apps

Activities for shared file downloads 1.15.0

Activity 2.17.0

Auditing / Logging 1.15.0

Collaborative tags 1.15.0

Comments 1.15.0

Contacts Interaction 1.6.0

Dashboard 7.5.0

Deleted files 1.15.0

Federation 1.15.0

File access control 1.15.1

File sharing 1.17.0

Files automated tagging 1.15.0

Log Reader 2.10.0

Monitoring 1.15.0

Nextcloud announcements 1.14.0

Notifications 2.13.1

Password policy 1.15.0

PDF viewer 2.6.0

Photos 2.0.1

Privacy 1.9.0

Recommendations 1.4.0

Related Resources 1.0.3

Retention 1.14.1

Right click 1.4.0

Share by mail 1.15.0

ShareRenamer 3.1.0

Support 1.8.0

Text 3.6.0

Update notification 1.15.0

Usage survey 1.13.0

User status 1.5.0

Versions 1.18.0

Weather status 1.5.0

Most relevant part in the logfiles I could find in context with tags

data/nextcloud.log:{"reqId":"S0mNvea0cmvcRQMkCguN","level":3,"time":"2023-01-19 12:31:49","remoteAddr":"172.19.0.2","user":"rnd","app":"no app in context","method":"GET","url":"/ocs/v2.php/search/providers/systemtags/search?term=devui&from=%2Fapps%2Ffiles%2F%3Fdir%3D%2FDatenaustausch%2FDownload%2FSupport%26fileid%3D2852476","message":"An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0","version":"25.0.3.2","exception":{"Exception":"Doctrine\\DBAL\\Exception\\ConnectionLost","Message":"An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away","Code":2006,"Trace":[{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1780,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},{"__class__":"Doctrine\\DBAL\\Query"}]},{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1719,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},{"__class__":"Doctrine\\DBAL\\Query"}]},{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1067,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},"SELECTfile.fileid, storage, path, path_hash, file.parent, file.name, mimetype, mimepart, size, mtime, storage_mtime, encrypted, etag, permissions, checksum, unencrypted_sizeFROMoc_filecache fileLEFT JOINoc_vcategory_to_object tagmapONfile.fileid=tagmap.objidLEFT JOINoc_systemtag_object_mapping systemtagmap ON (file.fileid=systemtagmap.objectid) AND (systemtagmap.objecttype= ?) LEFT JOINoc_vcategory tag ON (tagmap.type=tag.type) AND (tagmap.categoryid=tag.id) AND (tag.type = ?) AND (tag.uid= ?) LEFT JOINoc_systemtag systemtag ON (systemtag.id=systemtagmap.systemtagid) AND (systemtag.visibility = ?) WHERE ((tag.category COLLATE utf8mb4_general_ci LIKE ?) OR (systemtag.name COLLATE utf8mb4_general_ci LIKE ?)) AND (((storage = ?) AND ((path = ?) OR (path LIKE ?))) OR ((storage = ?) AND ((path = ?) OR (path LIKE ?))) OR ((storage = ?) AND ((path = ?) OR (pathLIKE ?)))) ORDER BYmtime+ ? desc LIMIT 5",["files","files","rnd",true,"%devui%","And 11 more entries, set log level to debug to see all entries"],[2,2,2,2,2,"And 11 more entries, set log level to debug to see all entries"]]},{"file":"/nextcloud/lib/private/DB/Connection.php","line":261,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECTfile.fileid, storage, path, path_hash, file.parent, file.name, mimetype, mimepart, size, mtime, storage_mtime, encrypted, etag, permissions, checksum, unencrypted_sizeFROMoc_filecache fileLEFT JOINoc_vcategory_to_object tagmapONfile.fileid=tagmap.objidLEFT JOINoc_systemtag_object_mapping systemtagmap ON (file.fileid=systemtagmap.objectid) AND (systemtagmap.objecttype= ?) LEFT JOINoc_vcategory tag ON (tagmap.type=tag.type) AND (tagmap.categoryid=tag.id) AND (tag.type = ?) AND (tag.uid= ?) LEFT JOINoc_systemtag systemtag ON (systemtag.id=systemtagmap.systemtagid) AND (systemtag.visibility = ?) WHERE ((tag.category COLLATE utf8mb4_general_ci LIKE ?) OR (systemtag.name COLLATE utf8mb4_general_ci LIKE ?)) AND (((storage = ?) AND ((path = ?) OR (path LIKE ?))) OR ((storage = ?) AND ((path = ?) OR (path LIKE ?))) OR ((storage = ?) AND ((path = ?) OR (pathLIKE ?)))) ORDER BYmtime+ ? desc LIMIT 5",["files","files","rnd",true,"%devui%","And 11 more entries, set log level to debug to see all entries"],[2,2,2,2,2,"And 11 more entries, set log level to debug to see all entries"],null]},{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":345,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECTfile.fileid, storage, path, path_hash, file.parent, file.name, mimetype, mimepart, size, mtime, storage_mtime, encrypted, etag, permissions, checksum, unencrypted_sizeFROMoc_filecache fileLEFT JOINoc_vcategory_to_object tagmapONfile.fileid=tagmap.objidLEFT JOINoc_systemtag_object_mapping systemtagmap ON (file.fileid=systemtagmap.objectid) AND (systemtagmap.objecttype= :dcValue3) LEFT JOINoc_vcategory tag ON (tagmap.type=tag.type) AND (tagmap.categoryid=tag.id) AND (tag.type = :dcValue1) AND (tag.uid= :dcValue2) LEFT JOINoc_systemtag systemtag ON (systemtag.id=systemtagmap.systemtagid) AND (systemtag.visibility = :dcValue4) WHERE ((tag.category COLLATE utf8mb4_general_ci LIKE :dcValue5) OR (systemtag.name COLLATE utf8mb4_general_ci LIKE :dcValue6)) AND (((storage = :dcValue7) AND ((path = :dcValue8) OR (path LIKE :dcValue9))) OR ((storage = :dcValue10) AND ((path = :dcValue11) OR (path LIKE :dcValue12))) OR ((storage = :dcValue13) AND ((path = :dcValue14) OR (pathLIKE :dcValue15)))) ORDER BYmtime+ :dcValue16 desc LIMIT 5",["files","rnd","files",true,"%devui%","And 11 more entries, set log level to debug to see all entries"],[2,2,2,2,2,"And 11 more entries, set log level to debug to see all entries"]]},{"file":"/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":281,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/nextcloud/lib/private/Files/Cache/QuerySearchHelper.php","line":152,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/nextcloud/lib/private/Files/Node/Folder.php","line":266,"function":"searchInCaches","class":"OC\\Files\\Cache\\QuerySearchHelper","type":"->","args":[{"__class__":"OC\\Files\\Search\\SearchQuery"},[{"__class__":"OC\\Files\\Cache\\Wrapper\\CacheJail"},{"__class__":"OCA\\FilesAccessControl\\CacheWrapper"},{"__class__":"OCA\\FilesAccessControl\\CacheWrapper"}]]},{"function":"search","class":"OC\\Files\\Node\\Folder","type":"->","args":[{"__class__":"OC\\Files\\Search\\SearchQuery"}]},{"file":"/nextcloud/lib/private/Files/Node/LazyFolder.php","line":72,"function":"call_user_func_array","args":[[{"__class__":"OC\\Files\\Node\\Folder"},"search"],[{"__class__":"OC\\Files\\Search\\SearchQuery"}]]},{"file":"/nextcloud/lib/private/Files/Node/LazyFolder.php","line":433,"function":"__call","class":"OC\\Files\\Node\\LazyFolder","type":"->","args":["search",[{"__class__":"OC\\Files\\Search\\SearchQuery"}]]},{"file":"/nextcloud/apps/systemtags/lib/Search/TagSearchProvider.php","line":131,"function":"search","class":"OC\\Files\\Node\\LazyFolder","type":"->","args":[{"__class__":"OC\\Files\\Search\\SearchQuery"}]},{"file":"/nextcloud/lib/private/Search/SearchComposer.php","line":160,"function":"search","class":"OCA\\SystemTags\\Search\\TagSearchProvider","type":"->","args":[{"__class__":"OC\\User\\User"},{"__class__":"OC\\Search\\SearchQuery"}]},{"file":"/nextcloud/core/Controller/UnifiedSearchController.php","line":105,"function":"search","class":"OC\\Search\\SearchComposer","type":"->","args":[{"__class__":"OC\\User\\User"},"systemtags",{"__class__":"OC\\Search\\SearchQuery"}]},{"file":"/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"search","class":"OC\\Core\\Controller\\UnifiedSearchController","type":"->","args":["systemtags","devui",null,null,null,"/apps/files/?dir=/Datenaustausch/Download/Support&fileid=2852476"]},{"file":"/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\UnifiedSearchController"},"search"]},{"file":"/nextcloud/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\UnifiedSearchController"},"search"]},{"file":"/nextcloud/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\UnifiedSearchController","search",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},["systemtags","ocs.core.UnifiedSearch.search"]]},{"file":"/nextcloud/ocs/v1.php","line":63,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/ocsapp/search/providers/systemtags/search"]},{"file":"/nextcloud/ocs/v2.php","line":23,"args":["/nextcloud/ocs/v1.php"],"function":"require_once"}],"File":"/nextcloud/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php","Line":101,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away","Code":2006,"Trace":[{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":94,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::","args":[{"__class__":"PDOException","errorInfo":["HY000",2006,"MySQL server has gone away"]}]},{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1057,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDO\\Statement","type":"->","args":[]},{"file":"/nextcloud/lib/private/DB/Connection.php","line":261,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECTfile.fileid, storage, path, path_hash, file.parent, file.name, mimetype, mimepart, size, mtime, storage_mtime, encrypted, etag, permissions, checksum, unencrypted_sizeFROMoc_filecache fileLEFT JOINoc_vcategory_to_object tagmapONfile.fileid=tagmap.objidLEFT JOINoc_systemtag_object_mapping systemtagmap ON (file.fileid=systemtagmap.objectid) AND (systemtagmap.objecttype= ?) LEFT JOINoc_vcategory tag ON (tagmap.type=tag.type) AND (tagmap.categoryid=tag.id) AND (tag.type = ?) AND (tag.uid= ?) LEFT JOINoc_systemtag systemtag ON (systemtag.id=systemtagmap.systemtagid) AND (systemtag.visibility = ?) WHERE ((tag.category COLLATE utf8mb4_general_ci LIKE ?) OR (systemtag.name COLLATE utf8mb4_general_ci LIKE ?)) AND (((storage = ?) AND ((path = ?) OR (path LIKE ?))) OR ((storage = ?) AND ((path = ?) OR (path LIKE ?))) OR ((storage = ?) AND ((path = ?) OR (pathLIKE ?)))) ORDER BYmtime+ ? desc LIMIT 5",["files","files","rnd",true,"%devui%","And 11 more entries, set log level to debug to see all entries"],[2,2,2,2,2,"And 11 more entries, set log level to debug to see all entries"],null]},{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":345,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECTfile.fileid, storage, path, path_hash, file.parent, file.name, mimetype, mimepart, size, mtime, storage_mtime, encrypted, etag, permissions, checksum, unencrypted_sizeFROMoc_filecache fileLEFT JOINoc_vcategory_to_object tagmapONfile.fileid=tagmap.objidLEFT JOINoc_systemtag_object_mapping systemtagmap ON (file.fileid=systemtagmap.objectid) AND (systemtagmap.objecttype= :dcValue3) LEFT JOINoc_vcategory tag ON (tagmap.type=tag.type) AND (tagmap.categoryid=tag.id) AND (tag.type = :dcValue1) AND (tag.uid= :dcValue2) LEFT JOINoc_systemtag systemtag ON (systemtag.id=systemtagmap.systemtagid) AND (systemtag.visibility = :dcValue4) WHERE ((tag.category COLLATE utf8mb4_general_ci LIKE :dcValue5) OR (systemtag.name COLLATE utf8mb4_general_ci LIKE :dcValue6)) AND (((storage = :dcValue7) AND ((path = :dcValue8) OR (path LIKE :dcValue9))) OR ((storage = :dcValue10) AND ((path = :dcValue11) OR (path LIKE :dcValue12))) OR ((storage = :dcValue13) AND ((path = :dcValue14) OR (pathLIKE :dcValue15)))) ORDER BYmtime+ :dcValue16 desc LIMIT 5",["files","rnd","files",true,"%devui%","And 11 more entries, set log level to debug to see all entries"],[2,2,2,2,2,"And 11 more entries, set log level to debug to see all entries"]]},{"file":"/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":281,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/nextcloud/lib/private/Files/Cache/QuerySearchHelper.php","line":152,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/nextcloud/lib/private/Files/Node/Folder.php","line":266,"function":"searchInCaches","class":"OC\\Files\\Cache\\QuerySearchHelper","type":"->","args":[{"__class__":"OC\\Files\\Search\\SearchQuery"},[{"__class__":"OC\\Files\\Cache\\Wrapper\\CacheJail"},{"__class__":"OCA\\FilesAccessControl\\CacheWrapper"},{"__class__":"OCA\\FilesAccessControl\\CacheWrapper"}]]},{"function":"search","class":"OC\\Files\\Node\\Folder","type":"->","args":[{"__class__":"OC\\Files\\Search\\SearchQuery"}]},{"file":"/nextcloud/lib/private/Files/Node/LazyFolder.php","line":72,"function":"call_user_func_array","args":[[{"__class__":"OC\\Files\\Node\\Folder"},"search"],[{"__class__":"OC\\Files\\Search\\SearchQuery"}]]},{"file":"/nextcloud/lib/private/Files/Node/LazyFolder.php","line":433,"function":"__call","class":"OC\\Files\\Node\\LazyFolder","type":"->","args":["search",[{"__class__":"OC\\Files\\Search\\SearchQuery"}]]},{"file":"/nextcloud/apps/systemtags/lib/Search/TagSearchProvider.php","line":131,"function":"search","class":"OC\\Files\\Node\\LazyFolder","type":"->","args":[{"__class__":"OC\\Files\\Search\\SearchQuery"}]},{"file":"/nextcloud/lib/private/Search/SearchComposer.php","line":160,"function":"search","class":"OCA\\SystemTags\\Search\\TagSearchProvider","type":"->","args":[{"__class__":"OC\\User\\User"},{"__class__":"OC\\Search\\SearchQuery"}]},{"file":"/nextcloud/core/Controller/UnifiedSearchController.php","line":105,"function":"search","class":"OC\\Search\\SearchComposer","type":"->","args":[{"__class__":"OC\\User\\User"},"systemtags",{"__class__":"OC\\Search\\SearchQuery"}]},{"file":"/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"search","class":"OC\\Core\\Controller\\UnifiedSearchController","type":"->","args":["systemtags","devui",null,null,null,"/apps/files/?dir=/Datenaustausch/Download/Support&fileid=2852476"]},{"file":"/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\UnifiedSearchController"},"search"]},{"file":"/nextcloud/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\UnifiedSearchController"},"search"]},{"file":"/nextcloud/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\UnifiedSearchController","search",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},["systemtags","ocs.core.UnifiedSearch.search"]]},{"file":"/nextcloud/ocs/v1.php","line":63,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/ocsapp/search/providers/systemtags/search"]},{"file":"/nextcloud/ocs/v2.php","line":23,"args":["/nextcloud/ocs/v1.php"],"function":"require_once"}],"File":"/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":26,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away","Code":"HY000","Trace":[{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","line":92,"function":"execute","class":"PDOStatement","type":"->","args":[null]},{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1057,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDO\\Statement","type":"->","args":[]},{"file":"/nextcloud/lib/private/DB/Connection.php","line":261,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECTfile.fileid, storage, path, path_hash, file.parent, file.name, mimetype, mimepart, size, mtime, storage_mtime, encrypted, etag, permissions, checksum, unencrypted_sizeFROMoc_filecache fileLEFT JOINoc_vcategory_to_object tagmapONfile.fileid=tagmap.objidLEFT JOINoc_systemtag_object_mapping systemtagmap ON (file.fileid=systemtagmap.objectid) AND (systemtagmap.objecttype= ?) LEFT JOINoc_vcategory tag ON (tagmap.type=tag.type) AND (tagmap.categoryid=tag.id) AND (tag.type = ?) AND (tag.uid= ?) LEFT JOINoc_systemtag systemtag ON (systemtag.id=systemtagmap.systemtagid) AND (systemtag.visibility = ?) WHERE ((tag.category COLLATE utf8mb4_general_ci LIKE ?) OR (systemtag.name COLLATE utf8mb4_general_ci LIKE ?)) AND (((storage = ?) AND ((path = ?) OR (path LIKE ?))) OR ((storage = ?) AND ((path = ?) OR (path LIKE ?))) OR ((storage = ?) AND ((path = ?) OR (pathLIKE ?)))) ORDER BYmtime+ ? desc LIMIT 5",["files","files","rnd",true,"%devui%","And 11 more entries, set log level to debug to see all entries"],[2,2,2,2,2,"And 11 more entries, set log level to debug to see all entries"],null]},{"file":"/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":345,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECTfile.fileid, storage, path, path_hash, file.parent, file.name, mimetype, mimepart, size, mtime, storage_mtime, encrypted, etag, permissions, checksum, unencrypted_sizeFROMoc_filecache fileLEFT JOINoc_vcategory_to_object tagmapONfile.fileid=tagmap.objidLEFT JOINoc_systemtag_object_mapping systemtagmap ON (file.fileid=systemtagmap.objectid) AND (systemtagmap.objecttype= :dcValue3) LEFT JOINoc_vcategory tag ON (tagmap.type=tag.type) AND (tagmap.categoryid=tag.id) AND (tag.type = :dcValue1) AND (tag.uid= :dcValue2) LEFT JOINoc_systemtag systemtag ON (systemtag.id=systemtagmap.systemtagid) AND (systemtag.visibility = :dcValue4) WHERE ((tag.category COLLATE utf8mb4_general_ci LIKE :dcValue5) OR (systemtag.name COLLATE utf8mb4_general_ci LIKE :dcValue6)) AND (((storage = :dcValue7) AND ((path = :dcValue8) OR (path LIKE :dcValue9))) OR ((storage = :dcValue10) AND ((path = :dcValue11) OR (path LIKE :dcValue12))) OR ((storage = :dcValue13) AND ((path = :dcValue14) OR (pathLIKE :dcValue15)))) ORDER BYmtime+ :dcValue16 desc LIMIT 5",["files","rnd","files",true,"%devui%","And 11 more entries, set log level to debug to see all entries"],[2,2,2,2,2,"And 11 more entries, set log level to debug to see all entries"]]},{"file":"/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":281,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/nextcloud/lib/private/Files/Cache/QuerySearchHelper.php","line":152,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/nextcloud/lib/private/Files/Node/Folder.php","line":266,"function":"searchInCaches","class":"OC\\Files\\Cache\\QuerySearchHelper","type":"->","args":[{"__class__":"OC\\Files\\Search\\SearchQuery"},[{"__class__":"OC\\Files\\Cache\\Wrapper\\CacheJail"},{"__class__":"OCA\\FilesAccessControl\\CacheWrapper"},{"__class__":"OCA\\FilesAccessControl\\CacheWrapper"}]]},{"function":"search","class":"OC\\Files\\Node\\Folder","type":"->","args":[{"__class__":"OC\\Files\\Search\\SearchQuery"}]},{"file":"/nextcloud/lib/private/Files/Node/LazyFolder.php","line":72,"function":"call_user_func_array","args":[[{"__class__":"OC\\Files\\Node\\Folder"},"search"],[{"__class__":"OC\\Files\\Search\\SearchQuery"}]]},{"file":"/nextcloud/lib/private/Files/Node/LazyFolder.php","line":433,"function":"__call","class":"OC\\Files\\Node\\LazyFolder","type":"->","args":["search",[{"__class__":"OC\\Files\\Search\\SearchQuery"}]]},{"file":"/nextcloud/apps/systemtags/lib/Search/TagSearchProvider.php","line":131,"function":"search","class":"OC\\Files\\Node\\LazyFolder","type":"->","args":[{"__class__":"OC\\Files\\Search\\SearchQuery"}]},{"file":"/nextcloud/lib/private/Search/SearchComposer.php","line":160,"function":"search","class":"OCA\\SystemTags\\Search\\TagSearchProvider","type":"->","args":[{"__class__":"OC\\User\\User"},{"__class__":"OC\\Search\\SearchQuery"}]},{"file":"/nextcloud/core/Controller/UnifiedSearchController.php","line":105,"function":"search","class":"OC\\Search\\SearchComposer","type":"->","args":[{"__class__":"OC\\User\\User"},"systemtags",{"__class__":"OC\\Search\\SearchQuery"}]},{"file":"/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"search","class":"OC\\Core\\Controller\\UnifiedSearchController","type":"->","args":["systemtags","devui",null,null,null,"/apps/files/?dir=/Datenaustausch/Download/Support&fileid=2852476"]},{"file":"/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\UnifiedSearchController"},"search"]},{"file":"/nextcloud/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\UnifiedSearchController"},"search"]},{"file":"/nextcloud/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\UnifiedSearchController","search",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},["systemtags","ocs.core.UnifiedSearch.search"]]},{"file":"/nextcloud/ocs/v1.php","line":63,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/ocsapp/search/providers/systemtags/search"]},{"file":"/nextcloud/ocs/v2.php","line":23,"args":["/nextcloud/ocs/v1.php"],"function":"require_once"}],"File":"/nextcloud/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php","Line":92}},"CustomMessage":"--"}}

Is there anything more I can provide to assist you ?

@nickvergessen
Copy link
Member

nickvergessen commented Feb 17, 2023

I was about to fix the notification bug with #293

But then decided against it. Instead we should find out why the file has no owner returned.

To get more debug logs, please add the following block to your config/config.php within the array, so before the ); in the last line:

  'log.condition' => 
  array (
    'apps' => 
    array (
      0 => 'files_retention',
    ),
  ),

Also there are detailed steps when it will not work in #142

@max-nextcloud
Copy link
Collaborator

Hi, is there anything more I can provide to help to sort it out?

@manu-p Are you still seeing this issue?

Could you try to add the enhanced logging proposed in #121 (comment) ?

Thanks!

@max-nextcloud max-nextcloud self-assigned this May 9, 2023
@max-nextcloud
Copy link
Collaborator

Talked about this with @juliushaertl

It looks like an exception is thrown because no owner can be found for the file.
Common causes for this might be:

  • The file is on an external storage
  • The file is in a groupfolder.

In both cases this represents a shared ownership. A groupfolder does not belong to a single user. Same for the external storage. So it's also not clear who these files belong to.

Normally we fall back to the current user: https://github.com/nextcloud/server/blob/b294edad804f40618a96116845615831302d0357/lib/private/Files/Storage/Common.php#L418

However this obviously does not work for background jobs like the one deleting the files here.

@nickvergessen
Copy link
Member

But the app loops over all users and uses the first node that is deletable.

If no path is deletable, I'm not sure it should be deleted?

@max-nextcloud
Copy link
Collaborator

max-nextcloud commented May 15, 2023

If no path is deletable, I'm not sure it should be deleted?

I think the path is deletable - but there is no user performing the request so the deletion fails.

In other words... if someone with write access to the NC backups path tried to remove the file in the UI it would work because there's a user that issued the request and that files storage will fall back to. This is failing because it's executed by a background job.

Looking at the second trace from the logs above a pre_remove_hook from the files_versions app errors out because no owner can be found:

{
  "reqId": "iPsCyIYb1HfGlg2KCtHz",
  "version": "24.0.5.1",
  "exception": {
    "Exception": "OCP\\Files\\NotFoundException",
    "Message": "/NC backups/nextcloud-1week has no owner",
    "Trace": [
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Storage.php",
        "line": 111,
        "function": "getOwner",
        "class": "OC\\Files\\Filesystem",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Storage.php",
        "line": 226,
        "function": "getUidAndFilename",
        "class": "OCA\\Files_Versions\\Storage",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Hooks.php",
        "line": 82,
        "function": "markDeletedFile",
        "class": "OCA\\Files_Versions\\Storage",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/private/legacy/OC_Hook.php",
        "line": 106,
        "function": "pre_remove_hook",
        "class": "OCA\\Files_Versions\\Hooks",
        "type": "::"
      },
      {  "removed": "Removed stack frames from hook logic for better overview ..." },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
        "line": 388,
        "function": "rmdir",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php",
        "line": 242,
        "function": "delete",
        "class": "OC\\Files\\Node\\Folder",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php",
        "line": 154,
        "function": "expireNode",
        "class": "OCA\\Files_Retention\\BackgroundJob\\RetentionJob",
        "type": "->"
      }
    ]
  }
}
full trace as reported above
{
  "reqId": "iPsCyIYb1HfGlg2KCtHz",
  "level": 3,
  "time": "2022-10-10T09:05:04+00:00",
  "remoteAddr": "",
  "user": "--",
  "app": "no app in context",
  "method": "",
  "url": "--",
  "message": "/NC backups/nextcloud-1week has no owner",
  "userAgent": "--",
  "version": "24.0.5.1",
  "exception": {
    "Exception": "OCP\\Files\\NotFoundException",
    "Message": "/NC backups/nextcloud-1week has no owner",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
        "line": 805,
        "function": "getOwner",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Storage.php",
        "line": 111,
        "function": "getOwner",
        "class": "OC\\Files\\Filesystem",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Storage.php",
        "line": 226,
        "function": "getUidAndFilename",
        "class": "OCA\\Files_Versions\\Storage",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Hooks.php",
        "line": 82,
        "function": "markDeletedFile",
        "class": "OCA\\Files_Versions\\Storage",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/private/legacy/OC_Hook.php",
        "line": 106,
        "function": "pre_remove_hook",
        "class": "OCA\\Files_Versions\\Hooks",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 1290,
        "function": "emit",
        "class": "OC_Hook",
        "type": "::"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 1160,
        "function": "runHooks",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/View.php",
        "line": 355,
        "function": "basicOperation",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
        "line": 388,
        "function": "rmdir",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php",
        "line": 242,
        "function": "delete",
        "class": "OC\\Files\\Node\\Folder",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_retention/lib/BackgroundJob/RetentionJob.php",
        "line": 154,
        "function": "expireNode",
        "class": "OCA\\Files_Retention\\BackgroundJob\\RetentionJob",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/Job.php",
        "line": 79,
        "function": "run",
        "class": "OCA\\Files_Retention\\BackgroundJob\\RetentionJob",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php",
        "line": 95,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/cron.php",
        "line": 151,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->"
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Files/View.php",
    "Line": 1702,
    "CustomMessage": "--"
  }
}

@nickvergessen
Copy link
Member

Well the code loops over all mountpoints and uses the first one with delete permissions.
So basically it tries all users:
https://github.com/nextcloud/files_retention/blob/master/lib/BackgroundJob/RetentionJob.php#L183-L226

@max-nextcloud
Copy link
Collaborator

Yes... it tries all users by trying all mount points.
And then it finds a mountpoint which contains the file.
It gets the node from the userFolder and checks if it's deletable.
It returns a node that is deletable. So that is not the problem.

But when attempting to delete the node the node is deletable but it does not have an owner by itself and \OC_User::getUser(); is not set. So getOwner fails to retrieve an owner.

I don't know if we could set the user for \OC_User::getUser(); in getDeletableNodeFromMountPoint according to the userId. Feels hacky but so does the entire fallback to \OC_User::getUser();.

@Joshua2504
Copy link

Joshua2504 commented Sep 13, 2023

Hi,

I have the same issue.

Maybe this helps.

Trace with error message "Backends provided no user object for "
{
  "reqId": "CN9rdrFwmjM0xqnam3DV",
  "level": 3,
  "time": "2023-08-30T10:52:09+00:00",
  "remoteAddr": "",
  "user": "--",
  "app": "files",
  "method": "",
  "url": "--",
  "message": "Backends provided no user object for ",
  "userAgent": "--",
  "version": "27.0.2.1",
  "exception": {
    "Exception": "OC\\User\\NoUserException",
    "Message": "Backends provided no user object",
    "Code": 0,
    "Trace": [
      {
        "function": "getUserFolder",
        "class": "OC\\Files\\Node\\Root",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/private/Files/Node/LazyFolder.php",
        "line": 74,
        "function": "call_user_func_array"
      },
      {
        "file": "/var/nextcloud_data/lib/private/Files/Node/LazyRoot.php",
        "line": 40,
        "function": "__call",
        "class": "OC\\Files\\Node\\LazyFolder",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/apps/files_versions/lib/Listener/FileEventsListener.php",
        "line": 357,
        "function": "getUserFolder",
        "class": "OC\\Files\\Node\\LazyRoot",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/apps/files_versions/lib/Listener/FileEventsListener.php",
        "line": 283,
        "function": "getPathForNode",
        "class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/apps/files_versions/lib/Listener/FileEventsListener.php",
        "line": 119,
        "function": "remove_hook",
        "class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/private/EventDispatcher/ServiceEventListener.php",
        "line": 86,
        "function": "handle",
        "class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 251,
        "function": "__invoke",
        "class": "OC\\EventDispatcher\\ServiceEventListener",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 73,
        "function": "callListeners",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 94,
        "function": "dispatch",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 106,
        "function": "dispatch",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/private/Files/Node/HookConnector.php",
        "line": 159,
        "function": "dispatchTyped",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/private/legacy/OC_Hook.php",
        "line": 105,
        "function": "postDelete",
        "class": "OC\\Files\\Node\\HookConnector",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/private/Files/View.php",
        "line": 1252,
        "function": "emit",
        "class": "OC_Hook",
        "type": "::"
      },
      {
        "file": "/var/nextcloud_data/lib/private/Files/View.php",
        "line": 1184,
        "function": "runHooks",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/private/Files/View.php",
        "line": 321,
        "function": "basicOperation",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/private/Files/Node/Folder.php",
        "line": 372,
        "function": "rmdir",
        "class": "OC\\Files\\View",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/apps/files_retention/lib/BackgroundJob/RetentionJob.php",
        "line": 242,
        "function": "delete",
        "class": "OC\\Files\\Node\\Folder",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/apps/files_retention/lib/BackgroundJob/RetentionJob.php",
        "line": 154,
        "function": "expireNode",
        "class": "OCA\\Files_Retention\\BackgroundJob\\RetentionJob",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/public/BackgroundJob/Job.php",
        "line": 81,
        "function": "run",
        "class": "OCA\\Files_Retention\\BackgroundJob\\RetentionJob",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/public/BackgroundJob/TimedJob.php",
        "line": 103,
        "function": "start",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/lib/public/BackgroundJob/TimedJob.php",
        "line": 93,
        "function": "start",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->"
      },
      {
        "file": "/var/nextcloud_data/cron.php",
        "line": 152,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->"
      }
    ],
    "File": "/var/nextcloud_data/lib/private/Files/Node/Root.php",
    "Line": 364,
    "message": "Backends provided no user object for ",
    "exception": [],
    "CustomMessage": "Backends provided no user object for "
  },
  "id": "6501866cd9c6a"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants