Upgrading from 13.0.5 to 14.0.12 causing major problems

Hi. I have been using nextcloud 13.0.5 for quite a while and decided to upgrade to 14.0.12. My kernel is 4.19.45 php version is 7.2 and my apache version is 2.4.39. I am using postgresql 10.8 as my database. I am using gentoo updated to a few weeks ago. Now when I upgrade to 14.0.12, when I log in and go to one of my files which is shared, the share link is checked, but the link itself is not visible. Also, if I unckeck the share link checkbox, I get erros about duplicate entries in some lock table and if I check the box, I get those errors again. The errors are not on the page, but in one of my logs.

Anyone have any ideas as to what to do about this problem? I went back to 13.0.5 and restored the database and all is back to normal.

Thanks in advance for any suggestions.

Back then, they added other indeces to the database, possible that such a thing went wrong. But without the logs it is difficult to say.

There are some maintenance commands that let you repair the setup:
https://docs.nextcloud.com/server/14/admin_manual/configuration_server/occ_command.html#maintenance-commands

If I try upgrading again what logs would you need? Also, how can I
get the shared link to appear in the gui? I had to go back to 13
because I have to share out links and I would not be able to do so
under 14.0.12.

Anyone have any ideas? Would upgrading o 15.x help me at all?

So, I upgraded to 15.0.7 and it sort of works, but whenever I share a link I get stuff like this:
postgres[3327]: 2019-06-05 10:27:39.500 EDT [8912] ERROR: duplicate key value violates unique constraint “lock_key_index”
postgres[3327]: 2019-06-05 10:27:39.500 EDT [8912] DETAIL: Key (key)=(files/047bdb651ce87858fd047d349a2af710) already exists.
postgres[3327]: 2019-06-05 10:27:39.500 EDT [8912] STATEMENT: INSERT INTO “oc_file_locks” (“key”, “lock”, “ttl”) VALUES($1, $2, $3)
postgres[3327]: 2019-06-05 10:27:39.504 EDT [8912] ERROR: duplicate key value violates unique constraint “lock_key_index”
postgres[3327]: 2019-06-05 10:27:39.504 EDT [8912] DETAIL: Key (key)=(files/c0c5cf315b1dcb73013f8f59fc1d4c3b) already exists.
postgres[3327]: 2019-06-05 10:27:39.504 EDT [8912] STATEMENT: INSERT INTO “oc_file_locks” (“key”, “lock”, “ttl”) VALUES($1, $2, $3)
postgres[3327]: 2019-06-05 10:27:39.507 EDT [8912] ERROR: duplicate key value violates unique constraint “lock_key_index”
postgres[3327]: 2019-06-05 10:27:39.507 EDT [8912] DETAIL: Key (key)=(files/5380bcb8e27f18d2642c2cc298f39daf) already exists.
postgres[3327]: 2019-06-05 10:27:39.507 EDT [8912] STATEMENT: INSERT INTO “oc_file_locks” (“key”, “lock”, “ttl”) VALUES($1, $2, $3)
postgres[3327]: 2019-06-05 10:27:40.447 EDT [8920] ERROR: duplicate key value violates unique constraint “lock_key_index”
postgres[3327]: 2019-06-05 10:27:40.447 EDT [8920] DETAIL: Key (key)=(files/047bdb651ce87858fd047d349a2af710) already exists.
postgres[3327]: 2019-06-05 10:27:40.447 EDT [8920] STATEMENT: INSERT INTO “oc_file_locks” (“key”, “lock”, “ttl”) VALUES($1, $2, $3)
postgres[3327]: 2019-06-05 10:27:40.451 EDT [8920] ERROR: duplicate key value violates unique constraint “lock_key_index”
postgres[3327]: 2019-06-05 10:27:40.451 EDT [8920] DETAIL: Key (key)=(files/c0c5cf315b1dcb73013f8f59fc1d4c3b) already exists.
postgres[3327]: 2019-06-05 10:27:40.451 EDT [8920] STATEMENT: INSERT INTO “oc_file_locks” (“key”, “lock”, “ttl”) VALUES($1, $2, $3)
postgres[3327]: 2019-06-05 10:27:40.454 EDT [8920] ERROR: duplicate key value violates unique constraint “lock_key_index”
postgres[3327]: 2019-06-05 10:27:40.454 EDT [8920] DETAIL: Key (key)=(files/5380bcb8e27f18d2642c2cc298f39daf) already exists.
postgres[3327]: 2019-06-05 10:27:40.454 EDT [8920] STATEMENT: INSERT INTO “oc_file_locks” (“key”, “lock”, “ttl”) VALUES($1, $2, $3)

How can I fix?

In general, I would recommend to use redis for file locking. It’s just very slow on a sql database and uses a lot of resources.

Once you are in maintenance mode, the locking is lost anyway, so you should be able to empty the oc_file_locks table. Why you have duplicates is hard to say, perhaps a cleanup routine didn’t work properly or some other problems.

That is very helpful. How would I use redis this way, I am not
familiar with that package. How do I tell nextcloud to use it?

Well, I do think there is a bug here: I did the following:

put the system into maintainance mode. Then I delete everything from
the oc_file_locks table (there were 4 rows). Then I turned
maintainance mode off and found a file and clicked shared (the link
had been shared already) and got the following messages from
postgresql and nothing in the nextcloud.log:

postgres[3327]: 2019-06-11 05:12:34.261 EDT [10599] ERROR: duplicate
key value violates unique constraint “lock_key_index”
postgres[3327]: 2019-06-11 05:12:34.261 EDT [10599] DETAIL: Key
(key)=(files/64f38aa872d75afbba8419fe8d75a7a4) already exists.
postgres[3327]: 2019-06-11 05:12:34.261 EDT [10599] STATEMENT: INSERT
INTO “oc_file_locks” (“key”, “lock”, “ttl”) VALUES($1, $2, $3)
postgres[3327]: 2019-06-11 05:12:34.265 EDT [10599] ERROR: duplicate
key value violates unique constraint “lock_key_index”
postgres[3327]: 2019-06-11 05:12:34.265 EDT [10599] DETAIL: Key
(key)=(files/c0c5cf315b1dcb73013f8f59fc1d4c3b) already exists.
postgres[3327]: 2019-06-11 05:12:34.265 EDT [10599] STATEMENT: INSERT
INTO “oc_file_locks” (“key”, “lock”, “ttl”) VALUES($1, $2, $3)
postgres[3327]: 2019-06-11 05:12:34.268 EDT [10599] ERROR: duplicate
key value violates unique constraint “lock_key_index”
postgres[3327]: 2019-06-11 05:12:34.268 EDT [10599] DETAIL: Key
(key)=(files/5380bcb8e27f18d2642c2cc298f39daf) already exists.
postgres[3327]: 2019-06-11 05:12:34.268 EDT [10599] STATEMENT: INSERT
INTO “oc_file_locks” (“key”, “lock”, “ttl”) VALUES($1, $2, $3)

How can this be fixed?

With this message, I found a bug report (https://github.com/nextcloud/server/issues/12729) that was fixed in NC 16: https://github.com/nextcloud/server/pull/13721, not sure if it is the same and if the fix can easily be backported (please ask in the bug tracker).
I also found a newer still open issue: https://github.com/nextcloud/server/issues/15047

OK, I will check those out – thanks.