prisma / prisma1

💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB) [deprecated]
https://v1.prisma.io/docs/
Apache License 2.0
16.55k stars 862 forks source link

Attempts to connect to postgres with alternative database name #4169

Closed calummoore closed 5 years ago

calummoore commented 5 years ago

Describe the bug Deploy fails, it attempts to connecto to postgres database, even though I have specified an alternative database name orqidund.

To Reproduce Attempt to deploy prisma deploy and I get the following error message:

  environment TypeError: Cannot read property 'serverInfo' of undefined
  environment     at Cluster.<anonymous> (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-yml/src/Cluster.ts:227:19)
  environment     at step (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-yml/dist/Cluster.js:32:23)
  environment     at Object.next (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-yml/dist/Cluster.js:13:53)
  environment     at fulfilled (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-yml/dist/Cluster.js:4:58)
  environment     at process._tickCallback (internal/process/next_tick.js:68:7) +0ms
Error: Could not connect to server at https://weekly-prisma-latest-zqsp.zeplosvc.com. Please check if your server is running.
    at Deploy.<anonymous> (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-cli-core/src/commands/deploy/deploy.ts:128:13)
    at step (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/deploy/deploy.js:45:23)
    at Object.next (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/deploy/deploy.js:26:53)
    at fulfilled (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/deploy/deploy.js:17:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Exiting with code: 1

Docker config is:

image: prismagraphql/prisma:1.28
environment:
  - name: PRISMA_CONFIG
    value: |
      port: 4466
      databases:
        default:
          connector: postgres
          host: otto.db.elephantsql.com
          port: 5432
          user: orqidund
          database: orqidund
          password: *********
          migrations: true

Expected behavior Deploys to Prisma server

Versions (please complete the following information):

Additional context I get the following log output:

No log level set, defaulting to INFO.
Mar 12, 2019 12:36:37 AM org.postgresql.core.v3.ConnectionFactoryImpl log
WARNING: SQLException occurred while connecting to otto.db.elephantsql.com:5432
org.postgresql.util.PSQLException: FATAL: permission denied for database "postgres"
  Detail: User does not have CONNECT privilege.
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
    at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2566)
    at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:131)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:210)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
    at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
    at org.postgresql.Driver.makeConnection(Driver.java:452)
    at org.postgresql.Driver.connect(Driver.java:254)
    at slick.jdbc.DriverDataSource.getConnection(DriverDataSource.scala:101)
    at slick.jdbc.DataSourceJdbcDataSource.createConnection(JdbcDataSource.scala:68)
    at slick.jdbc.JdbcBackend$BaseSession.<init>(JdbcBackend.scala:453)
    at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:46)
    at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:37)
    at slick.basic.BasicBackend$DatabaseDef.acquireSession(BasicBackend.scala:249)
    at slick.basic.BasicBackend$DatabaseDef.acquireSession$(BasicBackend.scala:248)
    at slick.jdbc.JdbcBackend$DatabaseDef.acquireSession(JdbcBackend.scala:37)
    at slick.basic.BasicBackend$DatabaseDef$$anon$2.run(BasicBackend.scala:274)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Mar 12, 2019 12:36:37 AM org.postgresql.Driver connect
SEVERE: Connection error: 
org.postgresql.util.PSQLException: FATAL: permission denied for database "postgres"
  Detail: User does not have CONNECT privilege.
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
    at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2566)
    at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:131)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:210)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
    at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
    at org.postgresql.Driver.makeConnection(Driver.java:452)
    at org.postgresql.Driver.connect(Driver.java:254)
    at slick.jdbc.DriverDataSource.getConnection(DriverDataSource.scala:101)
    at slick.jdbc.DataSourceJdbcDataSource.createConnection(JdbcDataSource.scala:68)
    at slick.jdbc.JdbcBackend$BaseSession.<init>(JdbcBackend.scala:453)
    at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:46)
    at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:37)
    at slick.basic.BasicBackend$DatabaseDef.acquireSession(BasicBackend.scala:249)
    at slick.basic.BasicBackend$DatabaseDef.acquireSession$(BasicBackend.scala:248)
    at slick.jdbc.JdbcBackend$DatabaseDef.acquireSession(JdbcBackend.scala:37)
    at slick.basic.BasicBackend$DatabaseDef$$anon$2.run(BasicBackend.scala:274)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

[INFO] Initializing workers...
[INFO] Obtaining exclusive agent lock...
[INFO] Successfully started 1 workers.
[INFO] Obtaining exclusive agent lock... Successful.
[INFO] Deployment worker initialization complete.
Server running on :4466
Syntax error while parsing GraphQL query. Unexpected end of input, expected CommentCap, OperationType, Fragment, schema, BlockString, '"', scalar or type (line 2, column 1):

^
sangria.parser.SyntaxError: Syntax error while parsing GraphQL query. Unexpected end of input, expected CommentCap, OperationType, Fragment, schema, BlockString, '"', scalar or type (line 2, column 1):

^
    at sangria.parser.QueryParser$.parse(QueryParser.scala:433)
    at sangria.parser.QueryParser$.parse(QueryParser.scala:425)
    at com.prisma.sangria_server.SangriaHandler.$anonfun$parseAsGraphqlQuery$4(SangriaServer.scala:66)
    at play.api.libs.json.JsSuccess.map(JsResult.scala:18)
    at com.prisma.sangria_server.SangriaHandler.$anonfun$parseAsGraphqlQuery$3(SangriaServer.scala:64)
    at play.api.libs.json.JsSuccess.flatMap(JsResult.scala:20)
    at com.prisma.sangria_server.SangriaHandler.$anonfun$parseAsGraphqlQuery$2(SangriaServer.scala:63)
    at play.api.libs.json.JsSuccess.flatMap(JsResult.scala:20)
    at com.prisma.sangria_server.SangriaHandler.$anonfun$parseAsGraphqlQuery$1(SangriaServer.scala:62)
    at scala.util.Try$.apply(Try.scala:209)
    at com.prisma.sangria_server.SangriaHandler.parseAsGraphqlQuery(SangriaServer.scala:58)
    at com.prisma.sangria_server.SangriaHandler.handleRawRequest(SangriaServer.scala:46)
    at com.prisma.sangria_server.SangriaHandler.handleRawRequest$(SangriaServer.scala:34)
    at com.prisma.image.SangriaHandlerImpl.super$handleRawRequest(SangriaHandlerImpl.scala:80)
    at com.prisma.image.SangriaHandlerImpl.$anonfun$handleRawRequest$7(SangriaHandlerImpl.scala:80)
    at com.prisma.image.RequestThrottler.throttleCallIfNeeded(RequestThrottler.scala:47)
    at com.prisma.image.SangriaHandlerImpl.handleRawRequest(SangriaHandlerImpl.scala:80)
    at com.prisma.sangria_server.AkkaHttpSangriaServer.$anonfun$routes$9(AkkaHttpSangriaServer.scala:53)
    at akka.http.scaladsl.server.directives.OnSuccessMagnet$$anon$1.$anonfun$directive$2(FutureDirectives.scala:97)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResult$2(BasicDirectives.scala:59)
    at akka.http.scaladsl.server.directives.FutureDirectives.$anonfun$onComplete$3(FutureDirectives.scala:37)
    at akka.http.scaladsl.util.FastFuture$.$anonfun$transformWith$1(FastFuture.scala:37)
    at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)
    at akka.http.scaladsl.util.FastFuture$.transformWith$extension1(FastFuture.scala:45)
    at akka.http.scaladsl.util.FastFuture$.transformWith$extension0(FastFuture.scala:37)
    at akka.http.scaladsl.server.directives.FutureDirectives.$anonfun$onComplete$2(FutureDirectives.scala:37)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$textract$2(BasicDirectives.scala:152)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResult$2(BasicDirectives.scala:59)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$textract$2(BasicDirectives.scala:152)
    at akka.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation.$anonfun$$tilde$1(RouteConcatenation.scala:44)
    at akka.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation.$anonfun$$tilde$1(RouteConcatenation.scala:44)
    at akka.http.scaladsl.server.Directive.$anonfun$recover$4(Directive.scala:93)
    at akka.http.scaladsl.server.Directive.$anonfun$recover$4(Directive.scala:93)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$textract$2(BasicDirectives.scala:152)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResult$2(BasicDirectives.scala:59)
    at akka.http.scaladsl.server.Directive.$anonfun$recover$5(Directive.scala:94)
    at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)
    at akka.http.scaladsl.util.FastFuture$.transformWith$extension1(FastFuture.scala:45)
    at akka.http.scaladsl.util.FastFuture$.flatMap$extension(FastFuture.scala:26)
    at akka.http.scaladsl.server.Directive.$anonfun$recover$2(Directive.scala:93)
    at akka.http.scaladsl.server.Directive.$anonfun$recover$2(Directive.scala:93)
    at akka.http.scaladsl.server.Directive.$anonfun$recover$2(Directive.scala:93)
    at akka.http.scaladsl.server.directives.ExecutionDirectives.$anonfun$handleExceptions$2(ExecutionDirectives.scala:32)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResult$2(BasicDirectives.scala:59)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$textract$2(BasicDirectives.scala:152)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResult$2(BasicDirectives.scala:59)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$textract$2(BasicDirectives.scala:152)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResultWith$2(BasicDirectives.scala:65)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$textract$2(BasicDirectives.scala:152)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResultWith$2(BasicDirectives.scala:65)
    at akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$textract$2(BasicDirectives.scala:152)
    at akka.http.scaladsl.server.directives.ExecutionDirectives.$anonfun$handleExceptions$2(ExecutionDirectives.scala:32)
    at akka.http.scaladsl.server.Route$.$anonfun$asyncHandler$1(Route.scala:79)
    at akka.stream.impl.fusing.MapAsync$$anon$25.onPush(Ops.scala:1190)
    at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:519)
    at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:482)
    at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:378)
    at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:588)
    at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:472)
    at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:563)
    at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:745)
    at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:760)
    at akka.actor.Actor.aroundReceive(Actor.scala:517)
    at akka.actor.Actor.aroundReceive$(Actor.scala:515)
    at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:670)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:588)
    at akka.actor.ActorCell.invoke(ActorCell.scala:557)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:258)
    at akka.dispatch.Mailbox.run(Mailbox.scala:225)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:235)
    at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: ParseError(Position(36,2,1), Position(36,2,1), <24 traces>)
    at org.parboiled2.Parser.done$1(Parser.scala:186)
    at org.parboiled2.Parser.phase4_collectRuleTraces$1(Parser.scala:200)
    at org.parboiled2.Parser.__run(Parser.scala:210)
    at sangria.parser.QueryParser$.parse(QueryParser.scala:430)
    ... 73 more
do4gr commented 5 years ago

Hey @calummoore,

I tried to connect ElephantSQL as well. I get the same error about accessing the postgres database.

That error does not seem to be fatal for the Prisma service though. Deploying a service works and creates the correct schemata in the provided database:

Bildschirmfoto 2019-03-12 um 15 09 41

Writing and reading data from that database does also seem to work.

Bildschirmfoto 2019-03-12 um 15 14 24

The error message you posted further down are from our GraphQL query validation library. And it seems the server is receiving an invalid GraphQL query. Can you try writing queries through the playground? That should validate the GraphQL statements and help pinpoint the issue.

calummoore commented 5 years ago

Thanks for the update. It won't let me deploy though? When I access the endpoint I get a GraphQL playground so it appears to be running.

prisma.yml

endpoint: https://weekly-prisma-latest-zqsp.zeplosvc.com
datamodel: datamodel.prisma

datamodel.prisma

type User {
  id: ID! @unique
  name: String!
}

I get the following error on prisma deploy

  environment TypeError: Cannot read property 'serverInfo' of undefined
  environment     at Cluster.<anonymous> (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-yml/src/Cluster.ts:227:19)
  environment     at step (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-yml/dist/Cluster.js:32:23)
  environment     at Object.next (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-yml/dist/Cluster.js:13:53)
  environment     at fulfilled (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-yml/dist/Cluster.js:4:58)
  environment     at process._tickCallback (internal/process/next_tick.js:68:7) +0ms
Error: Could not connect to server at https://weekly-prisma-latest-zqsp.zeplo.xyz. Please check if your server is running.
    at Deploy.<anonymous> (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-cli-core/src/commands/deploy/deploy.ts:128:13)
    at step (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/deploy/deploy.js:45:23)
    at Object.next (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/deploy/deploy.js:26:53)
    at fulfilled (/Users/calummoore/.nvm/versions/node/v10.13.0/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/deploy/deploy.js:17:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  util timed out +0ms
pantharshit00 commented 5 years ago

Hi @calummoore

I am also unable to reproduce this. I have successfully deployed the datamodel and also written a user in the database.

image

I think you should enable connectionLimits in the config as elephantSQL provides limited number of connections:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.29.2
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host: isilo.db.elephantsql.com
            database: <redacted>
            user: <redacted>
            password:<redacted>
            rawAccess: true
            port: '5432'
            connectionLimit: 4
            migrations: true
            ssl: true
pantharshit00 commented 5 years ago

Closing this now. Feel free to open a new issue if you are still experiencing this