File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -465,7 +465,16 @@ impl Consensus for PostgresConsensus {
465
465
limit
466
466
) ) ) ;
467
467
} ;
468
- let rows = {
468
+ let rows = if self . postgres_tuned ( ) {
469
+ // In serializable mode, postgres behaves better when read-only mode is explicitly
470
+ // declared, which requires explicitly initializing a transaction.
471
+ let mut client = self . get_connection ( ) . await ?;
472
+ let txn = client. build_transaction ( ) . read_only ( true ) . start ( ) . await ?;
473
+ let statement = txn. prepare_cached ( q) . await ?;
474
+ let result = txn. query ( & statement, & [ & key, & from, & limit] ) . await ?;
475
+ txn. commit ( ) . await ?;
476
+ result
477
+ } else {
469
478
let client = self . get_connection ( ) . await ?;
470
479
let statement = client. prepare_cached ( q) . await ?;
471
480
client. query ( & statement, & [ & key, & from, & limit] ) . await ?
You can’t perform that action at this time.
0 commit comments