From 3c63668dd4e78fd6b366dfdc8b4e314e98c275c1 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:48:32 -0500 Subject: [PATCH] Use repeatable read for pnl tick generation. (backport #2578) (#2580) Co-authored-by: vincentwschau <99756290+vincentwschau@users.noreply.github.com> --- indexer/services/roundtable/src/tasks/create-pnl-ticks.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indexer/services/roundtable/src/tasks/create-pnl-ticks.ts b/indexer/services/roundtable/src/tasks/create-pnl-ticks.ts index fde4918a18..7ef1df8154 100644 --- a/indexer/services/roundtable/src/tasks/create-pnl-ticks.ts +++ b/indexer/services/roundtable/src/tasks/create-pnl-ticks.ts @@ -2,6 +2,7 @@ import { logger, stats } from '@dydxprotocol-indexer/base'; import { BlockFromDatabase, BlockTable, + IsolationLevel, PnlTicksCreateObject, PnlTicksTable, Transaction, @@ -50,8 +51,10 @@ export default async function runTask(): Promise { 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();