Skip to content

Commit

Permalink
Clear indexing error on job-runner startup
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamesh0 committed Nov 7, 2023
1 parent 5fabf88 commit 55f50ce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/job-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class JobRunnerCmd {
// Delete all active and pending (before completed) jobs to start job-runner without old queued jobs
await jobRunner.jobQueue.deleteAllJobs('completed');
await jobRunner.resetToPrevIndexedBlock();
await indexer.updateSyncStatusIndexingError(false);

await startJobRunner(jobRunner);
jobRunner.handleShutdown();
Expand Down
11 changes: 5 additions & 6 deletions packages/util/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,15 @@ export class Indexer {

if (block.hash) {
resultBlock = await this.getBlockProgress(block.hash);
} else if (block.number) {
// Get all the blocks at the given height
const blocksAtHeight = await this.getBlocksAtHeight(block.number, false);
} else {
const blockHeight = block.number ? block.number : syncStatus.latestIndexedBlockNumber - 1;

// Get all the blocks at a height
const blocksAtHeight = await this.getBlocksAtHeight(blockHeight, false);

if (blocksAtHeight.length) {
resultBlock = blocksAtHeight[0];
}
} else {
resultBlock = await this.getBlockProgress(syncStatus.latestIndexedBlockHash);
assert(resultBlock);
}

return resultBlock
Expand Down
6 changes: 3 additions & 3 deletions packages/util/src/job-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,12 @@ export class JobRunner {
log(`Retrying event processing after ${EVENTS_PROCESSING_RETRY_WAIT} ms`);
await wait(EVENTS_PROCESSING_RETRY_WAIT);

// TODO: Stop next job in queue from processing next
// TODO: Stop job for next block in queue (in historical processing)

const eventsProcessingRetrytJob: EventsJobData = { ...jobData, isRetryAttempt: true };
const eventsProcessingRetryJob: EventsJobData = { ...jobData, isRetryAttempt: true };
await this.jobQueue.pushJob(
QUEUE_EVENT_PROCESSING,
eventsProcessingRetrytJob,
eventsProcessingRetryJob,
{ priority: 1 }
);
}
Expand Down

0 comments on commit 55f50ce

Please sign in to comment.