diff --git a/iconservice/icon_service_engine.py b/iconservice/icon_service_engine.py index e2e963088..d26e9f156 100644 --- a/iconservice/icon_service_engine.py +++ b/iconservice/icon_service_engine.py @@ -2063,6 +2063,11 @@ def _recover_rc_db(cls, reader: 'WriteAheadLogReader', rc_data_path: str): rc_version, revision = get_version_and_revision(prev_calc_db) rc_version: int = max(rc_version, 0) prev_calc_db.close() + + # Process compaction before send the RC DB to reward calculator + prev_calc_db_path: str = os.path.join(rc_data_path, RewardCalcStorage.CURRENT_IISS_DB_NAME) + RewardCalcStorage.process_db_compaction(prev_calc_db_path) + calculate_block_height: int = reader.block.height - 1 standby_rc_db_path: str = RewardCalcStorage.rename_current_db_to_standby_db(rc_data_path, calculate_block_height, diff --git a/iconservice/iiss/reward_calc/storage.py b/iconservice/iiss/reward_calc/storage.py index ec67ae7c5..af2bdd004 100644 --- a/iconservice/iiss/reward_calc/storage.py +++ b/iconservice/iiss/reward_calc/storage.py @@ -217,12 +217,25 @@ def replace_db(self, block_height: int) -> 'RewardCalcDBInfo': rc_version, _ = self.get_version_and_revision() rc_version: int = max(rc_version, 0) self._db.close() + # Process compaction before send the RC DB to reward calculator + self.process_db_compaction(os.path.join(self._path, self.CURRENT_IISS_DB_NAME)) standby_db_path: str = self.rename_current_db_to_standby_db(self._path, block_height, rc_version) self._db = self.create_current_db(self._path) return RewardCalcDBInfo(standby_db_path, block_height) + @classmethod + def process_db_compaction(cls, path: str): + """ + There is compatibility issue between C++ levelDB and go levelDB. + To solve it, should make DB being compacted before reading (from RC). + :param path: DB path to compact + :return: + """ + db = KeyValueDatabase.from_path(path) + db.close() + @classmethod def create_current_db(cls, rc_data_path: str) -> 'KeyValueDatabase': current_db_path = os.path.join(rc_data_path, cls.CURRENT_IISS_DB_NAME)