fix: 지역 캐시 5분 revision 동기화 - #683
Conversation
There was a problem hiding this comment.
노아 코드 리뷰
판정: 수정 필요 (blocking 3건)
- CI
rule-tests가 2개 ArchUnit 규칙 위반으로 실패합니다. - 현재 revision
(count, max(lastModifyAt))은 초 단위 timestamp 충돌 시 변경을 놓칠 수 있어, 해결하려는 24시간 stale-cache 문제가 남습니다. - 로컬에서
RegionCacheRefreshServiceTest2건은 통과했고, Admin 통합 테스트도 CI에서 통과했습니다.
세부 내용은 inline comment를 확인해 주세요.
|
|
||
| @Override | ||
| @Query( | ||
| "select new app.bottlenote.alcohols.dto.response.RegionCacheRevision(count(r), max(r.lastModifyAt)) from region r") |
There was a problem hiding this comment.
🔴 Blocking — revision 충돌 가능
regions.last_modify_at은 현재 스키마에서 fractional precision 없는 timestamp라 초 단위입니다. 따라서 poll이 (N, 12:00:00)을 저장한 직후 같은 초에 다른 지역을 수정하면 (count, max(lastModifyAt))이 그대로여서 캐시를 비우지 못하고 최대 24시간 stale 상태가 남습니다.
지역 변경 트랜잭션마다 원자적으로 증가시키는 전용 revision 값을 두는 방식이 가장 안전합니다. 최소한 동일 timestamp/동일 count에서도 실제 변경을 잡는 회귀 테스트가 필요합니다.
| refresh(); | ||
| } | ||
|
|
||
| @Scheduled(cron = "${schedules.region.cache.refresh.cron:0 */5 * * * *}") |
There was a problem hiding this comment.
🔴 Blocking — rule-tests 실패
@Service의 public 메서드는 @Transactional을 가져야 한다는 ArchUnit 규칙 때문에 initializeRevision()과 refresh()가 실패합니다. DB 조회 경계인 refresh()에는 @Transactional(readOnly = true)를 적용하고, initializeRevision()의 public 메서드 규칙도 프로젝트 방식에 맞게 충족시켜 주세요. 현재 CI rule-tests는 이 위반 2건으로 실패 중입니다.
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public record RegionCacheRevision(long count, LocalDateTime lastModifyAt) {} |
There was a problem hiding this comment.
🔴 Blocking — DTO 네이밍 규칙 위반
dto.response 최상위 타입은 이름이 Response로 끝나거나 Item을 포함해야 해서 ArchUnit이 실패합니다. 예: RegionCacheRevisionResponse로 변경하거나, 외부 응답 DTO가 아니라면 패키지/타입 역할을 재배치해 주세요.
49e645f to
bf12b09
Compare
개요
Product 지역 목록 Caffeine 캐시가 Admin 지역 변경 후 최대 24시간 오래된 값을 반환할 수 있던 문제를 보완합니다.
변경 내용
count,max(lastModifyAt))을 조회합니다.local_cache_alcohol_region_information를 비워 다음 Product 조회가 최신 DB 값을 다시 적재하도록 합니다.lastModifyAt갱신을 검증하는 통합 테스트를 추가했습니다.검증
./gradlew :bottlenote-product-api:test --tests app.bottlenote.alcohols.service.RegionCacheRefreshServiceTest./gradlew :bottlenote-product-api:unit_test미검증/로컬 제약
lastModifyAt검증은 로컬 Docker/Testcontainers 미가용으로 실행하지 못했습니다. 테스트 컴파일은 완료됐으며 CI 환경에서 확인이 필요합니다.