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
@@ -11,7 +11,10 @@ import type {
|
||||
HistorySeasonDto,
|
||||
RecentMatchView,
|
||||
} from '../match-history/match-history.types';
|
||||
import { CommunityStatsCacheService } from './community-stats-cache.service';
|
||||
import {
|
||||
CommunityStatsCacheKey,
|
||||
CommunityStatsCacheService,
|
||||
} from './community-stats-cache.service';
|
||||
import type {
|
||||
CommunityStatsFilters,
|
||||
InternalMatchCardView,
|
||||
@@ -219,21 +222,25 @@ export class CommunityStatsService {
|
||||
communityId: mongoose.Types.ObjectId;
|
||||
matchId: mongoose.Types.ObjectId;
|
||||
}): Promise<InternalMatchDetailResponse> {
|
||||
const key = `riot:communitystats:matchDetail:v${MATCH_STATS_BUILDER_VERSION}:r${MATCH_DETAIL_RESPONSE_CACHE_VERSION}:${params.communityId.toString()}:${params.matchId.toString()}`;
|
||||
const key = new CommunityStatsCacheKey(
|
||||
params.communityId.toString(),
|
||||
'matchDetail',
|
||||
`v${MATCH_STATS_BUILDER_VERSION}:r${MATCH_DETAIL_RESPONSE_CACHE_VERSION}:${params.matchId.toString()}`,
|
||||
);
|
||||
const cached =
|
||||
await this.cacheService.get<InternalMatchDetailResponse>(key);
|
||||
if (cached && isCompleteMatchDetailResponse(cached)) return cached;
|
||||
|
||||
const inFlight = this.matchDetailInFlight.get(key);
|
||||
const inFlight = this.matchDetailInFlight.get(key.identity);
|
||||
if (inFlight) return inFlight;
|
||||
|
||||
const promise = this.buildMatchDetailResponse(params, key);
|
||||
this.matchDetailInFlight.set(key, promise);
|
||||
this.matchDetailInFlight.set(key.identity, promise);
|
||||
try {
|
||||
return await promise;
|
||||
} finally {
|
||||
if (this.matchDetailInFlight.get(key) === promise) {
|
||||
this.matchDetailInFlight.delete(key);
|
||||
if (this.matchDetailInFlight.get(key.identity) === promise) {
|
||||
this.matchDetailInFlight.delete(key.identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,7 +250,7 @@ export class CommunityStatsService {
|
||||
communityId: mongoose.Types.ObjectId;
|
||||
matchId: mongoose.Types.ObjectId;
|
||||
},
|
||||
key: string,
|
||||
key: CommunityStatsCacheKey,
|
||||
): Promise<InternalMatchDetailResponse> {
|
||||
const dataset = await this.buildBaseDataset(params.communityId, {
|
||||
seasonId: 'all',
|
||||
@@ -346,16 +353,16 @@ export class CommunityStatsService {
|
||||
|
||||
// Auction viewers can all request the same next player's internal history
|
||||
// at once. Coalesce local cache misses so one player change does one DB read.
|
||||
const inFlight = this.userInternalHistoryInFlight.get(key);
|
||||
const inFlight = this.userInternalHistoryInFlight.get(key.identity);
|
||||
if (inFlight) return inFlight;
|
||||
|
||||
const promise = this.buildUserInternalHistoryResponse(params, key);
|
||||
this.userInternalHistoryInFlight.set(key, promise);
|
||||
this.userInternalHistoryInFlight.set(key.identity, promise);
|
||||
try {
|
||||
return await promise;
|
||||
} finally {
|
||||
if (this.userInternalHistoryInFlight.get(key) === promise) {
|
||||
this.userInternalHistoryInFlight.delete(key);
|
||||
if (this.userInternalHistoryInFlight.get(key.identity) === promise) {
|
||||
this.userInternalHistoryInFlight.delete(key.identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -428,7 +435,7 @@ export class CommunityStatsService {
|
||||
userId: mongoose.Types.ObjectId;
|
||||
filters: CommunityStatsFilters;
|
||||
},
|
||||
cacheKey: string,
|
||||
cacheKey: CommunityStatsCacheKey,
|
||||
): Promise<UserInternalHistoryResponse> {
|
||||
const context = await this.resolveContext(
|
||||
params.communityId,
|
||||
@@ -1138,18 +1145,31 @@ export class CommunityStatsService {
|
||||
scope: string,
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
filters: CommunityStatsFilters,
|
||||
): string {
|
||||
return [
|
||||
'riot:communitystats',
|
||||
scope,
|
||||
): CommunityStatsCacheKey {
|
||||
const cacheScope = scope.startsWith('userInternal:')
|
||||
? 'userInternal'
|
||||
: scope;
|
||||
if (
|
||||
cacheScope !== 'matches' &&
|
||||
cacheScope !== 'leaderboard' &&
|
||||
cacheScope !== 'teamInsights' &&
|
||||
cacheScope !== 'userInternal'
|
||||
) {
|
||||
throw new Error(`Unsupported community stats cache scope: ${scope}`);
|
||||
}
|
||||
return new CommunityStatsCacheKey(
|
||||
communityId.toString(),
|
||||
filters.seasonId ?? 'current',
|
||||
filters.from ?? '',
|
||||
filters.to ?? '',
|
||||
filters.championId ?? '',
|
||||
filters.cursor ?? '',
|
||||
filters.limit ?? '',
|
||||
].join(':');
|
||||
cacheScope,
|
||||
JSON.stringify([
|
||||
scope,
|
||||
filters.seasonId ?? 'current',
|
||||
filters.from ?? '',
|
||||
filters.to ?? '',
|
||||
filters.championId ?? '',
|
||||
filters.cursor ?? '',
|
||||
filters.limit ?? '',
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
private clampLimit(
|
||||
|
||||
Reference in new issue
Block a user