programing

스프링 부트 R2DBC: org.mariadb.r2dbc.client.유휴 기간 후 클라이언트 Base 연결에 예기치 않은 오류가 발생했습니다.

muds 2023. 7. 30. 18:08
반응형

스프링 부트 R2DBC: org.mariadb.r2dbc.client.유휴 기간 후 클라이언트 Base 연결에 예기치 않은 오류가 발생했습니다.

Spring Boot에서 MariaDB R2DBC 연결 문제를 해결하는 데 도움이 되길 바랍니다.

내 앱에 있는 것은 Rabbit의 소비자들입니다.수신된 메시지에서 일부 DB 작업(선택, 삽입, 업데이트 등)을 수행하는 MQ.관련된 경우, RabbitMQ 소비는 예에 따라 설정됩니다.

이슈는 다음과 같습니다.RabbitMQ(예: 생산 중)의 메시지 흐름은 지속적이지만 모든 것이 잘 작동합니다.그러나 테스트와 같은 다른 환경에서는 마지막 메시지가 처리된 후 RabbitMQ를 통해 한 묶음의 메시지만 보내고 유휴 상태가 된 후 다음과 같은 메시지가 표시됩니다.

2021-11-19T10:00:33.653682967Z 2021-11-19 10:00:33.653 DEBUG 1 --- [tor-tcp-epoll-2] o.s.r2dbc.core.DefaultDatabaseClient     : Executing SQL statement [<statement>]
<in a while...>
2021-11-19T10:09:28.791777463Z 2021-11-19 10:09:28.790 ERROR 1 --- [tor-tcp-epoll-2] org.mariadb.r2dbc.client.ClientBase      : Connection unexpected error

2021-11-19T10:09:28.791865848Z 

2021-11-19T10:09:28.791870296Z io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.791873532Z 

2021-11-19T10:09:28.792070449Z 2021-11-19 10:09:28.791 ERROR 1 --- [tor-tcp-epoll-2] reactor.core.publisher.Operators         : Operator called default onErrorDropped

2021-11-19T10:09:28.792084305Z 

2021-11-19T10:09:28.792087892Z reactor.core.Exceptions$ErrorCallbackNotImplemented: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.792091288Z Caused by: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.792094454Z 

2021-11-19T10:09:28.912384320Z 2021-11-19 10:09:28.911 ERROR 1 --- [tor-tcp-epoll-2] org.mariadb.r2dbc.client.ClientBase      : Connection unexpected error

2021-11-19T10:09:28.912429916Z 

2021-11-19T10:09:28.912436338Z io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.912441508Z 

2021-11-19T10:09:28.912597929Z 2021-11-19 10:09:28.912 ERROR 1 --- [tor-tcp-epoll-2] reactor.core.publisher.Operators         : Operator called default onErrorDropped

2021-11-19T10:09:28.912614901Z 

2021-11-19T10:09:28.912620521Z reactor.core.Exceptions$ErrorCallbackNotImplemented: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.912625822Z Caused by: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.912630660Z 

2021-11-19T10:09:28.913520271Z 2021-11-19 10:09:28.913 ERROR 1 --- [tor-tcp-epoll-2] org.mariadb.r2dbc.client.ClientBase      : Connection unexpected error

2021-11-19T10:09:28.913545226Z 

2021-11-19T10:09:28.913606432Z io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.913618294Z 

2021-11-19T10:09:28.913657416Z 2021-11-19 10:09:28.913 ERROR 1 --- [tor-tcp-epoll-2] reactor.core.publisher.Operators         : Operator called default onErrorDropped

2021-11-19T10:09:28.913670891Z 

2021-11-19T10:09:28.913675690Z reactor.core.Exceptions$ErrorCallbackNotImplemented: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.913680880Z Caused by: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.913685749Z 

2021-11-19T10:09:28.914072671Z 2021-11-19 10:09:28.913 ERROR 1 --- [tor-tcp-epoll-2] org.mariadb.r2dbc.client.ClientBase      : Connection unexpected error

2021-11-19T10:09:28.914162960Z 

2021-11-19T10:09:28.914175483Z io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.914182827Z 

2021-11-19T10:09:28.914310485Z 2021-11-19 10:09:28.914 ERROR 1 --- [tor-tcp-epoll-2] reactor.core.publisher.Operators         : Operator called default onErrorDropped

2021-11-19T10:09:28.914350279Z 

2021-11-19T10:09:28.914355910Z reactor.core.Exceptions$ErrorCallbackNotImplemented: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.914379684Z Caused by: io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer

2021-11-19T10:09:28.914384694Z 

2021-11-19T10:11:00.001676921Z 2021-11-19 10:11:00.000  INFO 1 --- [   scheduling-1] c.e.d.r.service.DeviceWakeupScheduler    : Checking some stuff at 2021-11-19T10:11:00.000878682

2021-11-19T10:11:00.005672948Z 2021-11-19 10:11:00.005  WARN 1 --- [undedElastic-18] c.e.d.r.service.DeviceWakeupScheduler    : Resetting some stuff failed due to error: Failed to obtain R2DBC Connection; nested exception is io.r2dbc.spi.R2dbcNonTransientResourceException: Connection validation failed

2021-11-19T10:11:00.009277315Z 2021-11-19 10:11:00.008 ERROR 1 --- [   scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task

2021-11-19T10:11:00.009290410Z 

2021-11-19T10:11:00.009294377Z org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection; nested exception is io.r2dbc.spi.R2dbcNonTransientResourceException: Connection validation failed

2021-11-19T10:11:00.009298164Z  at org.springframework.r2dbc.connection.ConnectionFactoryUtils.lambda$getConnection$0(ConnectionFactoryUtils.java:88) ~[spring-r2dbc-5.3.12.jar!/:5.3.12]

2021-11-19T10:11:00.009302392Z  at reactor.core.publisher.Mono.lambda$onErrorMap$31(Mono.java:3732) ~[reactor-core-3.4.11.jar!/:3.4.11]

2021-11-19T10:11:00.009320226Z  at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94) ~[reactor-core-3.4.11.jar!/:3.4.11]
...

DB에 연결하고 서버를 구성하는 방법은 다음과 같습니다.

server:
  port: 8180
  netty:
    connection-timeout: 60m // added later trying to fix
    
spring:
  r2dbc:
    url: r2dbc:mariadb://<stage_ip>:3306/<database_name>
    username: <user>
    password: <password>
    pool:
      max-idle-time: 60m
      enabled: true

프로젝트에 포함된 종속성 버전은 다음과 같습니다.

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>
</parent>

<dependency>
<groupId>org.mariadb</groupId>
<artifactId>r2dbc-mariadb</artifactId>
<version>1.0.3</version>
</dependency>

<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-pool</artifactId>
<version>0.8.7.RELEASE</version>
</dependency>

언급URL : https://stackoverflow.com/questions/70033526/spring-boot-r2dbc-org-mariadb-r2dbc-client-clientbase-connection-unexpected-err

반응형