From 89464c270632d0a550435a17d88bb8e429fbc240 Mon Sep 17 00:00:00 2001 From: brothergiven Date: Wed, 26 Nov 2025 21:04:49 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=EC=B6=94=EC=B8=A1=20=EC=A2=85?= =?UTF-8?q?=EB=A3=8C=20=EC=8B=9C=EA=B0=84=201=EB=B6=84=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../socket_server/domain/game/service/GuessRequestService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessRequestService.java b/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessRequestService.java index 21b94a34..33cfa142 100644 --- a/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessRequestService.java +++ b/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessRequestService.java @@ -77,7 +77,7 @@ public void requestGuessPlayer(String roomId, GameMeta gameMeta, Word word) { // 3. BUILD NEW GUESS DATA Guess guess = Guess.builder().guesserUuid(gusser.getPlayerUuid()).attempts(guesses.size()+1).build(); - guess.setGuessEndTime(LocalDateTime.now().plusSeconds(32)); + guess.setGuessEndTime(LocalDateTime.now().plusSeconds(62)); // 4. BroadCast gameBroadCaster.broadcastGameEvent("SYSTEM", roomId, GameEventType.GUESS_REQUEST, guess, aiSays); From e6b78976a8de222a9ffc0bad09a4172d54305ede Mon Sep 17 00:00:00 2001 From: brothergiven Date: Wed, 26 Nov 2025 21:05:03 +0900 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=EC=B6=94=EC=B8=A1=20request=20?= =?UTF-8?q?=EC=8B=9C=20=EB=8C=80=EA=B8=B0=EC=8B=9C=EA=B0=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../socket_server/domain/game/service/GuessFlowService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessFlowService.java b/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessFlowService.java index 5c5e20ed..b1c25e63 100644 --- a/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessFlowService.java +++ b/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessFlowService.java @@ -391,7 +391,7 @@ private void handleGuessResult(String roomId, Round currentRound, Word currentWo if(isWordGuessCompleted(currentWord)){ taskScheduler.schedule(() ->handleBattleEnd(roomId, currentRound, currentWord), Instant.now().plusSeconds(1)); } else { - processNextGuessRequest(roomId); + taskScheduler.schedule(() -> processNextGuessRequest(roomId), Instant.now().plusSeconds(2)); } } From f9fb48660eeb41994a7996f278b7d117662521a3 Mon Sep 17 00:00:00 2001 From: brothergiven Date: Wed, 26 Nov 2025 21:13:29 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20Lock=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=84=EB=A9=B4=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../game/repository/GameRepository.java | 63 ++-- .../game/repository/RoundRepository.java | 303 +++++++++--------- 2 files changed, 184 insertions(+), 182 deletions(-) diff --git a/gotcha-socket/src/main/java/socket_server/domain/game/repository/GameRepository.java b/gotcha-socket/src/main/java/socket_server/domain/game/repository/GameRepository.java index 3b36ae5b..4486ec9b 100644 --- a/gotcha-socket/src/main/java/socket_server/domain/game/repository/GameRepository.java +++ b/gotcha-socket/src/main/java/socket_server/domain/game/repository/GameRepository.java @@ -20,6 +20,7 @@ public class GameRepository { private final RedisTemplate redisTemplate; + //todo: Lock 관련 코드 전면 수정 private final RedissonClient redissonClient; public GameRepository(@Qualifier("socketStringRedisTemplate") RedisTemplate redisTemplate, RedissonClient redissonClient) { @@ -39,11 +40,11 @@ public static String getGameKey(String roomId) { */ public void saveGameMeta(GameMeta gameMeta) { String redisKey = getGameKey(gameMeta.getRoomId()); // Redis 해시 키 - String lockKey = "lock:" + redisKey; // 락 키 - - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; // 락 키 +// +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 Map gameData = Map.of( "gameType", gameMeta.getGameType().name(), "difficulty", gameMeta.getDifficulty().name(), @@ -55,17 +56,17 @@ public void saveGameMeta(GameMeta gameMeta) { "playerWon", String.valueOf(gameMeta.getPlayerWon()) ); redisTemplate.opsForHash().putAll(getGameKey(gameMeta.getRoomId()), gameData); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } /** @@ -73,22 +74,22 @@ public void saveGameMeta(GameMeta gameMeta) { */ public Map findGameMeta(String roomId) { String redisKey = getGameKey(roomId); - String lockKey = "lock:" + redisKey; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 return redisTemplate.opsForHash().entries(redisKey); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } public void deleteGameMeta(String roomId){ diff --git a/gotcha-socket/src/main/java/socket_server/domain/game/repository/RoundRepository.java b/gotcha-socket/src/main/java/socket_server/domain/game/repository/RoundRepository.java index 146617fd..5c7a49da 100644 --- a/gotcha-socket/src/main/java/socket_server/domain/game/repository/RoundRepository.java +++ b/gotcha-socket/src/main/java/socket_server/domain/game/repository/RoundRepository.java @@ -17,6 +17,7 @@ @Repository public class RoundRepository { private final RedisTemplate redisTemplate; + //todo: Lock 관련 코드 전면 수정 private final RedissonClient redissonClient; public RoundRepository(@Qualifier("socketStringRedisTemplate") RedisTemplate redisTemplate, RedissonClient redissonClient) { @@ -36,23 +37,23 @@ public static String getGameRoundsKey(String roomId) { */ public void saveRoundMetasString(String roomId, String roundsJson) { String redisKey = getGameRoundsKey(roomId); - String lockKey = "lock:" + redisKey; - - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 redisTemplate.opsForValue().set(redisKey, roundsJson); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } /** @@ -60,22 +61,22 @@ public void saveRoundMetasString(String roomId, String roundsJson) { */ public String findRoundMetasString(String roomId) { String key = getGameRoundsKey(roomId); - String lockKey = "lock:" + key; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + key; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 return redisTemplate.opsForValue().get(key); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } @@ -96,22 +97,22 @@ private String getRoundWordsKey(String roomId, int roundIndex) { */ public void saveWordMetasString(String roomId, int roundIndex, String wordsJson) { String redisKey = getRoundWordsKey(roomId, roundIndex); - String lockKey = "lock:" + redisKey; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 redisTemplate.opsForValue().set(redisKey, wordsJson); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } /** @@ -119,22 +120,22 @@ public void saveWordMetasString(String roomId, int roundIndex, String wordsJson) */ public String findWordMetasString(String roomId, int roundIndex) { String redisKey = getRoundWordsKey(roomId, roundIndex); - String lockKey = "lock:" + redisKey; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 return redisTemplate.opsForValue().get(redisKey); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } public void deleteWordMetas(String roomId, int roundIndex) { @@ -152,22 +153,22 @@ private String getAIPredicionsKey(String roomId, int roundIndex, int wordIndex) */ public void saveAIPredictionsString(String roomId, int roundIndex, int wordIndex, String predictionsJson){ String redisKey = getAIPredicionsKey(roomId, roundIndex, wordIndex); - String lockKey = "lock:" + redisKey; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 redisTemplate.opsForValue().set(redisKey, predictionsJson); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } /** @@ -175,22 +176,22 @@ public void saveAIPredictionsString(String roomId, int roundIndex, int wordIndex */ public String findAIPredictionsString(String roomId, int roundIndex, int wordIndex) { String redisKey = getAIPredicionsKey(roomId, roundIndex, wordIndex); - String lockKey = "lock:" + redisKey; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 return redisTemplate.opsForValue().get(redisKey); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } public void deleteAIPredictions(String roomId, int roundIndex, int wordIndex) { @@ -209,22 +210,22 @@ private String getAIGuessKey(String roomId, int roundIndex, int wordIndex){ */ public void saveAIGuessesString(String roomId, int roundIndex, int wordIndex, String guessesJson){ String redisKey = getAIGuessKey(roomId, roundIndex, wordIndex); - String lockKey = "lock:" + redisKey; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 redisTemplate.opsForValue().set(redisKey, guessesJson); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } /** @@ -232,22 +233,22 @@ public void saveAIGuessesString(String roomId, int roundIndex, int wordIndex, St */ public String findAIGuessesString(String roomId, int roundIndex, int wordIndex) { String redisKey = getAIGuessKey(roomId, roundIndex, wordIndex); - String lockKey = "lock:" + redisKey; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 return redisTemplate.opsForValue().get(redisKey); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } public void deleteAIGuesses(String roomId, int roundIndex, int wordIndex) { @@ -267,22 +268,22 @@ private String getPlayerGuessKey(String roomId, int roundIndex, int wordIndex){ */ public String findPlayerGuessesString(String roomId, int roundIndex, int wordIndex) { String redisKey = getPlayerGuessKey(roomId, roundIndex, wordIndex); - String lockKey = "lock:" + redisKey; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 return redisTemplate.opsForValue().get(redisKey); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } /** @@ -290,22 +291,22 @@ public String findPlayerGuessesString(String roomId, int roundIndex, int wordInd */ public void savePlayerGuesses(String roomId, int roundIndex, int wordIndex, String guessesJson){ String redisKey = getPlayerGuessKey(roomId, roundIndex, wordIndex); - String lockKey = "lock:" + redisKey; - RLock lock = redissonClient.getLock(lockKey); - try { - if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 +// String lockKey = "lock:" + redisKey; +// RLock lock = redissonClient.getLock(lockKey); +// try { +// if (lock.tryLock(1, 5, TimeUnit.SECONDS)) { // 1초 기다리고, 5초 동안 유지 redisTemplate.opsForValue().set(redisKey, guessesJson); - } else { - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); // - throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); - } finally { - if (lock.isHeldByCurrentThread()) { - lock.unlock(); - } - } +// } else { +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_ACQUISITION_FAILED); +// } +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); // +// throw new SocketCustomException(ErrorType.GAME, GameExceptionCode.LOCK_INTERRUPTED); +// } finally { +// if (lock.isHeldByCurrentThread()) { +// lock.unlock(); +// } +// } } public void deletePlayerGuesses(String roomId, int roundIndex, int wordIndex) { From 36b129afa1ca20f8782625c625bc810677a1d9f2 Mon Sep 17 00:00:00 2001 From: brothergiven Date: Wed, 26 Nov 2025 21:19:08 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=EC=B6=94=EC=B8=A1=20request?= =?UTF-8?q?=EC=8B=9C=20=EB=8C=80=EA=B8=B0=EC=8B=9C=EA=B0=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../socket_server/domain/game/service/GuessFlowService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessFlowService.java b/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessFlowService.java index b1c25e63..97a3b8e8 100644 --- a/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessFlowService.java +++ b/gotcha-socket/src/main/java/socket_server/domain/game/service/GuessFlowService.java @@ -67,7 +67,7 @@ public void startGuessingPhase(String roomId) { // log.info("[GUESS_START] broadcasted"); gameMeta.setGameStatus(GameStatus.GUESSING_STARTED); gameRepository.saveGameMeta(gameMeta); - taskScheduler.schedule(() ->processNextGuessRequest(roomId), Instant.now().plusSeconds(1)); + taskScheduler.schedule(() ->processNextGuessRequest(roomId), Instant.now().plusSeconds(2)); } @@ -94,6 +94,7 @@ public void processNextGuessRequest(String roomId){ boolean isAITurn = determineNextGuesser(currentWord); if(isAITurn){ // next guess + Guess newGuess = guessRequestService.requestGuessAI(roomId, gameMeta, currentWord); taskScheduler.schedule(() -> handleAIGuessSubmit(roomId, currentRound, currentWord, newGuess) From 81a3616a161412e8b816d72d89cfb2f037224cad Mon Sep 17 00:00:00 2001 From: brothergiven Date: Wed, 26 Nov 2025 21:22:14 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=EA=B7=B8=EB=A6=BC=20=EC=A0=9C?= =?UTF-8?q?=EC=B6=9C=20=EA=B8=B0=ED=95=9C=201=EB=B6=84=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../socket_server/domain/game/service/RoundStartService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gotcha-socket/src/main/java/socket_server/domain/game/service/RoundStartService.java b/gotcha-socket/src/main/java/socket_server/domain/game/service/RoundStartService.java index 98a1efad..86f66ed8 100644 --- a/gotcha-socket/src/main/java/socket_server/domain/game/service/RoundStartService.java +++ b/gotcha-socket/src/main/java/socket_server/domain/game/service/RoundStartService.java @@ -63,7 +63,7 @@ public void startNextRound(String roomId) { new AIRoundStartReq(currentRound, gameMeta.getTotalRounds()) ); - currentRoundMeta.setDrawingEndTime(LocalDateTime.now().plusSeconds(30)); + currentRoundMeta.setDrawingEndTime(LocalDateTime.now().plusSeconds(60)); gameBroadCaster.broadcastGameEvent("SYSTEM", roomId, GameEventType.ROUND_START, currentRoundMeta, aiSays); }