Skip to content

fix: Redis room key namespace 분리로 WRONGTYPE 오류 해결#107

Merged
jung-min-ju merged 1 commit intodevelopfrom
fix/redis-room-scan
Nov 16, 2025
Merged

fix: Redis room key namespace 분리로 WRONGTYPE 오류 해결#107
jung-min-ju merged 1 commit intodevelopfrom
fix/redis-room-scan

Conversation

@jung-min-ju
Copy link
Contributor

@jung-min-ju jung-min-ju commented Nov 15, 2025

Redis room key namespace 분리로 WRONGTYPE 오류 해결

📝 개요

현재 /api/v1/room get 매핑 시, 서버 에러 500이 발생됨.


⚙️ 구현 내용

Redis 키 네임스페이스 충돌 문제 해결

  • 기존 방 메타데이터 키: room:{roomId} -> hash 자료구조
  • 방 ID 풀 키: room:ids:available -> set 자료구조

두 키가 모두 room:* 패턴에 포함되어 SCAN 후 HGETALL 수행 시 Set 타입에서 WRONGTYPE 발생
set 타입은 HGETALL 이 아닌 SMEMBERS 명령어로 조회해야 하기에, 레디스 내에서 명령어 불일치 에러가 발생되었음!

<해당 조회 코드>

    public Cursor<String> scanRoomKeys() {
        ScanOptions options = ScanOptions.scanOptions().match("room:*").count(1000).build();
        return redisTemplate.scan(options);
    }

방 메타데이터 키를 아래와 같이 변경

  • room:data:{roomId}
  • 기존 room:ids:available는 유지

🧪 테스트 결과

image

@jung-min-ju jung-min-ju requested review from Uralauah and brothergiven and removed request for Uralauah November 15, 2025 09:30
Copy link
Contributor

@Uralauah Uralauah left a comment

Choose a reason for hiding this comment

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

확인했습니다

@jung-min-ju jung-min-ju merged commit 9630f5f into develop Nov 16, 2025
1 check passed
@jung-min-ju jung-min-ju deleted the fix/redis-room-scan branch November 16, 2025 10:19
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.

3 participants