mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 08:54:05 +00:00
Handle restarts during historical processing in watcher (#455)
* Reset to latest processed block on restarting job-runner * Update sync status during historical processing in job-runner * Codegen changes * Use sync status latest processed block for subgraph _meta GQL query * Set job per interval for subscribing events queue to 1 * Fix events processing skipped for blocks after template create
This commit is contained in:
@@ -27,6 +27,17 @@ columns:
|
||||
pgType: integer
|
||||
tsType: number
|
||||
columnType: Column
|
||||
- name: latestProcessedBlockHash
|
||||
pgType: varchar
|
||||
tsType: string
|
||||
columnType: Column
|
||||
columnOptions:
|
||||
- option: length
|
||||
value: 66
|
||||
- name: latestProcessedBlockNumber
|
||||
pgType: integer
|
||||
tsType: number
|
||||
columnType: Column
|
||||
- name: latestCanonicalBlockHash
|
||||
pgType: varchar
|
||||
tsType: string
|
||||
|
||||
@@ -460,16 +460,28 @@ export class Schema {
|
||||
}
|
||||
|
||||
_addMeta (): void {
|
||||
const typeComposer = this._composer.createObjectTC({
|
||||
// Create the Block type.
|
||||
const metaBlocktypeComposer = this._composer.createObjectTC({
|
||||
name: '_MetaBlock_',
|
||||
fields: {
|
||||
hash: 'Bytes',
|
||||
number: 'Int!',
|
||||
timestamp: 'Int'
|
||||
}
|
||||
});
|
||||
|
||||
this._composer.addSchemaMustHaveType(metaBlocktypeComposer);
|
||||
|
||||
const metaTypeComposer = this._composer.createObjectTC({
|
||||
name: '_Meta_',
|
||||
fields: {
|
||||
block: this._composer.getOTC('_Block_').NonNull,
|
||||
block: metaBlocktypeComposer.NonNull,
|
||||
deployment: { type: new GraphQLNonNull(GraphQLString) },
|
||||
hasIndexingErrors: { type: new GraphQLNonNull(GraphQLBoolean) }
|
||||
}
|
||||
});
|
||||
|
||||
this._composer.addSchemaMustHaveType(typeComposer);
|
||||
this._composer.addSchemaMustHaveType(metaTypeComposer);
|
||||
|
||||
this._composer.Query.addFields({
|
||||
_meta: {
|
||||
|
||||
@@ -253,13 +253,13 @@ export class Database implements DatabaseInterface {
|
||||
return this._baseDatabase.updateSyncStatusChainHead(repo, blockHash, blockNumber, force);
|
||||
}
|
||||
|
||||
async forceUpdateSyncStatus (queryRunner: QueryRunner, blockHash: string, blockNumber: number): Promise<SyncStatus> {
|
||||
async updateSyncStatusProcessedBlock (queryRunner: QueryRunner, blockHash: string, blockNumber: number, force = false): Promise<SyncStatus> {
|
||||
const repo = queryRunner.manager.getRepository(SyncStatus);
|
||||
|
||||
return this._baseDatabase.forceUpdateSyncStatus(repo, blockHash, blockNumber);
|
||||
return this._baseDatabase.updateSyncStatusProcessedBlock(repo, blockHash, blockNumber, force);
|
||||
}
|
||||
|
||||
async updateSyncStatusIndexingError (queryRunner: QueryRunner, hasIndexingError: boolean): Promise<SyncStatus> {
|
||||
async updateSyncStatusIndexingError (queryRunner: QueryRunner, hasIndexingError: boolean): Promise<SyncStatus | undefined> {
|
||||
const repo = queryRunner.manager.getRepository(SyncStatus);
|
||||
|
||||
return this._baseDatabase.updateSyncStatusIndexingError(repo, hasIndexingError);
|
||||
|
||||
@@ -661,11 +661,11 @@ export class Indexer implements IndexerInterface {
|
||||
return syncStatus;
|
||||
}
|
||||
|
||||
async forceUpdateSyncStatus (blockHash: string, blockNumber: number): Promise<SyncStatus> {
|
||||
return this._baseIndexer.forceUpdateSyncStatus(blockHash, blockNumber);
|
||||
async updateSyncStatusProcessedBlock (blockHash: string, blockNumber: number, force = false): Promise<SyncStatus> {
|
||||
return this._baseIndexer.updateSyncStatusProcessedBlock(blockHash, blockNumber, force);
|
||||
}
|
||||
|
||||
async updateSyncStatusIndexingError (hasIndexingError: boolean): Promise<SyncStatus> {
|
||||
async updateSyncStatusIndexingError (hasIndexingError: boolean): Promise<SyncStatus | undefined> {
|
||||
return this._baseIndexer.updateSyncStatusIndexingError(hasIndexingError);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user