@@ -124,16 +124,18 @@ public void close() {
124124 Misc .free (mvStateWriter );
125125 }
126126
127- private static long calculateSkipTransactionCount (long seqTxn , WalTxnDetails walTxnDetails ) {
127+ private static long calculateSkipTransactionCount (long initialSeqTxn , WalTxnDetails walTxnDetails ) {
128128 // Check all future transactions to see if any fully replace this transaction's range or table is truncated
129- final long initialSeqTxn = seqTxn ;
130129 final long lastSeqTxn = walTxnDetails .getLastSeqTxn ();
131130
132- boolean keepSkipping = true ;
133- seqTxn --;
131+ // Initial loop condition, as if the previous transaction was skipped
132+ long seqTxn = initialSeqTxn - 1 ;
133+ boolean seqTxnCanBeSkipped = true ;
134134
135- while (keepSkipping && seqTxn < lastSeqTxn ) {
135+ while (seqTxnCanBeSkipped && seqTxn < lastSeqTxn ) {
136136 seqTxn ++;
137+ seqTxnCanBeSkipped = false ;
138+
137139 int walId = walTxnDetails .getWalId (seqTxn );
138140 if (walId < 1 || !isDataType (walTxnDetails .getWalTxnType (seqTxn ))) {
139141 // This is not a data transaction
@@ -147,7 +149,6 @@ private static long calculateSkipTransactionCount(long seqTxn, WalTxnDetails wal
147149 txnTsHi = walTxnDetails .getReplaceRangeTsHi (seqTxn );
148150 }
149151
150- keepSkipping = false ;
151152 long firstNonSkippableTxn = Long .MAX_VALUE ;
152153 for (long futureSeqTxn = seqTxn + 1 ; futureSeqTxn <= lastSeqTxn ; futureSeqTxn ++) {
153154 int futureWalId = walTxnDetails .getWalId (futureSeqTxn );
@@ -156,8 +157,7 @@ private static long calculateSkipTransactionCount(long seqTxn, WalTxnDetails wal
156157 if (walTxnType == TRUNCATE ) {
157158 // Truncate fully removes any prior data, no point doing any data apply
158159 // We can skip straight to the truncate operation or the first non-skippable operation before it
159- seqTxn = Math .min (firstNonSkippableTxn , futureSeqTxn );
160- return seqTxn - initialSeqTxn ;
160+ return Math .min (firstNonSkippableTxn , futureSeqTxn ) - initialSeqTxn ;
161161 }
162162
163163 if (walTxnType == SQL ) {
@@ -184,7 +184,7 @@ private static long calculateSkipTransactionCount(long seqTxn, WalTxnDetails wal
184184 if (futureRangeTsLo <= txnTsLo && futureRangeTsHi >= txnTsHi ) {
185185 // Found that seqTxn is fully replaced by a future transaction
186186 // Skip it and continue checking further transactions
187- keepSkipping = true ;
187+ seqTxnCanBeSkipped = true ;
188188 break ;
189189 }
190190 }
0 commit comments