fix: ResetRoom 시 BossRoom 레코드 정리
데디서버가 reset-room 호출 시 슬롯만 idle로 변경하고 BossRoom 레코드는 남아있어서 다음 입장 시 unique 제약 위반(Duplicate entry) 발생. ResetRoom에서 해당 sessionName의 BossRoom 레코드도 함께 삭제. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -206,6 +206,12 @@ func (r *Repository) ResetRoomSlot(sessionName string) error {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
// DeleteRoomBySessionName removes BossRoom records for a given session name.
|
||||
// Used during ResetRoom to prevent duplicate session_name conflicts on next entry.
|
||||
func (r *Repository) DeleteRoomBySessionName(sessionName string) error {
|
||||
return r.db.Where("session_name = ?", sessionName).Delete(&BossRoom{}).Error
|
||||
}
|
||||
|
||||
// ResetStaleSlots clears instanceID for slots with stale heartbeats
|
||||
// and resets any active raids on those slots.
|
||||
func (r *Repository) ResetStaleSlots(threshold time.Time) (int64, error) {
|
||||
|
||||
@@ -473,9 +473,13 @@ func (s *Service) CheckStaleSlots() {
|
||||
}
|
||||
}
|
||||
|
||||
// ResetRoom resets a room slot back to idle.
|
||||
// ResetRoom resets a room slot back to idle and cleans up any lingering BossRoom records.
|
||||
// Called by the dedicated server after a raid ends and the runner is recycled.
|
||||
func (s *Service) ResetRoom(sessionName string) error {
|
||||
// 완료/실패되지 않은 BossRoom 레코드 정리 (waiting/in_progress 상태)
|
||||
if err := s.repo.DeleteRoomBySessionName(sessionName); err != nil {
|
||||
log.Printf("BossRoom 레코드 정리 실패: %s: %v", sessionName, err)
|
||||
}
|
||||
return s.repo.ResetRoomSlot(sessionName)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user