Data loss on rename of a 49 GB folder
I accidentially renamed a folder on my production instance:
- the folder was filled up with nearly 20k files in a total size of 48,7 GB
- I renamed the folder in the web UI
- shortly (2-5 seconds) after I noticed this I shut down the client to avoid bigger trouble (as this folder was set up as a synced folder inside the client)
- the spinner spinned forever
Notes
- I have a database dump here
- I have all apache logs here
- I have the owncloud.log here
- I have a filesystem snapshot
If someone wants to help me with digging in the debris is welcome.
Access log:
The rename:
127.0.0.1 - - [15/Jan/2015:13:32:39 +0100] "GET /index.php/apps/files/ajax/rename.php?dir=%2F&newname=Bildersd&file=Bilder HTTP/1.1" 503 1216
The access log filtered for the folder Bilder:
...
127.0.0.1 - - [15/Jan/2015:13:24:36 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:25:04 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:25:34 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:26:06 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:26:39 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 16662
127.0.0.1 - - [15/Jan/2015:13:27:36 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:28:06 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:28:36 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:29:06 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:29:36 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:30:05 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:30:34 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:31:04 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:31:36 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 411
127.0.0.1 - - [15/Jan/2015:13:32:09 +0100] "PROPFIND /remote.php/webdav/Bilder HTTP/1.1" 207 16662
Nothing special in php-fpm.log or apache error log.
The folder is successfully renamed (in database and in the filesystem), but all database entries are gone (files are still there in the filesystem). Just a forced rescan with the occ command line tool was able to get them back into the database. Browsing the folder in the web UI didn't trigger the update of the file cache.
! For the user (without admin rights) it's not possible to get back the data from the server. It's simply not shown.
I will try to investigate further and try to reproduce.
cc @karlitschek @DeepDiver1975 FYI could get a showstopper soon - I opened this ticket to document my process
To clarify: the rename happend through the web UI
127.0.0.1 - - [15/Jan/2015:13:32:39 +0100] "GET /index.php/apps/files/ajax/rename.php?dir=%2F&newname=Bildersd&file=Bilder HTTP/1.1" 503
503 ? That's "service unavailable" and shouldn't even trigger an actual rename.
You said you didn't have any other storages than home:: and the root, so this excludes the case of an unavailable external storage.
@PVince81 Yes. There is no external storage.
Regards the 503: It's the only rename request and it definetly gets renamed. Could that be caused by the timeout?
Not sure. Do you think php-fpm would decide to send 503 by itself when a timeout occurs ?
If the server was not available / maintenance mode, our Sabre plugin should kick in very early and prevent any file operations.
You could check the owncloud.log from around the time it happened (mind the timezone/utc differences)
I noticed that a rename caused a lot of database queries (600 for a folder with 507 files in it). It needs to update the path of all elements. I guess this caused the timeout and PHP-FPM will kill the process once the timeout is hit.
https://blackfire.io/profiles/a33715d9-0191-4f9a-ad4a-2f3166d71584/graph
@icewind1991 What is the reason to store the full path? Isn't knowing the parent enough to generate the full path?
@DeepDiver1975 @karlitschek I would rate this a bit higher. I talk to @icewind1991 and he would like to come up with a partly improving change, but reducing the load (especially the SQL queries) in a way like it was done for the delete operation isn't possible for 8.0 (#13394).
On the one hand this would require bigger changes but on the other hand this will cause critical problems (and even data loss) on renaming folders with many children.
Is this rated a showstopper or not?
@icewind1991 What is the reason to store the full path? Isn't knowing the parent enough to generate the full path?
Yes, but most queries we do are by path
@icewind1991 I guess it scales better if you simply traverse the file tree. And you can cache this too. The current approach doesn't scale in any direction. :(
I still don't understand why renaming a simple folder in place could run into a timeout (not even moving it to another location) Was that folder shared with many people ?
@PVince81 No. Have a look at the path column. it contains the full path and this needs to be updated for every child element. With many childs this could cause a huge processing action.
Ah right... the DB update :-/
A ticket should be either technical debt or a bug. I'd rather this is a bug. It might be caused by legacy code, but is still a bug.
@MorrisJobke have you been able to find any more clues ?
@PVince81 It's simply just the massive amount of DB updates. And the executing process got killed before it can finish this task. Nothing we can change for now :(
This is really a showstopper bug (as you can see in #10711). Our manager is considering to stop using Owncloud because of all these rename and sync problems that never gets fixed. I hope that you can fix all of these problems, because for us right now, oC can't be used in production. Thanks!
@DeepDiver1975 I've set this to 8.1, this should definitely be looked into.
It might take some time to debug because this bug is difficult to reproduce consistently.
I suspect that the part that handles renames will need to be rewritten to use a different approach, either by using part folders #13756 or updating the cache for each file one by one, as proposed here https://github.com/owncloud/core/issues/13775 instead of doing a bulk update at the end.
It might take some time to debug because this bug is difficult to reproduce consistently.
? You can't reproduce this? But the rename takes ages for you too, didn't it?