Skip to content

Commit

Permalink
fix: 경쟁조건 해결 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
rladydgn committed Dec 7, 2023
1 parent 8e9f0dc commit a0cd75e
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,13 @@ export class CompetitionService {
await queryRunner.startTransaction();

try {
submission = await queryRunner.manager
.getRepository(Submission)
.createQueryBuilder('submission')
.useTransaction(true)
.setLock('pessimistic_write')
.where('id = :id', { id: scoreResultDto.submissionId })
.getOne();
submission = await queryRunner.manager.findOneBy(Submission, {
id: scoreResultDto.submissionId,
});
Expand All @@ -327,6 +334,7 @@ export class CompetitionService {
await queryRunner.commitTransaction();
await queryRunner.release();
} catch (error) {
this.logger.debug(`트랜잭션 실패 ${error.message}`);
await queryRunner.rollbackTransaction();
await queryRunner.release();
throw error;
Expand Down

0 comments on commit a0cd75e

Please sign in to comment.