General error: 1205 Lock wait timeout exceeded; try restarting transaction

Nextcloud version (eg, 12.0.5): 12.05
Operating system and version (eg, Ubuntu 17.04): Ubuntu 16.04
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.29
PHP version (eg, 7.1): 7.1.13

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. Start nextcloud client and attempt to sync camera video directory to NC.

The output of your Nextcloud log in Admin > Logging:

Exception while scanning file "ispy/video/DLINK5020L/1_2017-11-07_14-07-03.mp4": An exception occurred while executing 'INSERT INTO `oc_filecache` (`mimepart`,`mimetype`,`mtime`,`size`,`etag`,`storage_mtime`,`permissions`,`parent`,`checksum`,`path_hash`,`path`,`name`,`storage`) SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? FROM `oc_filecache` WHERE `storage` = ? AND `path_hash` = ? HAVING COUNT(*) = 0' with params ["15", "16", 1510081681, 176685, "5a75d9552ba64", 1510081681, 27, 170352, "", "896aa24ead4d58ef759720f73cc3bbfb", "ispy\/video\/DLINK5020L\/1_2017-11-07_14-07-03.mp4", "1_2017-11-07_14-07-03.mp4", 81, 81, "896aa24ead4d58ef759720f73cc3bbfb"]: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'oc83c7828XXX',
  'passwordsalt' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  'trusted_domains' =>
  array (
    0 => '192.168.XXX.XXX',
    1 => 'cloud.domain.tld',
  ),
  'trusted_proxies' =>
  array (
    0 => '192.168.XXX.XXX',
  ),
  'forwarded_for_headers' =>
  array (
    0 => 'HTTP_X_FORWARDED_FOR',
  ),
  'auth.bruteforce.protection.enabled' => true,
  'datadirectory' => '/mnt/raid/owncloud/data',
  'dbtype' => 'mysql',
  'version' => '12.0.5.3',
  'dbname' => 'owncloud7',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'DBUSER',
  'dbpassword' => 'DBPASSWORD',
  'installed' => true,
  'forcessl' => true,
  'mail_smtpmode' => 'smtp',
'mail_from_address' => 'postmaster',
  'mail_domain' => 'domain.tld',
  'mail_smtphost' => 'smtp.domain.tld',
  'mail_smtpport' => '25',
  'loglevel' => 0,
  'theme' => '',
  'maintenance' => false,
  'secret' => 'SOME_SECRET',
  'trashbin_retention_obligation' => 'auto',
  'updatechecker' => false,
  'updater.secret' => 'SOME_SECRET',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 0.0,
  ),
  'overwrite.cli.url' => 'https://cloud.domain.tld',
);

The output of your Apache/nginx/system log in /var/log/____:

192.168.XXX.XXX - dedwards [03/Feb/2018:06:38:25 -0500] "PUT /remote.php/dav/files/dedwards/dedwards/ispy/video/DLINK5020L/1_2017-11-07_14-07-03.mp4 HTTP/1.0" 500 1560 "-" "Mozilla/5.0 (Windows) mirall/2.3.3 (build 1) (Nextcloud)"

Well that’s a classic mysql error message. Does restarting mysql help? Are there any other messages in mysql or apache / nginx?

You should consider increasing the lock wait timeout value for InnoDB by setting the
innodb_lock_wait_timeout, default is 50 sec to an higher value

You can set it to higher value in /etc/my.cnf (depending your config and distro ) permanently with this line

[mysqld]
innodb_lock_wait_timeout=120

personnaly, using 300

2 Likes

Thanks I’ll start with 120 and go from there. Appreciate the tip.