mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 17:44:52 +09:00
Use updateGet for atomic access to projectNextTicket
`updateGet` isn't atomic by default. In PostgreSQL the default isolation level if committed read, and an `update` followed by a `get` doesn't guarantee you get the same value you sent. However I'm making a patch for `persistent` to make `updateGet` atomic for PostgreSQL.
This commit is contained in:
parent
fb909adf2e
commit
1ae924558f
1 changed files with 7 additions and 9 deletions
|
@ -179,10 +179,9 @@ projectOfferTicketF
|
|||
findRelevantCollections hLocal $
|
||||
activityAudience $ actbActivity body
|
||||
mremotesHttp <- runDBExcept $ do
|
||||
(sid, jid, ibid, fsid, next, tids) <-
|
||||
getProjectAndDeps deps
|
||||
(sid, jid, ibid, fsid, tids) <- getProjectAndDeps deps
|
||||
lift $ join <$> do
|
||||
mractid <- insertTicket jid ibid next tids
|
||||
mractid <- insertTicket jid ibid tids
|
||||
for mractid $ \ ractid -> for msig $ \ sig -> do
|
||||
remoteRecips <- deliverLocal ractid colls sid fsid
|
||||
(sig,) <$> deliverRemoteDB (actbBL body) ractid jid sig remoteRecips
|
||||
|
@ -234,11 +233,8 @@ projectOfferTicketF
|
|||
tids <- for deps $ \ dep -> do
|
||||
mtid <- lift $ getKeyBy $ UniqueTicket jid dep
|
||||
fromMaybeE mtid "Local dep: No such ticket number in DB"
|
||||
return
|
||||
( sid, jid, projectInbox j, projectFollowers j, projectNextTicket j
|
||||
, tids
|
||||
)
|
||||
insertTicket jid ibid next deps = do
|
||||
return (sid, jid, projectInbox j, projectFollowers j, tids)
|
||||
insertTicket jid ibid deps = do
|
||||
let iidAuthor = remoteAuthorInstance author
|
||||
raidAuthor = remoteAuthorId author
|
||||
ractid <- either entityKey id <$> insertBy' RemoteActivity
|
||||
|
@ -254,7 +250,9 @@ projectOfferTicketF
|
|||
delete ibiid
|
||||
return Nothing
|
||||
Just _ibirid -> do
|
||||
update jid [ProjectNextTicket +=. 1]
|
||||
next <-
|
||||
((subtract 1) . projectNextTicket) <$>
|
||||
updateGet jid [ProjectNextTicket +=. 1]
|
||||
did <- insert Discussion
|
||||
fsid <- insert FollowerSet
|
||||
tid <- insert Ticket
|
||||
|
|
Loading…
Reference in a new issue