fix: harden result polling and Redis 8.10 operations
Preserve tournament result jobs through lock contention and transient failures, atomically schedule retries before acknowledgement, and publish initial polls after releasing the preparation lock. Fix Redis connection blocking, durability Hash cleanup, duplicate auction request ordering, and scheduled-job promotion. Use native Redis 8.10 stream, lock, counter, and field-expiring cache operations with invalidation fencing. Repair 90 test type errors and add a repeatable API typecheck command. Validation: 704 API tests, 129 web tests, 31 real Redis integration tests, 3 dependency checks, workspace type checks and builds, and changed-file lint.
This commit is contained in:
1 parent
0c4c4239ec
commit
4b8ccf0077
49 files changed
+2214
-371
No files matched your search
@@ -107,7 +107,7 @@ export class TournamentResultService {
|
||||
priority: RiotJobPriority = 'high',
|
||||
): Promise<EnqueueTournamentResultPollResult | null> {
|
||||
const matchIdentifier = this.resolveMatchIdentifier(matchOrId);
|
||||
return this.distributedLockService.runWithLock(
|
||||
const preparedMatchId = await this.distributedLockService.runWithLock(
|
||||
{
|
||||
lockKey: this.tournamentResultPollProcessingLockKey(matchIdentifier),
|
||||
lockExpirationDurationMilliseconds:
|
||||
@@ -115,14 +115,22 @@ export class TournamentResultService {
|
||||
lockAcquireTimeoutMilliseconds: 1_000,
|
||||
lockRetryDelayMilliseconds: 100,
|
||||
},
|
||||
async () => this.scheduleInitialPollWhileLockOwned(matchOrId, priority),
|
||||
async () => this.prepareInitialPollWhileLockOwned(matchOrId),
|
||||
);
|
||||
if (!preparedMatchId) return null;
|
||||
|
||||
// A fast worker must not see the job while its preparation owns the same lock.
|
||||
return this.riotJobQueueService.enqueueTournamentResultPoll({
|
||||
matchId: preparedMatchId,
|
||||
attempt: 1,
|
||||
expandedToAllPuuids: false,
|
||||
priority,
|
||||
});
|
||||
}
|
||||
|
||||
private async scheduleInitialPollWhileLockOwned(
|
||||
private async prepareInitialPollWhileLockOwned(
|
||||
matchOrId: MatchDocument | mongoose.Types.ObjectId,
|
||||
priority: RiotJobPriority,
|
||||
): Promise<EnqueueTournamentResultPollResult | null> {
|
||||
): Promise<string | null> {
|
||||
const match = await this.loadMatch(matchOrId);
|
||||
if (!this.isReadyToPoll(match)) return null;
|
||||
let competition = await this.ensureCompetition(match);
|
||||
@@ -143,12 +151,7 @@ export class TournamentResultService {
|
||||
};
|
||||
await match.save();
|
||||
|
||||
return this.riotJobQueueService.enqueueTournamentResultPoll({
|
||||
matchId: match._id.toString(),
|
||||
attempt: 1,
|
||||
expandedToAllPuuids: false,
|
||||
priority,
|
||||
});
|
||||
return match._id.toString();
|
||||
}
|
||||
|
||||
public async scheduleManualPoll(params: {
|
||||
@@ -260,8 +263,8 @@ export class TournamentResultService {
|
||||
},
|
||||
);
|
||||
if (didProcess) return;
|
||||
this.logger.debug(
|
||||
`Skipped tournament result poll job ${job.jobId}; another worker is processing match ${job.matchId}.`,
|
||||
throw new Error(
|
||||
`Tournament result poll job ${job.jobId} could not acquire the processing lock for match ${job.matchId}.`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user