Skip to content

Commit

Permalink
HDDS-11713. Use seek to reach the start transaction. (apache#7460)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishkumar50 authored Nov 21, 2024
1 parent d52615a commit d6a5488
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public List<DeletedBlocksTransaction> getFailedTransactions(int count,
}
}
} else {
iter.seek(startTxId);
while (iter.hasNext() && failedTXs.size() < count) {
DeletedBlocksTransaction delTX = iter.next().getValue();
if (delTX.getCount() == -1 && delTX.getTxID() >= startTxId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ public void seekToLast() {
@Override
public TypedTable.KeyValue<Long, DeletedBlocksTransaction> seek(
Long key) throws IOException {
throw new UnsupportedOperationException("seek");
iter.seek(key);
findNext();
return nextTx;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,27 @@ public void testDeletedBlocksTxnSubcommand() throws Exception {
currentValidTxnNum = deletedBlockLog.getNumOfValidTransactions();
LOG.info("Valid num of txns: {}", currentValidTxnNum);
assertEquals(30, currentValidTxnNum);

// Fail first 20 txns be failed
// increment retry count than threshold, count will be set to -1
for (int i = 0; i < maxRetry + 1; i++) {
deletedBlockLog.incrementCount(txIds);
}
flush();

GetFailedDeletedBlocksTxnSubcommand getFailedBlockCommand =
new GetFailedDeletedBlocksTxnSubcommand();
outContent.reset();
cmd = new CommandLine(getFailedBlockCommand);
// set start transaction as 15
cmd.parseArgs("-c", "5", "-s", "15");
getFailedBlockCommand.execute(scmClient);
matchCount = 0;
p = Pattern.compile("\"txID\" : \\d+", Pattern.MULTILINE);
m = p.matcher(outContent.toString(DEFAULT_ENCODING));
while (m.find()) {
matchCount += 1;
}
assertEquals(5, matchCount);
}
}

0 comments on commit d6a5488

Please sign in to comment.