Skip to content

Comments

UID/GID 할당 로직 리팩토링#179

Open
uugaemi wants to merge 3 commits intodevelopfrom
feature/#176-id-allocation
Open

UID/GID 할당 로직 리팩토링#179
uugaemi wants to merge 3 commits intodevelopfrom
feature/#176-id-allocation

Conversation

@uugaemi
Copy link
Contributor

@uugaemi uugaemi commented Feb 22, 2026

🌱 관련 이슈

🌱 작업 사항

  1. IdCounter 테이블 도입 및 비관적 락 적용
  • IdCounter 엔티티 및 CounterKey enum 신규 생성
    • CounterKey.UID / CounterKey.SHARED_GID 두 가지 카운터 키 관리
    • allocateOne() 메서드에서 범위(min~max) 검증 후 순차 할당
  • IdCounterRepository에 @lock(LockModeType.PESSIMISTIC_WRITE) 적용하여 동시 요청 시 중복 할당 방지
  1. IdAllocationService 리팩터링
  • 기존 findMaxIdValue() + retry 루프 방식을 IdCounter + 비관적 락 방식으로 전체 교체
    • UID 할당: IdCounter(UID) 카운터로 순차 발급
    • GID 할당: IdCounter(SHARED_GID) 카운터로 순차 발급
  • createGroupWithSameId() → createPrimaryGroup()으로 단순화 (중복 조회 로직 제거)
  1. Config API 요청 경로 수정
  • 그룹 생성 외부 API 호출: POST /accounts/addgroup → PUT /accounts/groups
  1. 테스트 코드 작성
  • IdCounterTest: allocateOne() 경계값 및 예외 케이스 단위 테스트
  • IdAllocationServiceTest: allocateFor, allocateNewGid, releaseId Mockito 기반 단위 테스트
  • RequestGroupTest: builder 초기화 및 @PrePersist 동작 검증

🌱 참고 사항

  • IdCounter 초기 데이터 삽입 필요: id_counter 테이블에 UID, SHARED_GID 레코드가 없으면 할당 시 예외가 발생하므로, 배포 전 초기 데이터를 반드시 삽입해야 함.

@uugaemi uugaemi changed the title Feature/#176 id allocation UID/GID 할당 로직 리팩토링 Feb 22, 2026
@uugaemi uugaemi requested a review from dongmin0204 February 22, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ refactor ] UID/GID 할당 로직 리팩토링

1 participant