Skip to content

Moving files creates duplicate, empty directories #28277

Closed

Description

@kwisatz

Steps to reproduce

  1. Move files and directories from one folder to another folder

Expected behaviour

Files and directories should be moved to new directory and keep their integrity.

Actual behaviour

On the WebUI, directories and files got duplicated and directories are empty, despite the interface showing a file-size:
owncloud

On the server, directories are not duplicated, but also empty:

total 84
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Authorisations
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Budget
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Concept
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Contract
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Décompte_final
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Devis
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Dossier_presse
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Evaluation
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Factures
drwxr-xr-x 2 www-data www-data  4096 Oct 24  2016 Funding

root@:data/path/to/above/folder# ls -l Authorisations/
total 0

Re-scanning the files did not help.

Server configuration

Operating system: Debian 8.8

Web server: Apache 2.4.10

Database: MySQL 5.5.55

PHP version: 5.6.30

ownCloud version: 9.1.6-1.1

Updated from an older ownCloud or fresh install: Update

Where did you install ownCloud from: Your debian repositories

Signing status (ownCloud 9.0 and above): No errors have been found.

The content of config/config.php:

{
    "system": {
        "appstoreurl": "https:\/\/marketplace.owncloud.com\/api\/v0",
        "instanceid": "oc4idy8i5xh4",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.***REMOVED DOMAIN***"
        ],
        "datadirectory": "\/var\/www\/"***REMOVED SENSITIVE VALUE***\/oc-storage",
        "overwrite.cli.url": "http:\/\/***REMOVED DOMAIN***",
        "dbtype": "mysql",
        "version": "9.1.6.2",
        "dbname": "owncloud",
        "dbhost": "localhost",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "loglevel": "0",
        "preview_libreoffice_path": "\/usr\/bin\/libreoffice",
        "theme": "",
        "maintenance": false,
        "log_type": "owncloud",
        "logfile": "\/var\/log\/owncloud.log",
        "updatechecker": false,
        "trashbin_retention_obligation": "60",
        "mail_from_address": "cloud",
        "mail_smtpmode": "smtp",
        "mail_domain": "***REMOVED DOMAIN***",
        "mail_smtphost": "smtp.gmail.com",
        "mail_smtpport": "587",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "mail_smtpauthtype": "LOGIN"
    }
}

List of activated apps:

Enabled:
  - activity: 2.3.2
  - comments: 0.3.0
  - configreport: 0.1.1
  - dav: 0.2.7
  - federatedfilesharing: 0.3.0
  - federation: 0.1.0
  - files: 1.5.1
  - files_external: 0.6.0
  - files_pdfviewer: 0.8.1
  - files_sharing: 0.10.0
  - files_texteditor: 2.1
  - files_trashbin: 0.9.0
  - files_versions: 1.3.0
  - files_videoplayer: 0.9.8
  - firstrunwizard: 1.1
  - gallery: 15.0.0
  - notifications: 0.3.0
  - provisioning_api: 0.5.0
  - systemtags: 0.3.0
  - templateeditor: 0.1
  - updatenotification: 0.2.1
Disabled:
  - documents
  - encryption
  - external
  - files_antivirus
  - files_mv
  - ownnote
  - search_lucene
  - user_external
  - user_ldap

Are you using external storage, if yes which one: none

Are you using encryption: no

Are you using an external user-backend, if yes which one: no

Logs

Web server error log

[Wed Jun 28 15:58:35.981924 2017] [fastcgi:error] [pid 27677:tid 140233962153728] [client ***REMOVED IP***:59366] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: idle timeout (30 sec)
[Wed Jun 28 15:58:36.077825 2017] [fastcgi:error] [pid 27677:tid 140233962153728] [client ***REMOVED IP***:59366] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"

ownCloud log (data/owncloud.log)

has no entries later than 2015-11

Browser log

preview.png:1 GET https://cloud.***REMOVED DOMAIN***/index.php/core/preview.png?file=%2FARCH…nsib_20061103.doc&c=17fee15952987395ab1da99701a3deda&x=32&y=32&forceIcon=0 404 (Not Found)
2017-07-01 17:43:23.868
preview.png:1 GET https://cloud.***REMOVED DOMAIN***/index.php/core/preview.png?file=%2FARCH…dagogique2008.pdf&c=da864a0fbf8cd5c6698a8cdd7cfab1cc&x=32&y=32&forceIcon=0 404 (Not Found)
2017-07-01 17:43:23.869
preview.png:1 GET https://cloud.***REMOVED DOMAIN***/index.php/core/preview.png?file=%2FARCH…ects%2F_codes.xls&c=f12a4d208f51b9178c5af72b1a0f4037&x=32&y=32&forceIcon=0 404 (Not Found)
2017-07-01 17:43:23.870
preview.png:1 GET https://cloud.***REMOVED DOMAIN***/index.php/core/preview.png?file=%2FARCH…jectAgreement.odt&c=90ede19f2629462d7e1b0725779360ab&x=32&y=32&forceIcon=0 404 (Not Found)

Activity

  1. kwisatz commented on Jul 2, 2017

    @kwisatz
    Author

    Thanks @kdslkdsaldsal, it might be.
    At least some of the referenced SQL queries return a load of entries in this case (597 to be exact).

    But I'm not enough into owncloud to fully understand everything that @PVince81 is explaining in #28018 and #28238, so I can't be really sure.

  2. kwisatz commented on Jul 2, 2017

    @kwisatz
    Author

    I just ran the repair command on the owncloud instance and at first it seemed to succeed:

    root@server:/var/www/owncloud# sudo -u www-data ./occ maintenance:repair --include-expensive -vv            
     - Repair file cache entries with path that does not match parent-child relationships
     409/597 [===================>--------]  68% 55 secs/2 mins

    But I'm not actually sure this is a good sign? It doesn't seem to want to stop and the total number of file cache entries to be repaired now increments with the "repaired" entries:

    root@server:/var/www/owncloud# sudo -u www-data ./occ maintenance:repair --include-expensive -vv            
     - Repair file cache entries with path that does not match parent-child relationships
     770/770 [============================] 100% 2 mins/2 mins 

    Good thing I dumped the DB before I ran this?!

  3. kwisatz commented on Jul 2, 2017

    @kwisatz
    Author

    When I cancel (Ctrl-C) and restart, it starts at 0/579 again and shows the same behavior it did before. This might be interesting to @PVince81 too?

  4. kwisatz commented on Jul 2, 2017

    @kwisatz
    Author

    Fun fact: It did actually fix the issue.

  5. kwisatz commented on Jul 2, 2017

    @kwisatz
    Author

    Not entirely though. The files are showing up and the folders have been de-duplicated, but the files themselves are not accessible. E.g.

    Message: Unexpected server response (503) while retrieving PDF 
    "https://cloud.server.com/remote.php/webdav/ARCHIVES/A01_projects/262_TCA_Partnership%20Building_****/Authorisations/autorisation_2.pdf".
    
  6. PVince81 commented on Jul 3, 2017

    @PVince81
    Contributor

    @kwisatz thanks for testing. Can you rerun the queries I mentioned in the PR to see if there are still broken entries ?

    • select fc.storage,fc.fileid,fc.parent as "wrongparent",fc3.fileid "correctparent",fc.path,fc.etag from oc_filecache fc, oc_filecache fc3 where fc.parent <> -1 and fc.parent != fc3.fileid and fc3.storage=fc.storage and fc3.path = substring(fc.path, 1, length(fc.path) - length(substring_index(fc.path, '/', -1)) - 1) and not exists (select 1 from oc_filecache fc2 where fc2.fileid = fc.parent) order by path;
    • select fc.storage,fc.fileid,fc.parent as "wrongparent",fc.path,fc.etag from oc_filecache fc where fc.parent <> -1 and not exists (select 1 from oc_filecache fc2 where fc2.fileid = fc.parent) order by path;
    • select * from oc_filecache where parent=fileid;

    If none return results then there is likely yet another breakage style that needs to be adressed.
    In that case it would be good to see the entries and parent entries of that specific file:
    select * from oc_filecache where name='autorisation_2.pdf', pick the parent id then do select * from oc_filecache where fileid=$parentId replace $parentId with the value of "parent" from the previous query. Then repeat for each section of the tree.

  7. PVince81 commented on Jul 3, 2017

    @PVince81
    Contributor

    Note that you also need to apply #28022 to prevent the filecache breakage to be triggered in the first place. This PR #28217 #28253 is only to clean up the mess.

  8. kwisatz commented on Jul 3, 2017

    @kwisatz
    Author

    @PVince81 the first query still returns 145 rows; the second 180 rows and the last one returns an empty set. All of the files are still inaccessible though. I'm going to retrace parent IDs for one of them now and report back.

  9. kwisatz commented on Jul 3, 2017

    @kwisatz
    Author

    In the meantime, here's the exception triggered when trying to access one of the files in this directory:

    {
        "reqId": "s2yb7Gq1QMmkFbOcrT0k",
        "remoteAddr": "***REMOVED SENSITIVE INFO***",
        "app": "PHP",
        "message": "fopen(\/var\/www\/server.com\/oc-storage\/***REMOVED SENSITIVE INFO***\/files\/ARCHIVES\/A01_projects\/262_TCA_Partnership Building_***REMOVED SENSITIVE INFO***\/Budget\/BUDGET_2016.pdf): failed to open stream: No such file or directory at \/var\/www\/owncloud\/lib\/private\/Files\/Storage\/Local.php#278",
        "level": 3,
        "time": "2017-07-03T07:18:08+00:00",
        "method": "GET",
        "url": "\/remote.php\/webdav\/ARCHIVES\/A01_projects\/262_TCA_Partnership%20Building_***REMOVED SENSITIVE INFO***\/Budget\/BUDGET_2016.pdf",
        "user": "superclouder"
    } {
        "reqId": "s2yb7Gq1QMmkFbOcrT0k",
        "remoteAddr": "***REMOVED SENSITIVE INFO***",
        "app": "webdav",
        "message": "Exception: {\"Message\":\"HTTP\\\/1.1 503 Could not open file\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\ServiceUnavailable\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(83): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->get()\\n#1 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpGet(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#2 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#3 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(459): Sabre\\\\Event\\\\EventEmitter->emit('method:GET', Array)\\n#4 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(248): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#5 \\\/var\\\/www\\\/owncloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(61): Sabre\\\\DAV\\\\Server->exec()\\n#6 \\\/var\\\/www\\\/owncloud\\\/remote.php(164): require_once('\\\/var\\\/www\\\/ownclo...')\\n#7 {main}\",\"File\":\"\\\/var\\\/www\\\/owncloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":306,\"User\":\"superclouder\"}",
        "level": 4,
        "time": "2017-07-03T07:18:08+00:00",
        "method": "GET",
        "url": "\/remote.php\/webdav\/ARCHIVES\/A01_projects\/262_TCA_Partnership%20Building_***REMOVED SENSITIVE INFO***\/Budget\/BUDGET_2016.pdf",
        "user": "superclouder"
    }
    
  10. kwisatz commented on Jul 3, 2017

    @kwisatz
    Author

    @PVince81 I retraced the parentIDs and they seem OK. Each folder points to the respective parent folder and finally to parentId -1. I couldn't detect any inconsistencies here.

  11. PVince81 commented on Jul 3, 2017

    @PVince81
    Contributor

    @kwisatz try the following:

    • find data -name BUDGET_2016.pdf and see if the path matches the one from the error. I suspect the filecache had outdated entries that did not match what's on disk.
    • if that's the case, try running occ files:scan --all to repair this.
  12. kwisatz commented on Jul 3, 2017

    @kwisatz
    Author

    @PVince81 the file has gone completely from the filesystem. find doesn't find any occurrence of it anymore. We will restore it from backup (provided it goes that far back, since I don't know when exactly the files vanished) and then re-scan the files.

  13. kwisatz commented on Jul 3, 2017

    @kwisatz
    Author

    We just restored that data from a backup (from the original location, since I don't think the files ever made it to the new directory) and now files are accessible again, even without running the scan command. (Though I started it anyway).

  14. PVince81 commented on Jul 3, 2017

    @PVince81
    Contributor

    @kwisatz please patch your system with #28238 and hopefully the inconsistency won't happen again. I'm closing this as duplicate then.

    Glad to hear the repair worked for you.

  15. lock commented on Aug 1, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  16. locked as resolved and limited conversation to collaborators on Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions