Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 분산락 타임아웃 상황에서 트랜잭션 롤백 문제 해결 #345

Merged
merged 7 commits into from
Aug 29, 2024

Conversation

chhs2131
Copy link
Collaborator

@chhs2131 chhs2131 commented Aug 29, 2024

📄 Summary

레디슨락의 LeaseTime을 초과하여 중도 반환하였으나, 어플리케이션 로직 진행 중에는 이를 인지하지 못하고 있게 된다.
트랜잭션 Commit 이후 레디슨락을 unlcok하는 시점에서 이를 발견하고 익셉션이 발생하는 경우, 트랜잭션이 롤백되지 않아 데이터 정합성 문제가 발생한다.

문제 그림

image

할일

  • 타이머를 통해 락을 관리한다.
  • TransactionalWithTimer 추가
  • Sleep줘서 테스트 확인해보기
    • 테스트 상황 가정: 분산락 lease time을 초과하는 입찰 로직은 정상적으로 실패하고 롤백된다.
      • 한명의 유저가 입찰 로직을 시작
      • Lock 획득
      • 트랜잭션 시작
      • 입찰 작업이 너무 길어져 Lock lease time을 초과함 (즉, 락을 이 시점에서 잃음)
      • 트랜잭션 타임아웃으로 인해 트랜잭션이 종료됨
      • Lock 반환에 실패하고 예외 발생 (lease time 초과 시점에서 이미 반환됨)


image



🙋🏻 More

close #342

@chhs2131 chhs2131 requested a review from a team August 29, 2024 08:40
@chhs2131 chhs2131 self-assigned this Aug 29, 2024
@chhs2131 chhs2131 added the FEATURE 새로운 기능 또는 변경 label Aug 29, 2024
@chhs2131 chhs2131 changed the title feat: feat: 분산락 타임아웃 상황에서 트랜잭션 롤백 문제 해결 Aug 29, 2024
minseok-oh
minseok-oh previously approved these changes Aug 29, 2024
Copy link
Collaborator

@minseok-oh minseok-oh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 좋아요~!

Copy link
Collaborator

@minseok-oh minseok-oh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@minseok-oh minseok-oh merged commit 5ffb478 into dev Aug 29, 2024
2 checks passed
@chhs2131 chhs2131 deleted the fix/342-lock branch August 31, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FEATURE 새로운 기능 또는 변경
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] 분산락 타임아웃 상황에서 트랜잭션 롤백 문제 해결
2 participants