Skip to content

Commit

Permalink
ReadCommitted for definition searches, no need to wait for locking
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Jul 24, 2024
1 parent 93575b2 commit c7d0d73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions src/Share/BackgroundJobs/Search/DefinitionSync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ import Share.Postgres.NameLookups.Types qualified as NL
import Share.Postgres.Queries qualified as PG
import Share.Postgres.Search.DefinitionSearch.Queries qualified as DDQ
import Share.Prelude
import Share.Project (Project (..), ProjectVisibility (..))
import Share.Project (Project (..))
import Share.Release (Release (..))
import Share.User (User (..), UserVisibility (..))
import Share.Utils.Logging qualified as Logging
import Share.Web.Authorization qualified as AuthZ
import U.Codebase.Referent (Referent)
Expand Down Expand Up @@ -91,12 +90,7 @@ syncRelease authZReceipt releaseId = fmap (fromMaybe []) . runMaybeT $ do
-- Wipe out any existing rows for this release. Normally there should be none, but this
-- makes it easy to re-index later if we change how we tokenize things.
lift $ DDQ.cleanIndexForRelease releaseId
Project {ownerUserId, visibility = projectVis} <- lift $ PG.expectProjectById projectId
User {visibility = userVis} <- PG.expectUserByUserId ownerUserId
-- Don't sync private projects
guard $ projectVis == ProjectPublic
-- Don't sync private users
guard $ userVis == UserPublic
Project {ownerUserId} <- lift $ PG.expectProjectById projectId
Debug.debugM Debug.Temp "Syncing release" releaseId
lift $ do
bhId <- HashQ.expectNamespaceIdsByCausalIdsOf id squashedCausal
Expand Down
2 changes: 1 addition & 1 deletion src/Share/Web/Share/Impl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ searchDefinitionsEndpoint callerUserId (Query query) mayLimit userFilter project
pure $ DefinitionSearchResults []
Right (searchTokens, mayArity) -> do
matches <-
PG.runTransaction $
PG.runTransactionMode PG.ReadCommitted PG.Read $
DDQ.definitionSearch callerUserId filter limit searchTokens mayArity
>>= PQ.expectProjectShortHandsOf (traversed . _1)
>>= RQ.expectReleaseVersionsOf (traversed . _2)
Expand Down

0 comments on commit c7d0d73

Please sign in to comment.