Owncloud 8.1.5: File upload error Table ‘homeclouddb.oc_locks’ doesn’t exist”

By | February 26, 2016

After an OwnCloud upgrade I was getting complains from my users that WebDav and OwnCloud windows client were no longer able to upload files.

By looking into owncloud.log the following was the repeated error:

{"app":"remote","message":"An exception occurred while executing 'SELECT * FROM oc_locks WHERE userid = ? AND (created + timeout) > 1456517102 AND (( uri = ?) OR (depth != 0 AND uri = ?))':\n\nSQLSTATE[42S02]: Base table or view not found: 1146 Table 'homeclouddb.oc_locks' doesn't exist","level":4,"time":"2016-02-26T20:05:02+00:00"}

So the issue was caused by the missing table oc_locks. This table is used by the file lock algorithm that locks files that are uploading to try to avoid corruption of files accessed by concurrent clients.
The weird thing is that looking on the owncloud forums I found out that this is a deprecated table in owncloud 8.1. The locking algorithm is supposed to use some other method not involving this table. It seems that somehow the version 8.1.5 from the Suse repository I am using still needs this table (file lock table).

To fix the issue I had to manually create this missing table in the homeclouddb the owncloud mariadb database of my deploy.

Connect to mysql/mariadb database as root

mysql -uroot -p

Connect to the owncloud database instance in mysql shell

MariaDB [(none)]> use homeclouddb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Check what tables we have in the owncloud database and if the oc_locks exists

MariaDB [homeclouddb]> show tables
-> ;
| Tables_in_homeclouddb |
| oc_activity |
| oc_activity_mq |
| oc_appconfig |
| oc_clndr_calendars |
| oc_clndr_objects |
| oc_clndr_repeat |
| oc_clndr_share_calendar |
| oc_clndr_share_event |
| oc_contacts_addressbooks |
| oc_contacts_cards |
| oc_contacts_cards_properties |
| oc_documents_invite |
| oc_documents_member |
| oc_documents_op |
| oc_documents_revisions |
| oc_documents_session |
| oc_file_map |
| oc_filecache |
| oc_files_trash |
| oc_gallery_sharing |
| oc_group_admin |
| oc_group_user |
| oc_groups |
| oc_jobs |
| oc_locks |
| oc_lucene_status |
| oc_mimetypes |
| oc_ocDashboard_usedHashs |
| oc_preferences |
| oc_privatedata |
| oc_properties |
| oc_share |
| oc_share_external |
| oc_shorty |
| oc_storages |
| oc_users |
| oc_vcategory |
| oc_vcategory_to_object |
38 rows in set (0.00 sec)

Create the missing table as found on a forum for owncloud 7

CREATE TABLE oc_locks (
id int(11) unsigned NOT NULL AUTO_INCREMENT,
userid int(11) unsigned NOT NULL,
created int(11) unsigned NOT NULL,
timeout int(11) unsigned NOT NULL,
depth int(11) unsigned NOT NULL,
uri varchar(255) NOT NULL DEFAULT '',

Note that it may happen that you have the table but there are some missing columns.


I found out that the above create was not enough so I had to add the following columns also (as deduced from the github da structure for 8.0)

MariaDB [homeclouddb]> alter table oc_locks add owner text;
Query OK, 0 rows affected (0.36 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [homeclouddb]> alter table oc_locks add scope integer;
Query OK, 0 rows affected (0.19 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [homeclouddb]> alter table oc_locks add token text;
Query OK, 0 rows affected (0.18 sec)
Records: 0 Duplicates: 0 Warnings: 0

After this last step the upload of files by WebDav or the synchronization using the Windows Client has no issues.


2 thoughts on “Owncloud 8.1.5: File upload error Table ‘homeclouddb.oc_locks’ doesn’t exist”

  1. Half Baked

    What a life saver. Can’t find any other documentation on this anywhere

    1. voinageo Post author

      Glad to be of help, I had the same head banging experience until I found a fix. I recommend upgrading to owncloud 9.1, it has the long awaited two factor authentication.


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.