Skip to content

Commit 506fa63

Browse files
author
Yehonatan Buchnik
authored
Update pruning metrics when pruning is done after state transfer (#2643)
Problem Overview When pruning is done after state transfer, we use a code path that doesn't update the pruning metrics This PR is for fixing this bug Testing Done CI tests + enabling buck the test_pruning_with_failures_test and update it to also test that the lagged replica updates its metrics
1 parent 64cfb62 commit 506fa63

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

kvbc/src/categorization/kv_blockchain.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -967,9 +967,10 @@ void KeyValueBlockchain::pruneOnSTLink(const RawBlock& block) {
967967
auto key_it = internal_kvs.find(keyTypes::genesis_block_key);
968968
if (key_it != internal_kvs.cend()) {
969969
const auto block_genesis_id = concordUtils::fromBigEndianBuffer<BlockId>(key_it->second.data.data());
970-
while (getGenesisBlockId() >= INITIAL_GENESIS_BLOCK_ID && getGenesisBlockId() < getLastReachableBlockId() &&
971-
block_genesis_id > getGenesisBlockId()) {
972-
deleteGenesisBlock();
970+
if (getGenesisBlockId() >= INITIAL_GENESIS_BLOCK_ID && getGenesisBlockId() < getLastReachableBlockId()) {
971+
for (auto i = getGenesisBlockId(); i < block_genesis_id; i++) {
972+
ConcordAssert(deleteBlock(i));
973+
}
973974
}
974975
}
975976
}

tests/apollo/test_skvbc_reconfiguration.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,6 @@ async def test_pruning_command(self, bft_network):
10611061
log.log_message(message_type=f"pruned_block {pruned_block}")
10621062
assert pruned_block <= 97
10631063

1064-
@unittest.skip("Unstable test - BC-19253")
10651064
@with_trio
10661065
@with_bft_network(start_replica_cmd, selected_configs=lambda n, f, c: n == 7, publish_master_keys=True)
10671066
async def test_pruning_command_with_failures(self, bft_network):
@@ -1121,7 +1120,26 @@ async def test_pruning_command_with_failures(self, bft_network):
11211120
num_replies += 1
11221121
if num_replies == bft_network.config.n:
11231122
break
1123+
# Validate the crashed replica has managed to updates its metrics
1124+
with trio.fail_after(60):
1125+
while True:
1126+
with trio.move_on_after(seconds=.5):
1127+
try:
1128+
key = ['kv_blockchain_deletes', 'Counters', 'numOfVersionedKeysDeleted']
1129+
deletes = await bft_network.metrics.get(crashed_replica, *key)
1130+
1131+
key = ['kv_blockchain_deletes', 'Counters', 'numOfImmutableKeysDeleted']
1132+
deletes += await bft_network.metrics.get(crashed_replica, *key)
11241133

1134+
key = ['kv_blockchain_deletes', 'Counters', 'numOfMerkleKeysDeleted']
1135+
deletes += await bft_network.metrics.get(crashed_replica, *key)
1136+
1137+
except KeyError:
1138+
continue
1139+
else:
1140+
# success!
1141+
if deletes >= 0:
1142+
break
11251143
# Now, crash the same replica again.
11261144
crashed_replica = 3
11271145
bft_network.stop_replica(crashed_replica)

0 commit comments

Comments
 (0)