Skip to content

Commit bfe3fef

Browse files
committed
Use RepeatableRead isolation level
1 parent 5638f5c commit bfe3fef

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/Ambar/Emulator/Connector/Postgres.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ connect config@PostgreSQL{..} logger (PostgreSQLState tracker) producer f =
186186
P.withTransactionMode txMode conn $ foldM pollSection acc0 (splitBoundaries bounds)
187187
where
188188
txMode = P.TransactionMode
189-
{ P.isolationLevel = P.ReadCommitted
189+
{ P.isolationLevel = P.RepeatableRead
190190
, P.readWriteMode = P.ReadOnly
191191
}
192192

tests/Test/Connector/PostgreSQL.hs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,20 @@ testPostgreSQL p = do
5757

5858
it "handles large boundary lists" $ do
5959
with (PartitionCount 1) $ \conn table topic connected -> do
60-
void $ P.execute_ conn
61-
(fromString $ "ALTER SEQUENCE " <> tableName table <> "_id_seq INCREMENT BY 2")
62-
let n = 10000
63-
insert conn table (take n $ head $ mocks table)
64-
connected $
65-
deadline (seconds 10) $
66-
Topic.withConsumer topic group $ \consumer -> do
67-
forM_ [1..n] $ \_ -> void $ readEntry @Event consumer
68-
insert conn table [head (mocks table !! 1)]
69-
void $ readEntry @Event consumer
60+
void $ P.execute_ conn $ fromString $
61+
"ALTER SEQUENCE " <> tableName table <> "_id_seq INCREMENT BY 2"
62+
63+
let n = 50000
64+
connected $ Topic.withConsumer topic group $ \consumer -> deadline (seconds 10) $ do
65+
-- pre-fill the table
66+
insert conn table (take n $ head $ mocks table)
67+
-- advance connector.
68+
forM_ [1..n] $ \_ -> readEntry @Event consumer
69+
70+
-- now insert and expect a new entry, which will definitely be retrieved from a query
71+
-- containing lots of gaps.
72+
insert conn table [head (mocks table !! 1)]
73+
void $ readEntry @Event consumer
7074

7175
-- Test that column types are supported/unsupported by
7276
-- creating database entries with the value and reporting

0 commit comments

Comments
 (0)