{"action":"created","issue":{"url":"https://api.github.com/repos/owncloud/core/issues/19457","labels_url":"https://api.github.com/repos/owncloud/core/issues/19457/labels{/name}","comments_url":"https://api.github.com/repos/owncloud/core/issues/19457/comments","events_url":"https://api.github.com/repos/owncloud/core/issues/19457/events","html_url":"https://github.com/owncloud/core/issues/19457","id":108954489,"number":19457,"title":"1205 Lock wait timeout exceeded when trying to access a file on external storage before it's ready","user":{"login":"oparoz","id":323220,"avatar_url":"https://avatars.githubusercontent.com/u/323220?v=3","gravatar_id":"","url":"https://api.github.com/users/oparoz","html_url":"https://github.com/oparoz","followers_url":"https://api.github.com/users/oparoz/followers","following_url":"https://api.github.com/users/oparoz/following{/other_user}","gists_url":"https://api.github.com/users/oparoz/gists{/gist_id}","starred_url":"https://api.github.com/users/oparoz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oparoz/subscriptions","organizations_url":"https://api.github.com/users/oparoz/orgs","repos_url":"https://api.github.com/users/oparoz/repos","events_url":"https://api.github.com/users/oparoz/events{/privacy}","received_events_url":"https://api.github.com/users/oparoz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/owncloud/core/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/owncloud/core/labels/sev2-high","name":"sev2-high","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"icewind1991","id":1283854,"avatar_url":"https://avatars.githubusercontent.com/u/1283854?v=3","gravatar_id":"","url":"https://api.github.com/users/icewind1991","html_url":"https://github.com/icewind1991","followers_url":"https://api.github.com/users/icewind1991/followers","following_url":"https://api.github.com/users/icewind1991/following{/other_user}","gists_url":"https://api.github.com/users/icewind1991/gists{/gist_id}","starred_url":"https://api.github.com/users/icewind1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icewind1991/subscriptions","organizations_url":"https://api.github.com/users/icewind1991/orgs","repos_url":"https://api.github.com/users/icewind1991/repos","events_url":"https://api.github.com/users/icewind1991/events{/privacy}","received_events_url":"https://api.github.com/users/icewind1991/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/owncloud/core/milestones/37","html_url":"https://github.com/owncloud/core/milestones/8.2-current","labels_url":"https://api.github.com/repos/owncloud/core/milestones/37/labels","id":993629,"number":37,"title":"8.2-current","description":"","creator":{"login":"craigpg","id":160667,"avatar_url":"https://avatars.githubusercontent.com/u/160667?v=3","gravatar_id":"","url":"https://api.github.com/users/craigpg","html_url":"https://github.com/craigpg","followers_url":"https://api.github.com/users/craigpg/followers","following_url":"https://api.github.com/users/craigpg/following{/other_user}","gists_url":"https://api.github.com/users/craigpg/gists{/gist_id}","starred_url":"https://api.github.com/users/craigpg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/craigpg/subscriptions","organizations_url":"https://api.github.com/users/craigpg/orgs","repos_url":"https://api.github.com/users/craigpg/repos","events_url":"https://api.github.com/users/craigpg/events{/privacy}","received_events_url":"https://api.github.com/users/craigpg/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":1202,"state":"open","created_at":"2015-02-24T16:19:37Z","updated_at":"2015-10-08T13:09:50Z","due_on":"2015-10-20T04:00:00Z","closed_at":null},"comments":23,"created_at":"2015-09-29T20:35:22Z","updated_at":"2015-10-08T13:30:40Z","closed_at":null,"body":"### Steps to reproduce\r\n\r\n1. Add this code somewhere\r\n```\r\n$scanner = new \\OC\\Files\\Utils\\Scanner($user, \\OC::$server->getDatabaseConnection());\r\n$scanner->listen('\\OC\\Files\\Utils\\Scanner', 'scanFile', function ($path) use ($output) {\r\n\t$path = normalizePathToMakeItWorkWithPreview($path);\r\n\t$preview = new Preview($user, 'files', $path);\r\n\t$preview->setMaxX($this->thumbnailWidth);\r\n\t$preview->setMaxY($this->thumbnailHeight);\r\n\t$preview->setKeepAspect(true);\r\n\t$preview->getPreview();\r\n});\r\n```\r\n\r\n1. Connect your instance to another oC instance using files_ external -> WebDAV\r\n2. Upload a new file in the external cloud\r\n3. Launch your script\r\n\r\nNow the scanner is going loopy. It tries a hundred time to access the newly uploaded file, but it's never ready (unlocked?). A possible race condition? \r\n\r\n1. Change mount option to \"Every time the filesytem is used\" (value 2).\r\n2. Launch your script again\r\n\r\nThis time it's worse, the scanner keeps trying to access the external folder until the command is killed.\r\n\r\n### Notes\r\n\r\n* I think this happens because `getPreview()` tries to access the file before it's stored in the cache\r\n* New thumbnails, as they're generated, are also sent to the preview generator via the `scanFile` event\r\n* When using `postScanFile` things seem to work as expected, but some people have reported experiencing the same issue with it\r\n* Utils\\Scanner **does not** use transactional locking\r\n\r\n\r\n### Logs \r\n\r\nThis is for the last operation, when always getting the folder.\r\n\r\n```\r\n{\"reqId\":\"o2g1Y985c54xz\\/5dY2C1\",\"remoteAddr\":\"10.0.2.2\",\"app\":\"webdav\",\"message\":\"Exception: {\\\"Message\\\":\\\"An exception occurred while executing 'UPDATE `oc_file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0' with params [1443562215, \\\\\\\"files\\\\\\\\\\\\\\/a3594fd4eca7119cb937772e1f8f5415\\\\\\\"]:\\\\n\\\\nSQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction\\\",\\\"Exception\\\":\\\"Doctrine\\\\\\\\DBAL\\\\\\\\Exception\\\\\\\\DriverException\\\",\\\"Code\\\":0,\\\"Trace\\\":\\\"#0 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/doctrine\\\\\\/dbal\\\\\\/lib\\\\\\/Doctrine\\\\\\/DBAL\\\\\\/DBALException.php(116): Doctrine\\\\\\\\DBAL\\\\\\\\Driver\\\\\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\\\\\DBAL\\\\\\\\Driver\\\\\\\\PDOException))\\\\n#1 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/doctrine\\\\\\/dbal\\\\\\/lib\\\\\\/Doctrine\\\\\\/DBAL\\\\\\/Connection.php(996): Doctrine\\\\\\\\DBAL\\\\\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\\\\\DBAL\\\\\\\\Driver\\\\\\\\PDOMySql\\\\\\\\Driver), Object(Doctrine\\\\\\\\DBAL\\\\\\\\Driver\\\\\\\\PDOException), 'UPDATE `oc_file...', Array)\\\\n#2 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/db\\\\\\/connection.php(203): Doctrine\\\\\\\\DBAL\\\\\\\\Connection->executeUpdate('UPDATE `oc_file...', Array, Array)\\\\n#3 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/lock\\\\\\/dblockingprovider.php(112): OC\\\\\\\\DB\\\\\\\\Connection->executeUpdate('UPDATE `*PREFIX...', Array)\\\\n#4 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/files\\\\\\/storage\\\\\\/common.php(638): OC\\\\\\\\Lock\\\\\\\\DBLockingProvider->acquireLock('files\\\\\\/a3594fd4e...', 1)\\\\n#5 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/files\\\\\\/storage\\\\\\/wrapper\\\\\\/wrapper.php(571): OC\\\\\\\\Files\\\\\\\\Storage\\\\\\\\Common->acquireLock('files', 1, Object(OC\\\\\\\\Lock\\\\\\\\DBLockingProvider))\\\\n#6 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/files\\\\\\/view.php(1779): OC\\\\\\\\Files\\\\\\\\Storage\\\\\\\\Wrapper\\\\\\\\Wrapper->acquireLock('files', 1, Object(OC\\\\\\\\Lock\\\\\\\\DBLockingProvider))\\\\n#7 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/files\\\\\\/view.php(1874): OC\\\\\\\\Files\\\\\\\\View->lockPath('', 1, false)\\\\n#8 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/files\\\\\\/view.php(1190): OC\\\\\\\\Files\\\\\\\\View->lockFile('', 1)\\\\n#9 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/connector\\\\\\/sabre\\\\\\/serverfactory.php(83): OC\\\\\\\\Files\\\\\\\\View->getFileInfo('')\\\\n#10 [internal function]: OC\\\\\\\\Connector\\\\\\\\Sabre\\\\\\\\ServerFactory->OC\\\\\\\\Connector\\\\\\\\Sabre\\\\\\\\{closure}(Object(Sabre\\\\\\\\HTTP\\\\\\\\Request), Object(Sabre\\\\\\\\HTTP\\\\\\\\Response))\\\\n#11 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/sabre\\\\\\/event\\\\\\/lib\\\\\\/EventEmitterTrait.php(105): call_user_func_array(Object(Closure), Array)\\\\n#12 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/sabre\\\\\\/dav\\\\\\/lib\\\\\\/DAV\\\\\\/Server.php(456): Sabre\\\\\\\\Event\\\\\\\\EventEmitter->emit('beforeMethod', Array)\\\\n#13 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/sabre\\\\\\/dav\\\\\\/lib\\\\\\/DAV\\\\\\/Server.php(254): Sabre\\\\\\\\DAV\\\\\\\\Server->invokeMethod(Object(Sabre\\\\\\\\HTTP\\\\\\\\Request), Object(Sabre\\\\\\\\HTTP\\\\\\\\Response))\\\\n#14 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/apps\\\\\\/files\\\\\\/appinfo\\\\\\/remote.php(56): Sabre\\\\\\\\DAV\\\\\\\\Server->exec()\\\\n#15 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/remote.php(137): require_once('\\\\\\/var\\\\\\/www\\\\\\/ownclo...')\\\\n#16 {main}\\\",\\\"File\\\":\\\"\\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/doctrine\\\\\\/dbal\\\\\\/lib\\\\\\/Doctrine\\\\\\/DBAL\\\\\\/Driver\\\\\\/AbstractMySQLDriver.php\\\",\\\"Line\\\":115}\",\"level\":4,\"time\":\"2015-09-29T20:31:06+00:00\",\"method\":\"PROPFIND\",\"url\":\"\\/owncloud\\/remote.php\\/webdav\\/\"}\r\n{\"reqId\":\"Qb5n+Cq7CxO6bRP1sZRI\",\"remoteAddr\":\"10.0.2.2\",\"app\":\"webdav\",\"message\":\"Exception: {\\\"Message\\\":\\\"HTTP\\\\\\/1.1 401 No basic authentication headers were found\\\",\\\"Exception\\\":\\\"Sabre\\\\\\\\DAV\\\\\\\\Exception\\\\\\\\NotAuthenticated\\\",\\\"Code\\\":0,\\\"Trace\\\":\\\"#0 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/connector\\\\\\/sabre\\\\\\/auth.php(149): Sabre\\\\\\\\DAV\\\\\\\\Auth\\\\\\\\Backend\\\\\\\\AbstractBasic->authenticate(Object(OC\\\\\\\\Connector\\\\\\\\Sabre\\\\\\\\Server), 'ownCloud')\\\\n#1 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/connector\\\\\\/sabre\\\\\\/auth.php(122): OC\\\\\\\\Connector\\\\\\\\Sabre\\\\\\\\Auth->auth(Object(OC\\\\\\\\Connector\\\\\\\\Sabre\\\\\\\\Server), 'ownCloud')\\\\n#2 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/sabre\\\\\\/dav\\\\\\/lib\\\\\\/DAV\\\\\\/Auth\\\\\\/Plugin.php(118): OC\\\\\\\\Connector\\\\\\\\Sabre\\\\\\\\Auth->authenticate(Object(OC\\\\\\\\Connector\\\\\\\\Sabre\\\\\\\\Server), 'ownCloud')\\\\n#3 [internal function]: Sabre\\\\\\\\DAV\\\\\\\\Auth\\\\\\\\Plugin->beforeMethod(Object(Sabre\\\\\\\\HTTP\\\\\\\\Request), Object(Sabre\\\\\\\\HTTP\\\\\\\\Response))\\\\n#4 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/sabre\\\\\\/event\\\\\\/lib\\\\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\\\n#5 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/sabre\\\\\\/dav\\\\\\/lib\\\\\\/DAV\\\\\\/Server.php(456): Sabre\\\\\\\\Event\\\\\\\\EventEmitter->emit('beforeMethod', Array)\\\\n#6 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/sabre\\\\\\/dav\\\\\\/lib\\\\\\/DAV\\\\\\/Server.php(254): Sabre\\\\\\\\DAV\\\\\\\\Server->invokeMethod(Object(Sabre\\\\\\\\HTTP\\\\\\\\Request), Object(Sabre\\\\\\\\HTTP\\\\\\\\Response))\\\\n#7 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/apps\\\\\\/files\\\\\\/appinfo\\\\\\/remote.php(56): Sabre\\\\\\\\DAV\\\\\\\\Server->exec()\\\\n#8 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/remote.php(137): require_once('\\\\\\/var\\\\\\/www\\\\\\/ownclo...')\\\\n#9 {main}\\\",\\\"File\\\":\\\"\\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/3rdparty\\\\\\/sabre\\\\\\/dav\\\\\\/lib\\\\\\/DAV\\\\\\/Auth\\\\\\/Backend\\\\\\/AbstractBasic.php\\\",\\\"Line\\\":70}\",\"level\":0,\"time\":\"2015-09-29T20:31:19+00:00\",\"method\":\"PROPFIND\",\"url\":\"\\/owncloud\\/remote.php\\/webdav\\/\"}\r\n```\r\n\r\n### Config\r\n\r\n```\r\n$CONFIG = array (\r\n  'datadirectory' => '/var/www/owncloud/data',\r\n  'dbtype' => 'mysql',\r\n  'version' => '8.2.0.6',\r\n  'logtimezone' => 'UTC',\r\n  'installed' => true,\r\n  'loglevel' => 0,\r\n  'theme' => '',\r\n  'maintenance' => false,\r\n  'enabledPreviewProviders' =>\r\n  array (\r\n    0 => 'OC\\\\Preview\\\\JPEG',\r\n    1 => 'OC\\\\Preview\\\\PNG',\r\n    2 => 'OC\\\\Preview\\\\GIF',\r\n    3 => 'OC\\\\Preview\\\\Postscript',\r\n    4 => 'OC\\\\Preview\\\\Font',\r\n    10 => 'OC\\\\Preview\\\\Photoshop',\r\n    11 => 'OC\\\\Preview\\\\Illustrator',\r\n    12 => 'OC\\\\Preview\\\\TIFF',\r\n    14 => 'OC\\\\Preview\\\\Raw',\r\n  ),\r\n  'preview_max_x' => 2048,\r\n  'preview_max_y' => 2048,\r\n  'debug' => true,\r\n  'updatechecker' => 'false',\r\n  'singleuser' => false,\r\n  'memcache.local' => '\\\\OC\\\\Memcache\\\\APCu',\r\n);\r\n```\r\n\r\n----\r\n\r\n@icewind1991 @PVince81 "},"comment":{"url":"https://api.github.com/repos/owncloud/core/issues/comments/146545632","html_url":"https://github.com/owncloud/core/issues/19457#issuecomment-146545632","issue_url":"https://api.github.com/repos/owncloud/core/issues/19457","id":146545632,"user":{"login":"icewind1991","id":1283854,"avatar_url":"https://avatars.githubusercontent.com/u/1283854?v=3","gravatar_id":"","url":"https://api.github.com/users/icewind1991","html_url":"https://github.com/icewind1991","followers_url":"https://api.github.com/users/icewind1991/followers","following_url":"https://api.github.com/users/icewind1991/following{/other_user}","gists_url":"https://api.github.com/users/icewind1991/gists{/gist_id}","starred_url":"https://api.github.com/users/icewind1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icewind1991/subscriptions","organizations_url":"https://api.github.com/users/icewind1991/orgs","repos_url":"https://api.github.com/users/icewind1991/repos","events_url":"https://api.github.com/users/icewind1991/events{/privacy}","received_events_url":"https://api.github.com/users/icewind1991/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T13:30:40Z","updated_at":"2015-10-08T13:30:40Z","body":"Fix is here: #19654"}}