Nextcloud-snap: can't delete folder...

Created on 7 Jan 2017  Â·  29Comments  Â·  Source: nextcloud/nextcloud-snap

That a bit weird, but since upgrade to NC11 I cannot delete any folder with the NC web interface...
Step to reproduce :
1) in the root folder, create a folder
2) check the box of the newly created folder, and try to delete
3) an error message is displayed, stating (in french) "Erreur à la suppression du fichier "test2". that I could translate to "Error when trying to delete file test2"
4) in the Admin/log, a new entry appear : "Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) at /snap/nextcloud/559/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php#104"

upstream

Most helpful comment

My QUICK FIX:
lib/private/Files/Cache/Cache.php

Original method search:

public function search($pattern) {
        // normalize pattern
        $pattern = $this->normalize($pattern);

        $sql = '
            SELECT `fileid`, `storage`, `path`, `parent`, `name`,
                `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`,
                `etag`, `permissions`, `checksum`
            FROM `*PREFIX*filecache`
            WHERE `storage` = ? AND `name` ILIKE ?';
        $result = $this->connection->executeQuery($sql,
            [$this->getNumericStorageId(), $pattern]
        );

        $files = [];
        while ($row = $result->fetch()) {
            $row['mimetype'] = $this->mimetypeLoader->getMimetypeById($row['mimetype']);
            $row['mimepart'] = $this->mimetypeLoader->getMimetypeById($row['mimepart']);
            $files[] = $row;
        }
        return array_map(function(array $data) {
            return new CacheEntry($data);
        }, $files);
    }

My edit:

public function search($pattern) {
        // normalize pattern
        $pattern = $this->normalize($pattern);

        if($pattern == '%%'){
            return array();
        }

        $sql = '
            SELECT `fileid`, `storage`, `path`, `parent`, `name`,
                `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`,
                `etag`, `permissions`, `checksum`
            FROM `*PREFIX*filecache`
            WHERE `storage` = ? AND `name` ILIKE ?';
        $result = $this->connection->executeQuery($sql,
            [$this->getNumericStorageId(), $pattern]
        );

        $files = [];
        while ($row = $result->fetch()) {
            $row['mimetype'] = $this->mimetypeLoader->getMimetypeById($row['mimetype']);
            $row['mimepart'] = $this->mimetypeLoader->getMimetypeById($row['mimepart']);
            $files[] = $row;
        }
        return array_map(function(array $data) {
            return new CacheEntry($data);
        }, $files);
    }

Just added this three lines

if($pattern == '%%'){
    return array();
}

after line
$pattern = $this->normalize($pattern);

All 29 comments

further more, the log time are displayed with wrong time (local time +1)
my config.php is set to 'logtimezone' => 'Europe/Paris'
the system clock looks correct (timedatectl status give the good UTC time and no timezone) but it seems that a snap can have a specific time configuration (see old snappy command).

I suspect something like this one : https://github.com/nextcloud/server/issues/2961

I can't duplicate, but it sounds like you're out of RAM. Is that true?

Ah, or hitting the PHP memory limit. Does the folder include thumbnails, perhaps?

the folder is empty ... as I said, I reproduced this bug with a new folder !
My machine has 4 Go ram , and when I look to Memory usage in Server info, it said 1.3 GB (almost all the time). Maximum is 1 or 2 users at the same time.

The only related log is "Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) at /snap/nextcloud/559/htdocs/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php#104"
I also tried several occ command (such as scan all, repair, ...) but nothing solve this !

I can also give these information from the "server information":

Storage
Users: 2
Files: 66394
Database
Type: mysql
Version: 5.7.11
Size: 44.0 MB

Yeah, that's the PHP memory limit then. Regarding the thumbnails, I'm not referring to the folder you're trying to delete, but the folder containing it. Also, do you have the gallery app enabled?

gallery app is not installed...
there is maybe 8000 or 10.000 pictures in my cloud, but that should not be a problem ... as it worked before the v11 !

Well _something_ is eating 128MB of RAM, and I doubt it's just the deletion of an empty directory (particularly because I can do it without any issues). I'm not sure what would have changed in v11 to cause this, but it's likely out of the control of the snap. Have you asked upstream?

Have you asked upstream?

not yet ... and a reboot does not change anything !
do you think that a snap revert may be possible without damages ?

do you think that a snap revert may be possible without damages?

Indeed, though I suggest you debug some more and try to figure out the cause. Note that by reverting you'll lose all database changes you've made since the update (though raw data files will remain). I'm also not familiar enough with the reversion tech to know how future updates will work.

I suggest you debug some more and try to figure out the cause.

I wish I could do this, but it is far beyond my capacities !!

Same for me, except I did not performed any upgrade, but a clean install of Ubuntu server 16.04 LTS and a clean snappy install of Nextcloud. Besides that there are only security solutions installed, which are suggested in two tutorials for server hardening. One for ubuntu and one for Nextcloud.

Can be seen hereand here. But I did not installed / configured all of that stuff. If you need to know what exactly, then ask for.

Error PHP Allowed memory size of 134217728 bytes exhausted (tried to allocate 2097160 bytes) at /snap/nextcloud/559/htdocs/lib/private/Files/Cache/Cache.php#616 2017-01-12T23:41:16+0100

Edit1: I repeated the installation on a fresh server and installed nextcloud 11 (instead of 10) over snap. Then I reinstalled all security packages, like on the old server with the two links above. I did not configured all the security solutions but restarted the server and setted up the server encryption and the sync client. I can not reproduce this problem. Maybe it comes after some while or after having more users and plenty of stuff on it or not at all with the nextcloud version 11. Anyway: I could not reproduce the error, with a fresh installation in a similar environment.

Edit2: Somehow nextcloud 11 is on my old server now (by apt-get dist-upgrade maybe? Or is this going to happen automatically with snap?). But the problem still remains.

I have exactly the same problem. It is not possible to delete an empty folder. The error I get is

{"reqId":"eA5I6ntMa3vJXz7Ky7Jv","remoteAddr":"2003:4d:ee6c:6f00:9cfd:c850:2fa3:218d","app":"PHP","message":"Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) at $NEXTCLOUDDIR/lib/private/Files/Cache/Cache.php#619","level":3,"time":"January 17, 2017 22:48:12","method":"DELETE","url":"$FILE","user":"$USER","version":"11.0.1.2"}

I don't now, which information I can share to solve the problem.

Are all of you using Pi hardware?

Hmmm.... Actually, it doesn't matter as the limit is set in stone. I'm just confused by the latest log posted as it shows a limit set at 512MB

No. I'm using a Dell PowerEdge T20. Offered the Ubuntu Server 16.04 LTS Server 6 GB of RAM and it is dedicated for this task / application.

Good catch @oparoz, the only place I see that is in Nextcloud's .user.php. I can't believe that deleting a folder is maxing out 128MB, much less 512MB of RAM. Got any ideas? I'm not convinced the snap has anything to do with this.

I check my config twice, but did not find any error. The memory limit in .user.php is set to 512M (as default).

same problems described here: https://help.nextcloud.com/t/cant-delete-folder-on-local-external-storage/7732

Nextcloud 11.0.1 installed on Raspberry Pi 3 Model B (migrated from OwncCloud, OwnCloud has not similar problem)
PHP Version 7.0.15
MySQL 5.5.54

External storage filesystem: ext4
External storage mountpoint: /var/html/www/html
NextCloud directory: /var/www/html/cloud
NextCloud storage path: /var/www/html/STORAGE/CLOUD/data

Log: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) at /var/www/html/cloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php#104

I can delete folders via terminal or FTP. I tried occ files:scan, but no result.

I try debug this error, but when I delete file, Nextcloud search for pattern %% in filecache DB.
file lib/private/Files/Cache/Cache.php line 597, method search (pattern is %%)

I reinstalled the server + nextcloud and had no issued since then.

My QUICK FIX:
lib/private/Files/Cache/Cache.php

Original method search:

public function search($pattern) {
        // normalize pattern
        $pattern = $this->normalize($pattern);

        $sql = '
            SELECT `fileid`, `storage`, `path`, `parent`, `name`,
                `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`,
                `etag`, `permissions`, `checksum`
            FROM `*PREFIX*filecache`
            WHERE `storage` = ? AND `name` ILIKE ?';
        $result = $this->connection->executeQuery($sql,
            [$this->getNumericStorageId(), $pattern]
        );

        $files = [];
        while ($row = $result->fetch()) {
            $row['mimetype'] = $this->mimetypeLoader->getMimetypeById($row['mimetype']);
            $row['mimepart'] = $this->mimetypeLoader->getMimetypeById($row['mimepart']);
            $files[] = $row;
        }
        return array_map(function(array $data) {
            return new CacheEntry($data);
        }, $files);
    }

My edit:

public function search($pattern) {
        // normalize pattern
        $pattern = $this->normalize($pattern);

        if($pattern == '%%'){
            return array();
        }

        $sql = '
            SELECT `fileid`, `storage`, `path`, `parent`, `name`,
                `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`,
                `etag`, `permissions`, `checksum`
            FROM `*PREFIX*filecache`
            WHERE `storage` = ? AND `name` ILIKE ?';
        $result = $this->connection->executeQuery($sql,
            [$this->getNumericStorageId(), $pattern]
        );

        $files = [];
        while ($row = $result->fetch()) {
            $row['mimetype'] = $this->mimetypeLoader->getMimetypeById($row['mimetype']);
            $row['mimepart'] = $this->mimetypeLoader->getMimetypeById($row['mimepart']);
            $files[] = $row;
        }
        return array_map(function(array $data) {
            return new CacheEntry($data);
        }, $files);
    }

Just added this three lines

if($pattern == '%%'){
    return array();
}

after line
$pattern = $this->normalize($pattern);

hello

I couldn`t find this location in ubuntu 14.04: lib/private/Files/Cache/Cache.php

This is in your nextcloud directory.

Dňa 31.1.2017 15:56 používateľ "dhillonbros" notifications@github.com
napísal:

hello

I couldn`t find this location in ubuntu 14.04:
lib/private/Files/Cache/Cache.php

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/nextcloud/nextcloud-snap/issues/171#issuecomment-276385286,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHSjX6YXq4JRwYneew1GvjvEZN0TQkf8ks5rX0uogaJpZM4Ldio7
.

That discussion (and patch, thanks @thomasooo) definitely make this bug sound like it's in upstream Nextcloud. @thomasooo have you logged a bug there?

No

2017-01-31 17:13 GMT+01:00 Kyle Fazzari notifications@github.com:

That discussion (and patch, thanks @thomasooo
https://github.com/thomasooo) definitely make this bug sound like it's
in upstream Nextcloud. @thomasooo https://github.com/thomasooo have you
logged a bug there?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nextcloud/nextcloud-snap/issues/171#issuecomment-276408720,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHSjX-lGzrEfZkh9pra8i51JIUr5ejvdks5rX12WgaJpZM4Ldio7
.

--
S pozdravom
Tomáš Ballon

This trick works. Thanks guys for the solution.

if($pattern == '%%'){
return array();
}

Having a patch here isn't a good way to get a fix upstream: this project is only the packaging of Nextcloud, not Nextcloud itself. Please log a bug over there, and if you feel comfortable, make a PR with your suggested fix. If you don't feel comfortable making the PR, at least mention the route you took to work around it in the bug report.

Ok, make a bug report.

2017-01-31 18:20 GMT+01:00 Kyle Fazzari notifications@github.com:

Having a patch here isn't a good way to get a fix upstream: this project
is only the packaging of Nextcloud, not Nextcloud itself. Please log a bug
over there, and if you feel comfortable, make a PR with your suggested fix.
If you don't feel comfortable making the PR, at least mention the route you
took to work around it in the bug report.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nextcloud/nextcloud-snap/issues/171#issuecomment-276429708,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHSjX3h4M7je6rB0aCTmEfPvDgQsl881ks5rX21LgaJpZM4Ldio7
.

--
S pozdravom
Tomáš Ballon

Fixed upstream, will be in NC12

I'll close this, then.

Was this page helpful?
0 / 5 - 0 ratings