Postgresql genarate many deadlock error

Hi,
I don’t know what I do wrong but I get multiple PostreSQL error like this one:

2017-12-10 20:47:40 EST [4436-2] intranet_example_com@intranet_example_com DETAIL:  Process 4436 waits for ShareLock on transaction 3420773; blocked by process 4464.
        Process 4464 waits for ShareLock on transaction 3420774; blocked by process 4436.
        Process 4436: UPDATE "oc_file_locks" SET "lock" = "lock" -1 WHERE ("key" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30)) AND ("lock" > 0)
        Process 4464: UPDATE "oc_file_locks" SET "lock" = "lock" + 1, "ttl" = $1 WHERE "key" = $2 AND "lock" >= 0
2017-12-10 20:47:40 EST [4436-3] intranet_example_com@intranet_example_com HINT:  See server log for query details.
2017-12-10 20:47:40 EST [4436-4] intranet_example_com@intranet_example_com CONTEXT:  while updating tuple (0,51) in relation "oc_file_locks"
2017-12-10 20:47:40 EST [4436-5] intranet_example_com@intranet_example_com STATEMENT:  UPDATE "oc_file_locks" SET "lock" = "lock" -1 WHERE ("key" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30)) AND ("lock" > 0)

If you look further, it seams processes requesting ShareLock are blocked circularly.

You handle the file_locking with your database. For better performance, use redis for file-locking that will reduce the load on your database and probably solves this problem:
https://docs.nextcloud.com/server/12/admin_manual/configuration_server/caching_configuration.html?highlight=redis#id3