@@ -66,16 +66,18 @@ public void reconcileStock() {
6666 for (String lessonIdStr : lessonIds ) {
6767 try {
6868 Long lessonId = Long .valueOf (lessonIdStr );
69+ String waitingRoomKey = String .format (LessonApplyStreamConstant .WAITING_ROOM_KEY , lessonId );
70+ String stockKey = LessonApplyStreamConstant .STOCK_PREFIX + lessonId ;
6971
7072 // 해당 레슨이 현재 배치 처리 중인지 확인
7173 String busyKey = "lesson:busy:" + lessonId ;
7274 String lastActiveKey = "lesson:busy:last_active:" + lessonId ;
7375 String busyCountStr = coreRedisTemplate .opsForValue ().get (busyKey );
76+ String lastActiveStr = coreRedisTemplate .opsForValue ().get (lastActiveKey );
7477
7578 // 보정 로직 미실행 조건 체크
7679 if (busyCountStr != null ) {
7780 // 마지막 활동 시간 로드
78- String lastActiveStr = coreRedisTemplate .opsForValue ().get (lastActiveKey );
7981 long now = System .currentTimeMillis ();
8082 int busyCount = Integer .parseInt (busyCountStr );
8183
@@ -122,6 +124,14 @@ public void reconcileStock() {
122124 if (currentStock < 0 )
123125 currentStock = 0 ;
124126
127+ Long waitingRoomSize = coreRedisTemplate .opsForZSet ().size (waitingRoomKey );
128+ String redisStockBefore = coreRedisTemplate .opsForValue ().get (stockKey );
129+ Long streamSize = mqRedisTemplate .opsForStream ().size (LessonApplyStreamConstant .STREAM_KEY );
130+ log .info (
131+ "Reconciliation diagnostics. lessonId={}, dbCount={}, maxParticipants={}, calculatedStock={}, redisStockBefore={}, waitingRoomSize={}, streamSize={}, busyCount={}, lastActive={}" ,
132+ lessonId , actualParticipantCount , lesson .getMaxParticipants (), currentStock , redisStockBefore ,
133+ waitingRoomSize , streamSize , busyCountStr , lastActiveStr );
134+
125135 // Redis 재고 동기화 (Core Redis)
126136 lessonApplyProducer .setStock (lessonId , currentStock );
127137
0 commit comments