Reduce contention on file-update using advisory locks and weaker row locking.

This commit is contained in:
Andrey Antukh 2021-06-09 14:47:40 +02:00 committed by Andrés Moya
parent 2202f90d74
commit 144127224c
4 changed files with 37 additions and 10 deletions

View file

@ -268,8 +268,9 @@
(sv/defmethod ::update-file
[{:keys [pool] :as cfg} {:keys [id profile-id] :as params}]
(db/with-atomic [conn pool]
(let [{:keys [id] :as file} (db/get-by-id conn :file id {:for-update true})]
(let [{:keys [id] :as file} (db/get-by-id conn :file id {:for-key-share true})]
(files/check-edition-permissions! conn profile-id id)
(db/xact-lock! conn id)
(update-file (assoc cfg :conn conn)
(assoc params :file file)))))