Skip to content

Commit d918b87

Browse files
committed
enabling actual parallel backfilling of multiple flow types and fixing misleading log
removing unneeded modules Signed-off-by: Alfredo Gutierrez Grajeda <alfredo@hashgraph.com>
1 parent 26c91ea commit d918b87

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

block-node/backfill/src/main/java/module-info.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@
2020
requires transitive com.swirlds.metrics.api;
2121
requires transitive org.hiero.block.node.spi;
2222
requires transitive org.hiero.block.protobuf.pbj;
23-
requires transitive io.grpc.stub;
24-
requires transitive io.grpc;
25-
requires transitive io.helidon.grpc.core;
26-
requires transitive io.helidon.webclient.grpc;
2723
requires com.hedera.pbj.grpc.client.helidon;
2824
requires org.hiero.block.node.base;
2925
requires io.helidon.common.tls;
3026
requires io.helidon.webclient.api;
27+
requires io.helidon.webclient.grpc;
3128
requires org.antlr.antlr4.runtime;
3229
requires static transitive com.github.spotbugs.annotations;
3330

block-node/backfill/src/main/java/org/hiero/block/node/backfill/BackfillPlugin.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ public void start() {
208208
TRACE,
209209
"Scheduling backfill process to start in {0} milliseconds",
210210
backfillConfiguration.initialDelay());
211-
scheduler = Executors.newSingleThreadScheduledExecutor();
211+
scheduler = Executors.newScheduledThreadPool(
212+
2); // Two threads: one for autonomous backfill, one for on-demand backfill
212213
scheduler.scheduleAtFixedRate(
213214
this::detectGaps,
214215
backfillConfiguration.initialDelay(),
@@ -333,6 +334,11 @@ private void backfillGap(LongRange gap, BackfillType backfillType) throws Interr
333334
// to avoid deadlocks, since blocks that fail verification are not persisted
334335
getLatch(backfillType).set(new CountDownLatch(batchOfBlocks.size()));
335336

337+
if (batchOfBlocks.isEmpty()) {
338+
LOGGER.log(TRACE, "No blocks fetched for gap {0}, skipping", chunk);
339+
continue; // Skip empty batches
340+
}
341+
336342
// Process each fetched block
337343
for (BlockUnparsed blockUnparsed : batchOfBlocks) {
338344
long blockNumber = extractBlockNumber(blockUnparsed);
@@ -349,21 +355,25 @@ private void backfillGap(LongRange gap, BackfillType backfillType) throws Interr
349355
boolean backfillFinished = getLatch(backfillType).get().await(timeout, TimeUnit.MILLISECONDS);
350356

351357
// Check if the backfill finished successfully
352-
if (!backfillFinished) {
358+
if (backfillFinished) {
359+
// just log a victory message for each chunk
360+
LOGGER.log(TRACE, "Successfully backfilled gap {0}", chunk);
361+
} else {
353362
LOGGER.log(TRACE, "Backfill for gap {0} did not finish in time", chunk);
354363
backfillFetchErrors.increment();
355364
// If it didn't finish, we will retry it later but move on to next chunk
356-
} else {
357-
// just log a victory message for each chunk
358-
LOGGER.log(TRACE, "Successfully backfilled gap {0}", chunk);
359365
}
360366

361367
// Cooldown between batches
362368
Thread.sleep(backfillConfiguration.delayBetweenBatches());
363369
}
364370

365371
LOGGER.log(
366-
TRACE, "Completed backfilling of type {0} gap from {1} to {2}", backfillType, gap.start(), gap.end());
372+
TRACE,
373+
"Completed backfilling task (does not mean success or failure, just completion) of type {0} gap from {1} to {2} ",
374+
backfillType,
375+
gap.start(),
376+
gap.end());
367377
if (backfillType.equals(BackfillType.ON_DEMAND)) {
368378
onDemandBackfillStartBlock.set(-1); // Reset on-demand start block after backfill
369379
}

block-node/backfill/src/main/java/org/hiero/block/node/backfill/client/BlockNodeClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
public class BlockNodeClient {
1616
// Options definition for all gRPC services in the block node client
1717
private record Options(Optional<String> authority, String contentType) implements ServiceInterface.RequestOptions {}
18+
1819
private static final BlockNodeClient.Options OPTIONS =
1920
new BlockNodeClient.Options(Optional.empty(), ServiceInterface.RequestOptions.APPLICATION_GRPC);
2021

0 commit comments

Comments
 (0)