diff --git a/backend/services/identity-service/src/application/tasks/wallet-retry.task.ts b/backend/services/identity-service/src/application/tasks/wallet-retry.task.ts index 53f42819..efb9d278 100644 --- a/backend/services/identity-service/src/application/tasks/wallet-retry.task.ts +++ b/backend/services/identity-service/src/application/tasks/wallet-retry.task.ts @@ -43,6 +43,9 @@ const MAX_BACKOFF_MINUTES = 60; // 最大退避时间:60分钟 // 每次扫描的最大用户数 const MAX_USERS_PER_SCAN = 100; +// 每次任务最多触发的重试数量(防止 MPC 服务过载) +const MAX_RETRIES_PER_RUN = 10; + export interface KeygenStatusData { status: 'pending' | 'generating' | 'deriving' | 'completed' | 'failed'; userId: string; @@ -112,6 +115,14 @@ export class WalletRetryTask { let skippedCount = 0; for (const userId of incompleteUserIds) { + // 限制每次任务最多触发的重试数量,防止 MPC 服务过载 + if (retriedCount >= MAX_RETRIES_PER_RUN) { + this.logger.log( + `[TASK] Reached max retries per run (${MAX_RETRIES_PER_RUN}), stopping`, + ); + break; + } + try { const retried = await this.checkAndRetryUser(userId.value.toString()); if (retried) {