Repository navigation
Closed
Description
After upgrading from 10.0.8 to 10.0.9 I'm getting a lot of this errors:
{"reqId":"aVZ86bwUZOHjbSkPtaCu","level":3,"time":"2018-08-14T17:45:07+02:00","remoteAddr":"","user":"--","app":"no app in context","method":"--","url":"--","message":"Exception: {"Exception":"OCP\Files\NotFoundException","Message":"/trabajos/xxxxxxs.xlsx.v1526485490 not found while trying to get owner","Code":0,"Trace":"
#0 /var/www/owncloud/lib/private/Files/Filesystem.php(960): OC\Files\View->getOwner('/trabajos/aries...')
#1 /var/www/owncloud/lib/private/Preview.php(1315): OC\Files\Filesystem::getOwner('/trabajos/xxxxx...')
#2 /var/www/owncloud/lib/private/Preview.php(1303): OC\Preview::post_delete(Array, 'files/')
#3 /var/www/owncloud/lib/private/legacy/hook.php(105): OC\Preview::post_delete_versions(Array)
#4 /var/www/owncloud/apps/files_versions/lib/Storage.php(504): OC_Hook::emit('\OCP\Versions', 'delete', Array)
#5 /var/www/owncloud/apps/files_versions/lib/BackgroundJob/ExpireVersions.php(75): OCA\Files_Versions\Storage::expireOlderThanMaxForUser('lizzardts')
#6 /var/www/owncloud/lib/private/User/Manager.php(440): OCA\Files_Versions\BackgroundJob\ExpireVersions->OCA\Files_Versions\BackgroundJob\{closure}(Object(OC\User\User))
#7 /var/www/owncloud/lib/private/User/AccountMapper.php(233): OC\User\Manager->OC\User\{closure}(Object(OC\User\Account))
#8 /var/www/owncloud/lib/private/User/Manager.php(441): OC\User\AccountMapper->callForAllUsers(Object(Closure), '', true)
#9 /var/www/owncloud/lib/private/User/Manager.php(459): OC\User\Manager->callForAllUsers(Object(Closure), '', true)
#10 /var/www/owncloud/apps/files_versions/lib/BackgroundJob/ExpireVersions.php(76): OC\User\Manager->callForSeenUsers(Object(Closure))
#11 /var/www/owncloud/lib/private/BackgroundJob/Job.php(57): OCA\Files_Versions\BackgroundJob\ExpireVersions->run(NULL)
#12 /var/www/owncloud/lib/private/BackgroundJob/TimedJob.php(53): OC\BackgroundJob\Job->execute(Object(OC\BackgroundJob\JobList), Object(OC\Log))
#13 /var/www/owncloud/cron.php(121): OC\BackgroundJob\TimedJob->execute(Object(OC\BackgroundJob\JobList), Object(OC\Log))
#14 {main}","File":"/var/www/owncloud/lib/private/Files/View.php","Line":1718}"}
It doesn't look like a big error, but the log is full of those messages
Activity
[-][10.0.9]Trying to get a preview from an erased file[/-][+][10.0.9]Trying to get owner from an erased file[/+]ownclouders commentedon Aug 15, 2018
GitMate.io thinks the contributor most likely able to help you is @PVince81.
Possibly related issues are #27770 (File version preview icon not showing up after upgrading from 9.1.5 to 10.0.0), #30537 (Bump phpseclib/phpseclib from 2.0.9 to 2.0.10), #28331 (DB issues after upgrade from 9.1.5 to 10.0.2), #5176 (Preview for avi files), and #4785 (OC 5.0.10 Gallery bug: Gallery treats a ZIP file as image and tries to show a preview image for a zip file .zip).
PVince81 commentedon Aug 22, 2018
seems the version expiry code is triggering the thumbnail/preview deletion code which itself is running into the error.
we should probably catch the error in the preview handler in case we try to delete a preview for an already deleted version.
now it's not guaranteed that the current state works, maybe it's actually leaving the previews on-disk... needs to be tested.
PVince81 commentedon Oct 15, 2018
Steps to reproduce
cron.phpand observe the logsExpected result
No errors
Actual result
Version
v10.0.10 from git
Bisect points at commit b09846b which points to b09846b regarding the change related to version previews.
This is a regression from v10.0.8
PVince81 commentedon Oct 15, 2018
From what I see in past versions we didn't call
getOwner()in thepost_deletehook handler.Since the move to the new previews endpoint, we need it.
PVince81 commentedon Oct 15, 2018
The issue happens because the $path seems to be a relative path instead of absolute and looks like "/test.txt.v123456678". It also only does this
getOwner()fallback because no user id was passed as arguments.There are two fixes we can do here:
PVince81 commentedon Oct 15, 2018
hmmm, making
$patharg absolute could be dangerous as it could affect old hooks.I diffed the files_versions/lib/Storage.php class with v10.0.8 and there was no notable changes, so the path was always absolute. It seems that in v10.0.8 the Preview::post_delete was mostly based on the logged in user. Not sure how this could even work back then with cron where there is no logged in user, maybe it didn't and just failed silently.
PVince81 commentedon Oct 15, 2018
I've checked v10.0.8 and observed the following:
Previewconstructor even tries to create the path with an empty user, so the root path becomes "//files/" and it tries to look for "//files/test.txt.v123456789"The assumption that $path is relative in v10.0.9+ is wrong. We better not change the semantics of the hook as it could break other implementations.
When running in cron I suggest to pass in the user id argument as we have it. If no user id argument is given, the handler should abort and log a debug message about a missing arg.
PVince81 commentedon Oct 15, 2018
Hmm even user id is not enough, and neither is the relative path "/test.txt.v123456789" because it's missing the "/files_version" prefix.
Looks like the prefix specified in "post_delete_versions" is incorrect.
1 remaining item
PVince81 commentedon Oct 15, 2018
also from what I saw, the preview folders location for versions has changed and is now a subdir of "$fileid/$timestamp" instead of having its own fileid, so it is likely that deletion needs to be done completely differently.
@DeepDiver1975 I'll need your guidance to continue here. Here's my PR so far: #33188
Next up would be to write new methods "Preview::prepare_delete_versions" and "Preview::post_delete_versions" with its own specific code. I'm not sure if Preview::deleteAllPreviews() is the right approach now with the new versions location.
Also it seems that
Preview::addPathToDeleteFileMapperis thinking it's receiving an absolute path but my observation is that hook paths are always relative, scary 🙈PVince81 commentedon Oct 16, 2018
and since we're using the node API now I'm wondering whether the query should rather go to "meta" to get the versioned node, then have logic in the preview delete methods that detect the versioned node and know where to delete the thumbnails in "$fileid/$timestamp".
PVince81 commentedon Oct 17, 2018
The previews behavior is also a little bit strange when restoring a file: since the original file gets overwritten, the folder "thumbnails/$fileid" gets deleted, so all version previews also get deleted. At that stage, the versions tab still displays cached previews. Once I refresh the page, it will regenerate a preview for each version displayed in the versions tab. So version previews aren't kept.
This is only a minor issue as regenerating is only for few entries and the final outcome is the same: all previews are displayed correctly in the web UI.
I mostly wanted to see if there was an actual explicit code path for deleting a version thumbnail when restoring a version file. Since the parent folder gets deleted such logic wouldn't be needed.
PVince81 commentedon Oct 20, 2018
Once this is fixed, we'll likely also want an occ command and/or repair step to clean up all orphaned previews that failed to be deleted on expiration. Raised here: #33240
DeepDiver1975 commentedon Nov 12, 2018
@PVince81 what is your expiration config? THX
PVince81 commentedon Nov 12, 2018
@DeepDiver1975 all default.
I use the trick where I reset oc_jobs timestamp to make sure the cron job will run.
DeepDiver1975 commentedon Nov 26, 2018
I tried this with default behavior - and the occ command ...
.... will try with cron next ....
PVince81 commentedon Jan 11, 2019
in the meantime, here's an attempt at mitigation: #34118
this would prevent the exception but would also leave some stray previews
PVince81 commentedon Jan 21, 2019
I realize that I missed one crucial step for reproduction, added now:
"3. Open the versions panel to have it generate previews"