fix: 가오픈 명령과 GAME WALL 시간 경계 회귀 수정
This commit is contained in:
@@ -316,7 +316,13 @@ export const createGatewayReleaseRepository = (prisma: GatewayPrismaClient): Gat
|
||||
where:
|
||||
candidate.status === 'QUEUED'
|
||||
? { id: candidate.id, status: 'QUEUED' }
|
||||
: { id: candidate.id, status: 'RUNNING', leaseUntil: candidate.leaseUntil },
|
||||
: {
|
||||
id: candidate.id,
|
||||
status: 'RUNNING',
|
||||
// 마이크로초 lease를 Date로 왕복한 값과 equality CAS하면
|
||||
// 만료된 행도 선점하지 못한다. 갱신 race는 만료 조건으로 막는다.
|
||||
leaseUntil: candidate.leaseUntil ? { lt: now } : null,
|
||||
},
|
||||
data: {
|
||||
status: 'RUNNING',
|
||||
startedAt: candidate.startedAt ?? now,
|
||||
|
||||
@@ -802,7 +802,13 @@ export const createGatewayProfileRepository = (prisma: GatewayPrismaClient): Gat
|
||||
where:
|
||||
candidate.status === 'QUEUED'
|
||||
? { id: candidate.id, status: 'QUEUED' }
|
||||
: { id: candidate.id, status: 'RUNNING', leaseUntil: candidate.leaseUntil },
|
||||
: {
|
||||
id: candidate.id,
|
||||
status: 'RUNNING',
|
||||
// DB microseconds는 JS Date로 읽을 때 잘린다. timestamp
|
||||
// 동등 비교 대신 갱신되지 않은 만료 lease인지 DB에서 재검사한다.
|
||||
leaseUntil: candidate.leaseUntil ? { lt: now } : null,
|
||||
},
|
||||
data: {
|
||||
status: 'RUNNING',
|
||||
startedAt: candidate.startedAt ?? now,
|
||||
|
||||
@@ -108,7 +108,8 @@ describeDatabase('gateway release operation persistence', () => {
|
||||
|
||||
await connector.prisma.$executeRaw`
|
||||
UPDATE "gateway_release_operation"
|
||||
SET "lease_until" = CURRENT_TIMESTAMP - INTERVAL '1 second'
|
||||
SET "lease_until" = date_trunc('milliseconds', CURRENT_TIMESTAMP)
|
||||
- INTERVAL '1 second' + INTERVAL '123 microseconds'
|
||||
WHERE "id" = ${operation.id}
|
||||
`;
|
||||
await expect(
|
||||
|
||||
@@ -417,7 +417,8 @@ describeDatabase('gateway operation lease and profile serialization', () => {
|
||||
).resolves.toBeNull();
|
||||
await connector.prisma.$executeRaw`
|
||||
UPDATE "gateway_operation"
|
||||
SET "lease_until" = CURRENT_TIMESTAMP - INTERVAL '1 second'
|
||||
SET "lease_until" = date_trunc('milliseconds', CURRENT_TIMESTAMP)
|
||||
- INTERVAL '1 second' + INTERVAL '123 microseconds'
|
||||
WHERE "id" = ${operation.id}
|
||||
`;
|
||||
const reclaimed = await repository.claimNextOperation(new Date(startedAt.getTime() + 1_001), {
|
||||
|
||||
Reference in New Issue
Block a user