diff --git a/packages/node-core/CHANGELOG.md b/packages/node-core/CHANGELOG.md index c6ecb5176b..1c1dcc234c 100644 --- a/packages/node-core/CHANGELOG.md +++ b/packages/node-core/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] + +### Fixed +- Fix getCache could not been cleared after reindex, and could have been re-used and lead to error, such as syncPoi + ## [6.0.2] - 2023-10-12 ### Fixed - Issues with using object destructing for store interface and workers (#2094) diff --git a/packages/node-core/src/indexer/poi/poiSync.service.ts b/packages/node-core/src/indexer/poi/poiSync.service.ts index 900078484f..c9101d9122 100644 --- a/packages/node-core/src/indexer/poi/poiSync.service.ts +++ b/packages/node-core/src/indexer/poi/poiSync.service.ts @@ -113,6 +113,8 @@ export class PoiSyncService implements OnApplicationShutdown { async syncPoi(exitHeight?: number): Promise { if (this.isSyncing) return; this.isSyncing = true; + // Enable this after rewind + this.isShutdown = false; try { while (!this.isShutdown) { if (!this._latestSyncedPoi) { diff --git a/packages/node-core/src/indexer/storeCache/cacheMetadata.ts b/packages/node-core/src/indexer/storeCache/cacheMetadata.ts index cace3202bf..3a7adc67a7 100644 --- a/packages/node-core/src/indexer/storeCache/cacheMetadata.ts +++ b/packages/node-core/src/indexer/storeCache/cacheMetadata.ts @@ -140,5 +140,6 @@ export class CacheMetadataModel extends Cacheable implements ICachedModelControl this.flushableRecordCounter = 1; } this.setCache = newSetCache; + this.getCache = newSetCache; } } diff --git a/packages/node-core/src/indexer/storeCache/cacheModel.ts b/packages/node-core/src/indexer/storeCache/cacheModel.ts index 961907201d..8932b6551e 100644 --- a/packages/node-core/src/indexer/storeCache/cacheModel.ts +++ b/packages/node-core/src/indexer/storeCache/cacheModel.ts @@ -414,6 +414,8 @@ export class CachedModel< clear(blockHeight?: number): void { if (!blockHeight) { this.setCache = {}; + // avoid fetch old data after rewind/reindex + this.getCache = new GetData(getCacheOptions); this.removeCache = {}; this.flushableRecordCounter = 0; return;