Skip to content

Commit

Permalink
Use repeatable read for pnl tick generation. (backport #2578) (#2580)
Browse files Browse the repository at this point in the history
Co-authored-by: vincentwschau <[email protected]>
  • Loading branch information
mergify[bot] and vincentwschau authored Nov 18, 2024
1 parent 4da78f7 commit 3c63668
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion indexer/services/roundtable/src/tasks/create-pnl-ticks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { logger, stats } from '@dydxprotocol-indexer/base';
import {
BlockFromDatabase,
BlockTable,
IsolationLevel,
PnlTicksCreateObject,
PnlTicksTable,
Transaction,
Expand Down Expand Up @@ -50,8 +51,10 @@ export default async function runTask(): Promise<void> {
return;
}

// Start a transaction to ensure different table reads are consistent.
// Start a transaction to ensure different table reads are consistent. Use a repeatable read
// to ensure all reads within the transaction are consistent.
const txId: number = await Transaction.start();
await Transaction.setIsolationLevel(txId, IsolationLevel.REPEATABLE_READ);
let newTicksToCreate: PnlTicksCreateObject[] = [];
try {
await perpetualMarketRefresher.updatePerpetualMarkets();
Expand Down

0 comments on commit 3c63668

Please sign in to comment.