Moving a file between two shares fails, with PHP error 'Nesting level too deep' on the server. #24318

Closed
benjunmun opened this Issue Apr 27, 2016 · 12 comments

Projects

None yet

4 participants

@benjunmun
benjunmun commented Apr 27, 2016 edited

Steps to reproduce

  1. Create two folders on account A.
  2. Share both folders to account B.
  3. On the client side, Account B creates a file in the first folder, and waits for everything to sync.
  4. On the client side, Account B attempts to move the file from the first folder to the second folder (Cut and paste)

Expected behaviour

Expect the move operation to be synched up to the server.

Actual behaviour

On the client side, the file moves as expected. When attempting to sync the move, the client reports:
4/27/16 3:42:41 PM, Jing-A/TESTFILE, ownCloud,Continue blacklisting: Error downloading https://**FQDN**/remote.php/webdav/Jing-A/TESTFILE - server replied: Internal Server Error

The server reports:
{"reqId":"Zr1y+OPVk6OZ5LqGBlOd","remoteAddr":"*******","app":"PHP","message":"Nesting level too deep - recursive dependency? at \/var\/www\/owncloud\/lib\/private\/files\/view.php#729","level":3,"time":"2016-04-27T19:41:49+00:00","method":"MOVE","url":"\/remote.php\/webdav\/Jing-A\/TESTFILE","user":"1******b"}

Interestingly this does not appear to break when moving between two folders I have shared (as opposed to folders shared with me).

Server configuration

Operating system:
Server - Ubuntu 14.04 LTS.
Clients - I have reproduced this on both windows and linux.

Web server:
Apache/2.4.7

Database:
Postgresql 9.3

PHP version:

PHP 5.5.9-1ubuntu4.16 (cli) (built: Apr 20 2016 14:31:27)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

ownCloud version: (see ownCloud admin page)
9.0.1

Updated from an older ownCloud or fresh install:
Updated.

Where did you install ownCloud from:
Owncloud package repos for Ubuntu

Signing status (ownCloud 9.0 and above):

No errors have been found.

List of activated apps:

sudo -u www-data php occ app:list
Enabled:
  - activity: 2.2.1
  - comments: 0.2
  - dav: 0.1.6
  - federatedfilesharing: 0.1.0
  - federation: 0.0.4
  - files: 1.4.4
  - files_pdfviewer: 0.8
  - files_sharing: 0.9.1
  - files_texteditor: 2.1
  - files_trashbin: 0.8.0
  - files_versions: 1.2.0
  - files_videoplayer: 0.9.8
  - firstrunwizard: 1.1
  - gallery: 14.5.0
  - notifications: 0.2.3
  - provisioning_api: 0.4.1
  - systemtags: 0.2
  - templateeditor: 0.1
  - updatenotification: 0.1.0
  - user_ldap: 0.8.0
Disabled:
  - documents
  - encryption
  - external
  - files_external
  - user_external

The content of config/config.php:

sudo -u www-data php occ config:list system
{
    "system": {
        "instanceid": "oc8994ffde61",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "appstoreenabled": true,
        "datadirectory": "\/var\/www\/owncloud\/data",
        "dbtype": "pgsql",
        "version": "9.0.1.3",
        "dbname": "owncloud",
        "dbhost": "localhost",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "ldapIgnoreNamingRules": false,
        "forcessl": true,
        "theme": "",
        "maintenance": false,
        "mail_smtpmode": "smtp",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "loglevel": 1,
        "mail_from_address": "owncloud",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "appstore.experimental.enabled": true,
        "trashbin_retention_obligation": "auto",
        "mail_smtpsecure": "ssl",
        "mail_smtpauthtype": "PLAIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "updatechecker": false
    }
}

Are you using external storage, if yes which one: local/smb/sftp/...
No external storage

Are you using encryption: yes/no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
LDAP user backend.

LDAP configuration (delete this part if not used)

sudo -u www-data php occ ldap:show-config
+-------------------------------+---------------------------------------------+
| Configuration                 |                                             |
+-------------------------------+---------------------------------------------+
| hasMemberOfFilterSupport      | 0                                           |
| hasPagedResultSupport         |                                             |
| homeFolderNamingRule          |                                             |
| lastJpegPhotoLookup           | 0                                           |
| ldapAgentName                 |                                             |
| ldapAgentPassword             | ***                                         |
| ldapAttributesForGroupSearch  |                                             |
| ldapAttributesForUserSearch   |                                             |
| ldapBackupHost                | ldaps://****REMOVED***              |
| ldapBackupPort                | 636                                         |
| ldapBase                      | ou=Users,dc=****REMOVED***            |
| ldapBaseGroups                | ou=Users,dc=****REMOVED***            |
| ldapBaseUsers                 | ou=Users,dc=****REMOVED***            |
| ldapCacheTTL                  | 600                                         |
| ldapConfigurationActive       | 1                                           |
| ldapDynamicGroupMemberURL     |                                             |
| ldapEmailAttribute            | mail                                        |
| ldapExperiencedAdmin          | 0                                           |
| ldapExpertUUIDGroupAttr       |                                             |
| ldapExpertUUIDUserAttr        |                                             |
| ldapExpertUsernameAttr        |                                             |
| ldapGroupDisplayName          | cn                                          |
| ldapGroupFilter               |                                             |
| ldapGroupFilterGroups         |                                             |
| ldapGroupFilterMode           | 0                                           |
| ldapGroupFilterObjectclass    |                                             |
| ldapGroupMemberAssocAttr      | uniqueMember                                |
| ldapHost                      | ldaps://****REMOVED***              |
| ldapIgnoreNamingRules         |                                             |
| ldapLoginFilter               | (&(|(objectclass=inetOrgPerson))(uid=%uid)) |
| ldapLoginFilterAttributes     |                                             |
| ldapLoginFilterEmail          | 0                                           |
| ldapLoginFilterMode           | 0                                           |
| ldapLoginFilterUsername       | 1                                           |
| ldapNestedGroups              | 0                                           |
| ldapOverrideMainServer        | 0                                           |
| ldapPagingSize                | 500                                         |
| ldapPort                      | 636                                         |
| ldapQuotaAttribute            |                                             |
| ldapQuotaDefault              |                                             |
| ldapTLS                       | 0                                           |
| ldapUserDisplayName           | displayname                                 |
| ldapUserDisplayName2          |                                             |
| ldapUserFilter                | (|(objectclass=inetOrgPerson))              |
| ldapUserFilterGroups          |                                             |
| ldapUserFilterMode            | 0                                           |
| ldapUserFilterObjectclass     | inetOrgPerson                               |
| ldapUuidGroupAttribute        | auto                                        |
| ldapUuidUserAttribute         | auto                                        |
| turnOffCertCheck              | 0                                           |
| useMemberOfToDetectMembership | 1                                           |
+-------------------------------+---------------------------------------------+

Client configuration

Browser:
N/A

Operating system:
Windows 10, Ubuntu Linux

Logs

ownCloud log (data/owncloud.log)

Client:
`  4/27/16 3:42:41 PM,                                                 Jing-A/TESTFILE,                      ownCloud,Continue blacklisting: Error downloading https://**FQDN**/remote.php/webdav/Jing-A/TESTFILE - server replied: Internal Server Error`

Server:

`{"reqId":"Zr1y+OPVk6OZ5LqGBlOd","remoteAddr":"*******","app":"PHP","message":"Nesting level too deep - recursive dependency? at \/var\/www\/owncloud\/lib\/private\/files\/view.php#729","level":3,"time":"2016-04-27T19:41:49+00:00","method":"MOVE","url":"\/remote.php\/webdav\/Jing-A\/TESTFILE","user":"1******b"}
`

Browser log

N/A

@ghost
ghost commented Apr 28, 2016

Looks like something which got already fixed a few days ago: #24078

@nickvergessen
Contributor

@benjunmun can you test the patch above and report back if it helped?

@benjunmun

First of all, sorry for the duplicate - I'd searched for it but failed to find the other case.

I tested the referenced patch. At first, the move appeared to be fixed. However, this time, moving the file BACK to the first folder did not work.

When I move the file back from folder B to A, it gets stuck in the blue 'syncing' state on the client. After a few seconds, another copy is downloaded to the B folder so that I have now two copies on the client side.

If I delete the B copy, then A finishes uploading. If I retry the move a third time, then I get an error like this:

{
"reqId":"NUjp6OPCGfCjKPKi+ZJ0",
"remoteAddr":"----REMOVED----",
"app":"webdav",
"message":"Exception: {"Message":"An exception occurred while executing 'UPDATE \"oc_filecache\" SET \"storage\" = ?, \"path\" = ?, \"path_hash\" = ?, \"name\" = ?, \"parent\" =? WHERE \"fileid\" = ?' with params [23, \"ZZZZ.txt\", \"d900826e218e96a186415017cb816ff5\", \"ZZZZ.txt\", 1829, 7997]:\n\nSQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint \"fs_storage_path_hash\"\nDETAIL: Key (storage, path_hash)=(23, d900826e218e96a186415017cb816ff5) already exists.","Exception":"Doctrine\DBAL\Exception\UniqueConstraintViolationException","Code":0,"Trace":"#0 \/var\/www\/owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/DBALException.php(116): Doctrine\DBAL\Driver\AbstractPostgreSQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException))\n#1 \/var\/www\/owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Connection.php(836): Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDOPgSql\Driver), Object(Doctrine\DBAL\Driver\PDOException), 'UPDATE \"oc_file...', Array)\n#2 \/var\/www\/owncloud\/lib\/private\/db\/connection.php(184): Doctrine\DBAL\Connection->executeQuery('UPDATE \"oc_file...', Array, Array, NULL)\n#3 \/var\/www\/owncloud\/lib\/private\/files\/cache\/cache.php(527): OC\DB\Connection->executeQuery('UPDATE `*PREFIX...', Array)\n#4 \/var\/www\/owncloud\/lib\/private\/files\/cache\/wrapper\/cachewrapper.php(183): OC\Files\Cache\Cache->moveFromCache(Object(OC\Files\Cache\Shared_Cache), 'ZZZZ.txt', 'ZZZZ.txt')\n#5 \/var\/www\/owncloud\/lib\/private\/files\/cache\/updater.php(179): OC\Files\Cache\Wrapper\CacheWrapper->moveFromCache(Object(OC\Files\Cache\Shared_Cache), 'ZZZZ.txt', 'ZZZZ.txt')\n#6 \/var\/www\/owncloud\/lib\/private\/files\/view.php(321): OC\Files\Cache\Updater->renameFromStorage(Object(OCA\Files_Trashbin\Storage), 'ZZZZ.txt', 'ZZZZ.txt')\n#7 \/var\/www\/owncloud\/lib\/private\/files\/view.php(747): OC\Files\View->renameUpdate(Object(OCA\Files_Trashbin\Storage), Object(OCA\Files_Trashbin\Storage), 'ZZZZ.txt', 'ZZZZ.txt')\n#8 \/var\/www\/owncloud\/apps\/dav\/lib\/connector\/sabre\/objecttree.php(241): OC\Files\View->rename('TESTB\/ZZZZ.txt', 'TESTA\/ZZZZ.txt')\n#9 \/var\/www\/owncloud\/3rdparty\/sabre\/dav\/lib\/DAV\/CorePlugin.php(640): OCA\DAV\Connector\Sabre\ObjectTree->move('TESTB\/ZZZZ.txt', 'TESTA\/ZZZZ.txt')\n#10 [internal function]: Sabre\DAV\CorePlugin->httpMove(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))\n#11 \/var\/www\/owncloud\/3rdparty\/sabre\/event\/lib\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\n#12 \/var\/www\/owncloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(459): Sabre\Event\EventEmitter->emit('method:MOVE', Array)\n#13 \/var\/www\/owncloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(248): Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))\n#14 \/var\/www\/owncloud\/apps\/dav\/appinfo\/v1\/webdav.php(55): Sabre\DAV\Server->exec()\n#15 \/var\/www\/owncloud\/remote.php(138): require_once('\/var\/www\/ownclo...')\n#16 {main}","File":"\/var\/www\/owncloud\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Driver\/AbstractPostgreSQLDriver.php","Line":63,"User":"1e8e79f8-11a6-1033-920a-3da7fb037f8b"}",
"level":4,
"time":"2016-04-28T14:22:34+00:00",
"method":"MOVE",
"url":"/remote.php/webdav/TESTB/ZZZZ.txt",
"user":"1e8e79f8-11a6-1033-920a-3da7fb037f8b"
}

@PVince81
Collaborator
PVince81 commented May 2, 2016

Confirmed happening on 9.0.2RC2, with Webdav:

  1. Create two users "user1" and "user2"
  2. Login as "user1"
  3. Create a folder "share1"
  4. Upload a file into "share1", for example "test.jpg"
  5. Share "share1" with user "admin"
  6. Login as "user2"
  7. Create a folder "share2"
  8. Share "share2" with user "admin"
  9. On the CLI with cadaver (Webdav), login as "admin"
  10. mv share1/test.jpg share2/
@PVince81 PVince81 added the sev2-high label May 2, 2016
@PVince81 PVince81 added this to the 9.0.3-next-maintenance milestone May 2, 2016
@PVince81
Collaborator
PVince81 commented May 2, 2016

Raised QA case to add automated tests for this: owncloud/QA#221

@PVince81
Collaborator
PVince81 commented May 2, 2016

Tested with #24078 and it works fine, no additional error.

I suspect that in the case of @benjunmun, the first failed move operation caused a file cache inconsistency. You might need to run occ files:scan username to fix it before retrying.

@PVince81
Collaborator
PVince81 commented May 2, 2016

I tried reproducing the issue from @benjunmun by first moving the file without the patch to generate the error, and then move the same file with the patch applied. Still works fine for me.

But as I said, please try running occ files:scan username, I think some inconsistency have appeared in your database.

@benjunmun

occ files:scan --all didn't warn me about anything aside from 'Home storage for user **** not writable' for users that don't have any files.

Just tried with two brand new (non-ldap) accounts. Still having trouble moving files back after the first apparently successful move.

To be absolutely clear on what I'm seeing (slightly different from your test setup):

  1. Create two users "user1" and "user2"
  2. Login as "user1"
  3. Create a folder "share1"
  4. Create a folder "share2"
  5. Upload a file into "share1", for example "test.jpg"
  6. Share "share1" with user "user2"
  7. Share "share2" with user "user2"
  8. Log in to client app as "user2"
  9. mv share1/test.jpg share2/ WORKS NOW
  10. Wait for sync to complete
  11. mv share2/test.jpg share1/

The second move never completes. After a few seconds, it will re-download in share2.

Interestingly at this point there are no errors in either the client or the server. However, if I delete one of the two copies then I start getting errors.

I'll see if I can re-test this in a clean owncloud installation in case there's something else messed up about mine.

@benjunmun

Just tested on a brand new Ubuntu VM with 9.0.1-3.1 with the #24078 patch applied. I am still able to reproduce the move-back issue.

@JochenHWezel

My Ubuntu 16.04 with OwnCloud 9.0.2.2 still produces these errors:
image

image

Any progress on this issue?

@PVince81
Collaborator

@JochenHWezel here #24446
or wait for 9.0.3

@nickvergessen
Contributor

Closing as per above

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