Skip to content

Commit 665f55c

Browse files
committed
fix(wip): retrying transaction on 40001 errors
1 parent ff0873d commit 665f55c

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/PostgREST/AppState.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ retryingSchemaCacheLoad appState@AppState{stateObserver=observer, stateMainThrea
408408
qSchemaCache = do
409409
conf@AppConfig{..} <- getConfig appState
410410
(resultTime, result) <-
411-
timeItT $ usePool appState (SQL.transaction SQL.ReadCommitted SQL.Read $ querySchemaCache conf)
411+
timeItT $ usePool appState (SQL.transactionNoRetry SQL.ReadCommitted SQL.Read $ querySchemaCache conf)
412412
case result of
413413
Left e -> do
414414
putSCacheStatus appState SCPending

src/PostgREST/CLI.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ main CLI{cliCommand, cliPath} = do
5353
dumpSchema :: AppState -> IO LBS.ByteString
5454
dumpSchema appState = do
5555
conf@AppConfig{..} <- AppState.getConfig appState
56-
result <- AppState.usePool appState (SQL.transaction SQL.ReadCommitted SQL.Read $ querySchemaCache conf)
56+
result <- AppState.usePool appState (SQL.transactionNoRetry SQL.ReadCommitted SQL.Read $ querySchemaCache conf)
5757
case result of
5858
Left e -> do
5959
let observer = AppState.getObserver appState

src/PostgREST/Config/Database.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pgVersionStatement = SQL.Statement sql HE.noParams versionRow
9292
-- A setting on the database only will have no effect: ALTER DATABASE postgres SET <prefix>jwt_aud = 'xx'
9393
queryDbSettings :: Maybe Text -> Bool -> Session [(Text, Text)]
9494
queryDbSettings preConfFunc prepared =
95-
SQL.transaction SQL.ReadCommitted SQL.Read $ SQL.statement dbSettingsNames $ SQL.Statement sql (arrayParam HE.text) decodeSettings prepared
95+
SQL.transactionNoRetry SQL.ReadCommitted SQL.Read $ SQL.statement dbSettingsNames $ SQL.Statement sql (arrayParam HE.text) decodeSettings prepared
9696
where
9797
sql = encodeUtf8 [trimming|
9898
WITH
@@ -132,7 +132,7 @@ queryDbSettings preConfFunc prepared =
132132

133133
queryRoleSettings :: PgVersion -> Bool -> Session (RoleSettings, RoleIsolationLvl)
134134
queryRoleSettings pgVer prepared =
135-
SQL.transaction SQL.ReadCommitted SQL.Read $ SQL.statement mempty $ SQL.Statement sql HE.noParams (processRows <$> rows) prepared
135+
SQL.transactionNoRetry SQL.ReadCommitted SQL.Read $ SQL.statement mempty $ SQL.Statement sql HE.noParams (processRows <$> rows) prepared
136136
where
137137
sql = encodeUtf8 [trimming|
138138
with

src/PostgREST/Query.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ data QueryResult
7676
query :: AppConfig -> AuthResult -> ApiRequest -> ActionPlan -> SchemaCache -> Query
7777
query _ _ _ (NoDb x) _ = NoDbQuery $ NoDbResult x
7878
query config AuthResult{..} apiReq (Db plan) sCache =
79-
DbQuery isoLvl txMode dbHandler SQL.transaction mainSQLQuery
79+
DbQuery isoLvl txMode dbHandler SQL.transactionNoRetry mainSQLQuery
8080
where
8181
isoLvl = planIsoLvl config authRole plan
8282
txMode = planTxMode plan

0 commit comments

Comments
 (0)