Skip to content

Commit 9e9897e

Browse files
committed
Use safer transaction modes
1 parent aef0e12 commit 9e9897e

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/Share/BackgroundJobs/Diffs/ContributionDiffs.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ worker scope = do
3737

3838
processDiffs :: AuthZ.AuthZReceipt -> Background (Either NamespaceDiffError ())
3939
processDiffs authZReceipt = Metrics.recordContributionDiffDuration . runExceptT $ do
40-
mayContributionId <- PG.runTransactionMode PG.ReadCommitted PG.ReadWrite $ do
41-
DQ.claimContributionToDiff
40+
mayContributionId <- PG.runTransaction DQ.claimContributionToDiff
4241
for_ mayContributionId (diffContribution authZReceipt)
4342
case mayContributionId of
4443
Just contributionId -> do

src/Share/BackgroundJobs/Search/DefinitionSync.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ worker scope = do
8686
liftIO $ UnliftIO.threadDelay $ pollingIntervalSeconds * 1000000
8787
where
8888
processReleases authZReceipt = do
89-
(mayErrs, mayProcessedRelease) <- Metrics.recordDefinitionSearchIndexDuration $ PG.runTransactionMode PG.ReadCommitted PG.ReadWrite $ do
89+
(mayErrs, mayProcessedRelease) <- Metrics.recordDefinitionSearchIndexDuration $ PG.runTransaction $ do
9090
mayReleaseId <- DDQ.claimUnsyncedRelease
9191
mayErrs <- for mayReleaseId (syncRelease authZReceipt)
9292
pure (mayErrs, mayReleaseId)

src/Share/Postgres/Definitions/Queries.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ ensureTextIdsOf trav s = do
601601
ensureBytesIds :: (QueryM m) => (Traversable t) => t BS.ByteString -> m (t BytesId)
602602
ensureBytesIds = ensureBytesIdsOf traversed
603603

604-
-- | Efficiently saves all Text's focused by the provided traversal into the database and
604+
-- | Efficiently saves all bytestrings focused by the provided traversal into the database and
605605
-- replaces them with their corresponding Ids.
606606
ensureBytesIdsOf :: (QueryM m) => Traversal s t BS.ByteString BytesId -> s -> m t
607607
ensureBytesIdsOf trav s = do

src/Share/Web/Share/Diffs/Impl.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ diffTerms !_authZReceipt old@(_, _, oldName) new@(_, _, newName) = do
161161
getTermDefinition :: (Codebase.CodebaseEnv, BranchHashId, Name) -> AppM r (Maybe TermDefinition)
162162
getTermDefinition (codebase, bhId, name) = do
163163
let perspective = Path.empty
164-
(namesPerspective, Identity relocatedName) <- PG.runTransactionMode PG.ReadCommitted PG.Read $ NameLookupOps.relocateToNameRoot perspective (Identity name) bhId
164+
(namesPerspective, Identity relocatedName) <- PG.runTransaction $ NameLookupOps.relocateToNameRoot perspective (Identity name) bhId
165165
let ppedBuilder deps = (PPED.biasTo [name]) <$> lift (PPEPostgres.ppedForReferences namesPerspective deps)
166166
let nameSearch = PGNameSearch.nameSearchForPerspective namesPerspective
167167
rt <- Codebase.codebaseRuntime codebase
168-
Codebase.runCodebaseTransactionMode PG.ReadCommitted codebase do
168+
Codebase.runCodebaseTransaction codebase do
169169
Definitions.termDefinitionByName ppedBuilder nameSearch renderWidth rt relocatedName
170170
where
171171
renderWidth :: Width
@@ -190,11 +190,11 @@ diffTypes !_authZReceipt old@(_, _, oldTypeName) new@(_, _, newTypeName) = do
190190
getTypeDefinition :: (Codebase.CodebaseEnv, BranchHashId, Name) -> AppM r (Maybe TypeDefinition)
191191
getTypeDefinition (codebase, bhId, name) = do
192192
let perspective = Path.empty
193-
(namesPerspective, Identity relocatedName) <- PG.runTransactionMode PG.ReadCommitted PG.Read $ NameLookupOps.relocateToNameRoot perspective (Identity name) bhId
193+
(namesPerspective, Identity relocatedName) <- PG.runTransaction $ NameLookupOps.relocateToNameRoot perspective (Identity name) bhId
194194
let ppedBuilder deps = (PPED.biasTo [name]) <$> lift (PPEPostgres.ppedForReferences namesPerspective deps)
195195
let nameSearch = PGNameSearch.nameSearchForPerspective namesPerspective
196196
rt <- Codebase.codebaseRuntime codebase
197-
Codebase.runCodebaseTransactionMode PG.ReadCommitted codebase do
197+
Codebase.runCodebaseTransaction codebase do
198198
Definitions.typeDefinitionByName ppedBuilder nameSearch renderWidth rt relocatedName
199199
where
200200
renderWidth :: Width

0 commit comments

Comments
 (0)