Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files get locked after Ctrl+C interrupt decrypt command #32616

Open
davitol opened this issue Sep 6, 2018 · 4 comments
Open

Files get locked after Ctrl+C interrupt decrypt command #32616

davitol opened this issue Sep 6, 2018 · 4 comments
Labels
Milestone

Comments

@davitol
Copy link
Contributor

davitol commented Sep 6, 2018

Steps to reproduce

1 - create 2 users admin and user1
2 - Enable encryption with user-keys. Login as admin and user1.
3 - Now try to run decrypt-all command as follows: ./occ encryption:decrypt-all -c yes
4 - set admin pwd
5 - Stop the command with crtl ^c
6 - re-enable encryption ./occ encryption:enable
7 - re-run ./occ encryption:decrypt-all -c yes

Expected behaviour

Files should not get locked.

Actual behaviour

Files get locked. In the rename operation, the file gets locked. And once the file gets locked try to give Ctrl+C interrupt.

screen shot 2018-09-06 at 10 31 48

Server logs

{"reqId":"fIPdClUXId4qyQRzPcM3","level":3,"time":"2018-09-05T15:07:06+00:00","remoteAddr":"","user":"--","app":"OC\\Encryption\\DecryptAll","method":"--","url":"--","message":"Exception trying to decrypt file <\/admin\/files\/file1.txt> for user <admin>: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\DriverException\",\"Message\":\"An exception occurred while executing 'INSERT INTO \\\"oc_file_locks\\\" (\\\"key\\\",\\\"lock\\\",\\\"ttl\\\") SELECT ?,?,?  WHERE NOT EXISTS (SELECT 1 FROM \\\"oc_file_locks\\\" WHERE \\\"key\\\" = ?)' with params [\\\"files\\\\\\\/7ff417ff21a5d83e5e739f9907ece177\\\", 1, 1536163626, \\\"files\\\\\\\/7ff417ff21a5d83e5e739f9907ece177\\\"]:\\n\\nSQLSTATE[HY000]: General error: 5 database is locked\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractSQLiteDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/var\\\/www\\\/owncloud\\\/lib\\\/composer\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Connection.php(1015):

Server configuration

Operating system:
Ubuntu 16.04

Web server:
Apache

Database:
MySQL

PHP version:
7.1

ownCloud version:

ownCloud 10.0.10RC1

Updated from an older ownCloud or fresh install:
Fresh

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

Are you using encryption:
Yes

Logs

No logs in owncloud.log

Client configuration

browser

Firefox

@PVince81
Copy link
Contributor

PVince81 commented Sep 6, 2018

it is possible that when ctrl+c is hit, PHP doesn't run the shutdown handler and destructors, so it wouldn't release the file locks

if that's the case, we need to add a handler for ctrl+c (pcntl extension) and somehow initiate graceful shutdown

@DeepDiver1975

@sharidas
Copy link
Contributor

sharidas commented Sep 6, 2018

I was able to reproduce this error, by having Ctrl+C during rename operation at https://github.com/owncloud/core/blob/stable10/lib/private/Files/View.php#L1987.

@ownclouders
Copy link
Contributor

GitMate.io thinks possibly related issues are #22171 (Interruptable occ commands do not get interrupted when pressed ctrl-c), #26838 (File locking), #24737 (File Locked), #28991 (file is locked), and #16895 (File not decrypting).

@PVince81
Copy link
Contributor

PVince81 commented Sep 6, 2018

Another solution would be to provide an occ command to release the lock for all files.
The alternative is waiting one hour then running cron for lock expiration...

In a scenario where the admin decided to interrupt decryption after realizing that it takes longer than expected, they should be able to recover quickly from the file locks. That's where an occ command would come handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants