1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 15:38:15 +00:00

Catch exception in thread pool when migrate repos (#7320)

* Catch exception in thread pool when migrate repos

* Add comment and use different exit code

* Check exception only

---------

Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
feiniks
2025-01-13 16:58:56 +08:00
committed by GitHub
parent de75571ae6
commit dd3003a693
2 changed files with 21 additions and 8 deletions

View File

@@ -186,7 +186,7 @@ def migrate_repo(repo_id, orig_storage_id, dest_storage_id):
sys.exit(1)
for w in workers:
if w.exit_code == 1:
if w.exception:
logging.warning(w.exception)
api.set_repo_status (repo_id, REPO_STATUS_NORMAL)
sys.exit(1)
@@ -202,6 +202,7 @@ def migrate_repo(repo_id, orig_storage_id, dest_storage_id):
def migrate_repos(orig_storage_id, dest_storage_id):
repo_ids = get_repo_ids(orig_storage_id, dest_storage_id)
pending_repos = {}
for repo_id in repo_ids:
api.set_repo_status (repo_id, REPO_STATUS_READ_ONLY)
dtypes = ['commits', 'fs', 'blocks']
@@ -232,10 +233,14 @@ def migrate_repos(orig_storage_id, dest_storage_id):
sys.exit(1)
for w in workers:
if w.exit_code == 1:
if w.exception:
logging.warning(w.exception)
api.set_repo_status (repo_id, REPO_STATUS_NORMAL)
sys.exit(1)
pending_repos[repo_id] = repo_id
if repo_id in pending_repos:
api.set_repo_status (repo_id, REPO_STATUS_NORMAL)
logging.info('The process of migrating repo [%s] is failed.\n', repo_id)
continue
if api.update_repo_storage_id(repo_id, dest_storage_id) < 0:
logging.warning('Failed to update repo [%s] storage_id.\n', repo_id)
@@ -245,5 +250,10 @@ def migrate_repos(orig_storage_id, dest_storage_id):
api.set_repo_status (repo_id, REPO_STATUS_NORMAL)
logging.info('The process of migrating repo [%s] is over.\n', repo_id)
if len(pending_repos) != 0:
logging.info('The following repos were not migrated successfully and need to be migrated again:\n')
for r in pending_repos:
logging.info('%s\n', r)
if __name__ == '__main__':
main(sys.argv)