티스토리 뷰
DB & Redis
Redis Scan 사용시 org.springframework.data.redis.RedisSystemException: Error in execution 에러 해결 방법
Grand_J 2023. 10. 23. 13:41반응형
Redis Scan 사용시 org.springframework.data.redis.RedisSystemException: Error in execution 에러 해결 방법
2023-10-23 13:21:54.410 [PID:1 Thrd:XNIO-1 task-4] com.yellowballoon.framework.api.exception.GlobalExceptionAdvice:144 - handleException
ERROR > Error in execution
org.springframework.data.redis.RedisSystemException: Error in execution
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:52)
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:50)
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41)
at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:40)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:38)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:248)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.await(LettuceConnection.java:961)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.lambda$doInvoke$4(LettuceConnection.java:818)
at org.springframework.data.redis.connection.lettuce.LettuceInvoker$Synchronizer.invoke(LettuceInvoker.java:665)
at org.springframework.data.redis.connection.lettuce.LettuceInvoker.just(LettuceInvoker.java:109)
at org.springframework.data.redis.connection.lettuce.LettuceKeyCommands$1.doScan(LettuceKeyCommands.java:157)
at org.springframework.data.redis.connection.lettuce.LettuceScanCursor.scanAndProcessState(LettuceScanCursor.java:73)
at org.springframework.data.redis.connection.lettuce.LettuceScanCursor.doScan(LettuceScanCursor.java:58)
at org.springframework.data.redis.core.ScanCursor.scan(ScanCursor.java:90)
at org.springframework.data.redis.core.ScanCursor.hasNext(ScanCursor.java:176)
...
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: io.lettuce.core.RedisCommandExecutionException: ERR invalid cursor
at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:147)
at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:116)
at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:120)
at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:111)
...
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
... 1 common frames omitted
SQL로 따지면 like 조회같은 기능을 만들기 위해 key pattern 형식으로 키를 찾아 상세조회 하는 기능 중 scan쪽에서 문제가 있었음
ScanOptions scanOptions = ScanOptions.scanOptions().match(searchData).build();
Cursor<byte[]> keys = redisTemplate.getConnectionFactory().getConnection().scan(scanOptions);
알고보니 ScanOptions에 count를 기입하지 않아 full scan을 타다가 에러가 난것으로 생각됨
ScanOptions scanOptions = ScanOptions.scanOptions().match(searchData).count(1000).build();
Cursor<byte[]> keys = redisTemplate.getConnectionFactory().getConnection().scan(scanOptions);
후에 .count(1000) 추가
위 문제 사라졌음!!!
count 옵션은 분할 조회 건수였음
Redis Scan count가 기본 10인데 이로 인해 수행시간이 지연되면서 전체 응답속도 지연뿐 아니라 위 에러가 난것이었음
예를 들면 20000 건으로 기본 scan(10) 시 2000번 호출을 한 꼴이었음20000 건을 1000count 수로 호출시 20 번이면 끝나는 내용임
이로인해 수행시간, 응답속도가 빨라짐을 확인할 수 있었음
끗!@#!#$~!#
참고 https://peterica.tistory.com/153
반응형
'DB & Redis' 카테고리의 다른 글
Mac DBeaver MariaDB dump 시 Local client is not specified for connection. 에러 해결 방법 (0) | 2024.01.19 |
---|---|
Redis 키 패턴 조회, 삭제 (0) | 2023.10.11 |
postgreSQL Docker에서 접속 시 psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "postgress" does not exist 에러 해결 (0) | 2023.09.15 |
MySql Stored Procedure 생성 및 저장방법 (0) | 2022.10.04 |
MySql ViewTable 생성 및 작성방법 (0) | 2022.10.04 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 남자 혼자 여행
- vscode
- 보성 여행
- 고흥 여행
- 나래바이크
- 제주도 스쿠터 여행
- 송내역 룸카페
- 국제반점
- 은파호수공원
- 영광 여행
- 송내 룸카페
- 군산 게스트하우스
- 스쿠터 여행
- 군산 여행
- 리니지m
- 스쿠터 전국 일주
- 담양 여행
- kendo grid
- 송내역 카페
- 전국 일주 여행
- 군산 가볼만한곳
- 오라클 DB 링크
- Docker
- 인터바이크
- 윈드스크린
- 초원사진관
- 돌장갑
- 베스파LX
- 남자 혼자 국내 여행
- 송내 카페
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함