Nextcloud transitional file lock database meaning

Hello to everybody. Today I uploaded a directory to nextcloud on the browser interface and then I had to stop the upload.
After doing it I was not able to delete anymore the directory.

I had time ago this issue and i solved deleting from oc_file_locks the locked files records. But I wold like to understand more how it works.

For example while I upload a file I can find

MariaDB [d_nextcloud]> select * from oc_file_locks where `lock`!=0;
+---------+------+----------------------------------------+------------+
| id      | lock | key                                    | ttl        |
+---------+------+----------------------------------------+------------+
| 4142902 |    1 | files/cdc01a113083d1a50aee3225bfc60f3a | 1631817536 |
| 4142903 |    1 | files/86173500f0eb66a25a4296d0fe427d4e | 1631817536 |
| 4142905 |    1 | files/1cc1d9ea7e0dbb44a6a2473e6d27b82e | 1631817536 |
| 4142908 |   -1 | files/18719414b4ec566597e43522f8312b52 | 1631817536 |
| 4142909 |    1 | files/efb4620b9ca2ade3d4447d3966e9c680 | 1631817536 |
| 4142910 |    1 | files/b6f1accfc07471e0363bc0c16644d699 | 1631817536 |
| 4142911 |    1 | files/40bc2866c3b6c15b466193556fe6cc29 | 1631817536 |
| 4142912 |    1 | files/cfc9c22a1316eeb23b83057585f8b750 | 1631817536 |
+---------+------+----------------------------------------+------------+

So how to understand which file are locked? I should make a join with oc_filecache? Which query should I use?
Then, why if I

MariaDB [d_nextcloud]> select * from oc_file_locks where `lock`=0;
[...]
412 rows in set (0.002 sec)

Why after lock removed the records are not removed?

What happens if I delete this row, I let some dust in file system? I risk file corruption?

Normally you lock files, when they are modified (opened in an app) so others can’t change it. In case they are falsely locked, they should unlock after some time, not sure exactly about the timing here, if the cronjobs handle this. It can be a performance problem on mariadb or mysql, so it is better to use redis.

If everything got locked up, you can manually deleted the entries (the file lock table only).

Thanks. Si I don’t create any trouble if sometimes i delete that table.

What about the menaing of -1 or 1 in the lock status? It is explained somewhere or to understand that the only way is to study the code?

The thing is, it shouldn’t be necessary. So if you end up with that, there is probably some issue at some point of your setup. Perhaps too many requests on your database so it doesn’t handle everything, this could as well affect other queries in the database.

@tflidd
I am interested in oc_file_locks but i can not find code at GitHub.

org:nextcloud oc_file_locks (All GitHub)

Can you help me?