fix(contribution): avoid nested transaction timeout in BonusClaimService
Use unitOfWork.isInTransaction() to detect if already in a transaction context (called from ContributionCalculationService). If so, reuse the existing transaction instead of opening a new one, preventing Prisma interactive transaction timeout errors. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
7588d18fff
commit
0bbb52284c
|
|
@ -769,7 +769,8 @@
|
|||
"Bash(git rm:*)",
|
||||
"Bash(echo \"请在服务器运行以下命令检查 outbox 事件:\n\ndocker exec -it rwa-postgres psql -U rwa_user -d rwa_contribution -c \"\"\nSELECT id, event_type, aggregate_id, \n payload->>''sourceType'' as source_type,\n payload->>''accountSequence'' as account_seq,\n payload->>''sourceAccountSequence'' as source_account_seq,\n payload->>''bonusTier'' as bonus_tier\nFROM outbox_events \nWHERE payload->>''accountSequence'' = ''D25122900007''\nORDER BY id;\n\"\"\")",
|
||||
"Bash(ssh -o ConnectTimeout=10 ceshi@14.215.128.96 'find /home/ceshi/rwadurian/frontend/mining-admin-web -name \"\"*.tsx\"\" -o -name \"\"*.ts\"\" | xargs grep -l \"\"用户管理\\\\|users\"\" 2>/dev/null | head -10')",
|
||||
"Bash(dir /s /b \"c:\\\\Users\\\\dong\\\\Desktop\\\\rwadurian\")"
|
||||
"Bash(dir /s /b \"c:\\\\Users\\\\dong\\\\Desktop\\\\rwadurian\")",
|
||||
"Bash(dir /b \"c:\\\\Users\\\\dong\\\\Desktop\\\\rwadurian\\\\backend\\\\services\")"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
|
|
|||
|
|
@ -60,13 +60,21 @@ export class BonusClaimService {
|
|||
`(directReferralAdoptedCount: ${previousCount} -> ${newCount})`,
|
||||
);
|
||||
|
||||
// 在事务中处理补发
|
||||
// 检查是否已在事务中(被 ContributionCalculationService 调用时)
|
||||
// 如果已在事务中,直接执行,避免嵌套事务导致超时
|
||||
if (this.unitOfWork.isInTransaction()) {
|
||||
for (const tier of tiersToClaimList) {
|
||||
await this.claimBonusTier(accountSequence, tier);
|
||||
}
|
||||
} else {
|
||||
// 独立调用时,开启新事务
|
||||
await this.unitOfWork.executeInTransaction(async () => {
|
||||
for (const tier of tiersToClaimList) {
|
||||
await this.claimBonusTier(accountSequence, tier);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 补发指定档位的奖励
|
||||
|
|
|
|||
Loading…
Reference in New Issue