Skip to content

Commit

Permalink
Use repeatable read for pnl tick generation. (#2578)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentwschau authored and adamfraser committed Nov 20, 2024
1 parent f408f71 commit c51e491
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 c51e491

Please sign in to comment.