mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
Lock the topic while computing topic_position
This commit is contained in:
parent
5e908e40f6
commit
e2c94dda6c
1 changed files with 5 additions and 0 deletions
|
@ -57,11 +57,16 @@ defmodule Philomena.Posts do
|
||||||
Topic
|
Topic
|
||||||
|> where(id: ^topic.id)
|
|> where(id: ^topic.id)
|
||||||
|
|
||||||
|
topic_lock_query =
|
||||||
|
topic_query
|
||||||
|
|> lock("FOR UPDATE")
|
||||||
|
|
||||||
forum_query =
|
forum_query =
|
||||||
Forum
|
Forum
|
||||||
|> where(id: ^topic.forum_id)
|
|> where(id: ^topic.forum_id)
|
||||||
|
|
||||||
Multi.new()
|
Multi.new()
|
||||||
|
|> Multi.all(:topic_lock, topic_lock_query)
|
||||||
|> Multi.run(:post, fn repo, _ ->
|
|> Multi.run(:post, fn repo, _ ->
|
||||||
last_position =
|
last_position =
|
||||||
Post
|
Post
|
||||||
|
|
Loading…
Reference in a new issue