Skip to content

Commit

Permalink
tweaking the 2 migration task logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Dec 18, 2023
1 parent 4f2fb89 commit cd93fc2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ prime_backup:
start: 正在将压缩方法迁移至{},见控制台以了解进度
no_confirm: 未做出选择, 压缩方法迁移任务终止
aborted: 压缩方法迁移任务终止
done: '已将压缩方法迁移至{}, 数据对象总储存大小变化: {} -> {} ({})'
done: '已将压缩方法迁移至{}, 数据对象总储存大小: {} -> {} ({})'
db_migrate_hash_method:
name: 哈希算法迁移
hash_method_unchanged: 哈希算法已经是{}了
Expand Down
10 changes: 5 additions & 5 deletions prime_backup/action/migrate_compress_method_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,30 @@ def run(self) -> SizeDiff:
cnt = 0
for blobs in session.iterate_blob_batch(batch_size=1000):
cnt += len(blobs)
self.logger.info('Migrating blobs {} / {}'.format(cnt, total_blob_count))
self.logger.info('Processing blobs {} / {}'.format(cnt, total_blob_count))
self.__migrate_blobs_and_sync_files(session, blobs)
session.flush_and_expunge_all()

if len(self.__migrated_blob_hashes) == 0:
self.logger.info('No blob is changed, no need to migrate')
self.logger.info('No blob needs a compress method change, nothing to migrate')
else:
self.logger.info('Migrated {} blobs and related files'.format(len(self.__migrated_blob_hashes)))

# 3. migrate backup data
self.logger.info('Syncing {} backups'.format(len(self.__affected_backup_ids)))
self.logger.info('Syncing {} affected backups'.format(len(self.__affected_backup_ids)))
self.__update_backups(session)
session.flush_and_expunge_all()

# 4. finalize blob file change
self.logger.info('Finalize blob file change')
self.logger.info('Finalizing blob file change')
self.__finalize_blobs_change()
session.flush_and_expunge_all()

# 5. output
after_size = session.get_blob_stored_size_sum()

self.config.backup.compress_method = self.new_compress_method
self.logger.info('Migration done, cost {}s'.format(round(time.time() - t, 2)))
self.logger.info('Compress method migration done, cost {}s'.format(round(time.time() - t, 2)))
return SizeDiff(before_size, after_size)

finally:
Expand Down
4 changes: 3 additions & 1 deletion prime_backup/action/migrate_hash_method_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def run(self):
self.logger.info('Hash method of the database is already {}, no need to migrate'.format(self.new_hash_method.name))
return

self.logger.info('Migrating hash method from {} to {}'.format(meta.hash_method, self.new_hash_method.name))

total_blob_count = session.get_blob_count()
all_hashes = session.get_all_blob_hashes()
all_hash_set = set(all_hashes)
Expand All @@ -78,7 +80,7 @@ def run(self):
DbAccess.sync_hash_method()
self.config.backup.hash_method = self.new_hash_method.name

self.logger.info('Migration done, cost {}s'.format(round(time.time() - t, 2)))
self.logger.info('Hash method migration done, cost {}s'.format(round(time.time() - t, 2)))

except Exception:
self.logger.warning('Error occurs during migration, applying rollback')
Expand Down

0 comments on commit cd93fc2

Please sign in to comment.