S-HealthStack/backend-system

postgres db 설정의 에러

Closed this issue · 1 comments

안녕하세요.

postgres로 db 설정하였는데 아래 에러가 발생합니다.
추가로 platform 서버가 제대로 설정되었을 경우 정상 동작되는지 확인하는 방법 있을지요?

02:12:24.092 [main] INFO c.s.h.p.HealthResearchPlatformApplicationKt - Starting HealthResearchPlatformApplicationKt using Java 17.0.2 on 37082d2023db with PID 1 (/BOOT-INF/classes started by root in /)
02:12:24.095 [main] INFO c.s.h.p.HealthResearchPlatformApplicationKt - No active profile set, falling back to 1 default profile: "default"
02:12:25.172 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data R2DBC repositories in DEFAULT mode.
02:12:25.185 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 8 ms. Found 0 R2DBC repository interfaces.
02:12:25.576 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Bootstrapping Spring Data R2DBC repositories in DEFAULT mode.
02:12:25.813 [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 235 ms. Found 6 R2DBC repository interfaces.
02:12:27.404 [reactor-tcp-epoll-1] WARN i.r.p.client.ReactorNettyClient - Error: SEVERITY_LOCALIZED=ERROR, SEVERITY_NON_LOCALIZED=ERROR, CODE=42P01, MESSAGE=relation "projects" does not exist, POSITION=16, FILE=parse_relation.c, LINE=1381, ROUTINE=parserOpenTable
02:12:27.420 [reactor-tcp-epoll-1] ERROR reactor.core.publisher.Operators - Operator called default onErrorDropped
reactor.core.Exceptions$ErrorCallbackNotImplemented: io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: [42P01] relation "projects" does not exist
Caused by: io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: relation "projects" does not exist
at io.r2dbc.postgresql.ExceptionFactory.createException(ExceptionFactory.java:86)
at io.r2dbc.postgresql.ExceptionFactory.handleErrorResponse(ExceptionFactory.java:111)
at io.r2dbc.postgresql.PostgresqlResult.lambda$map$2(PostgresqlResult.java:111)
at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:169)
at reactor.core.publisher.FluxWindowPredicate$WindowFlux.drainRegular(FluxWindowPredicate.java:668)
at reactor.core.publisher.FluxWindowPredicate$WindowFlux.drain(FluxWindowPredicate.java:746)
at reactor.core.publisher.FluxWindowPredicate$WindowFlux.onNext(FluxWindowPredicate.java:788)
at reactor.core.publisher.FluxWindowPredicate$WindowPredicateMain.onNext(FluxWindowPredicate.java:239)
at io.r2dbc.postgresql.util.FluxDiscardOnCancel$FluxDiscardOnCancelSubscriber.onNext(FluxDiscardOnCancel.java:86)
at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107)
at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:793)
at reactor.core.publisher.FluxCreate$BufferAsyncSink.next(FluxCreate.java:718)
at reactor.core.publisher.FluxCreate$SerializedFluxSink.next(FluxCreate.java:154)
at io.r2dbc.postgresql.client.ReactorNettyClient$Conversation.emit(ReactorNettyClient.java:636)
at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.emit(ReactorNettyClient.java:887)
at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.onNext(ReactorNettyClient.java:761)
at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.onNext(ReactorNettyClient.java:668)
at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:119)
at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854)
at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:220)
at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:220)
at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:279)
at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:388)
at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:404)
at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:314)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:435)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
02:12:28.499 [main] INFO o.f.c.i.license.VersionPrinter - Flyway Community Edition 8.5.2 by Redgate
02:12:28.499 [main] INFO o.f.c.i.license.VersionPrinter - See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.2
02:12:28.499 [main] INFO o.f.c.i.license.VersionPrinter -
02:12:28.500 [main] INFO o.f.c.i.d.base.BaseDatabaseType - Database: jdbc:postgresql://postgres:5432/research_platform (PostgreSQL 14.5)
02:12:28.542 [main] INFO o.f.core.internal.command.DbValidate - Successfully validated 6 migrations (execution time 00:00.024s)
02:12:28.550 [main] INFO o.f.core.internal.command.DbMigrate - Current version of schema "public": 0.0.6
02:12:28.551 [main] INFO o.f.core.internal.command.DbMigrate - Schema "public" is up to date. No migration necessary.
02:12:28.686 [main] INFO o.s.b.a.s.r.ReactiveUserDetailsServiceAutoConfiguration -

안녕하세요.

로그 상 flyway migration을 통해 default schema에 projects table을 성공적으로 생성했는데,
이 테이블을 못 찾는 거라
application.yml에 선언되어 있는 config.db.schema 값이 잘못 설정된 것으로 보입니다.

config.db.schema 값을 public으로 변경 후 수행해 보시겠어요?

Postman등의 HTTP Client를 활용하면, HTTP Request를 호출할 수 있어
Backend Server가 정상적으로 실행됐는지 확인하실 수 있습니다.

Postman이 설치되어 있지 않으시다면 아래 curl 명령어를 활용하셔도 좋은데요,

curl --location --request POST 'http://localhost:3030/api/projects' \
--header 'Authorization: Basic @@@@@@' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Project-Name-Sample",
    "isOpen": true,
    "info": {
        "jiyun": "zzang",
        "startDate": "2020-05-02",
        "thisIsInt": 10
    }
}'

@@@@@@부분은

  1. Application 실행 시 찍히는 아래 로그에서 Using generated security password: 부분을 복사하여
15:57:24.653 [main] INFO  o.s.b.a.s.r.ReactiveUserDetailsServiceAutoConfiguration - 

Using generated security password: 32a8f26a-86f8-43ca-8fc5-42f4cb423619

15:57:24.782 [main] INFO  o.s.b.w.e.netty.NettyWebServer - Netty started on port 3030
  1. https://www.base64encode.org/ 에 접속해 user:값 형태로 base64 encoding한 값을 넣어주시면 됩니다.

무슨 일인지 이미지 파일 첨부가 되지 않는데, 이 캡처본은 메일로 다시 송부드리겠습니다.

  1. 결국 아래 형태의 authorization 값을 사용하실 수 있습니다.
curl --location --request POST 'http://localhost:3030/api/projects' \
--header 'Authorization: Basic dXNlcjozMmE4ZjI2YS04NmY4LTQzY2EtOGZjNS00MmY0Y2I0MjM2MTk=' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Project-Name-Sample",
    "isOpen": true,
    "info": {
        "jiyun": "zzang",
        "startDate": "2020-05-02",
        "thisIsInt": 10
    }
}'