GithubHelp home page GithubHelp logo

Comments (39)

syedzainqadri avatar syedzainqadri commented on May 24, 2024 2

Hay Facing the same issue
with mysql in development
PrismaClientInitializationError:
message: Failed to start the query engine: Connection refused
errorCode: null
clientVersion: 2.4.5
Can you guide that how can we manually start the prisma query engine

from prisma-dart.

medz avatar medz commented on May 24, 2024 1

Meanwhile, I'm working on a more stable C api query engine, using Rust. However, my personal time is limited, and I can only maintain the binary query engine version for the time being. I think I need help from the community. I have developed a version, but it has not been applied to Prisma ORM for Dart, because it depends on the Prisma engines warehouse (using git for dependency, non-standard release) which leads to huge maintenance costs. The query engine requirement of C API is submitted to Prisma official. Use FFI for data interaction to achieve a more stable engine and Flutter support.

https://github.com/odroe/prisma-query-c-api

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC This needs to be investigated why it is rejected, and my usual practice is to manually start the Prisma query engine in the command line window to locate the problem.

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@yahu1031

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@AndryHTC This needs to be investigated why it is rejected, and my usual practice is to manually start the Prisma query engine in the command line window to locate the problem.

I will not refuse a little bit of a guide on how to do it πŸ˜„

from prisma-dart.

medz avatar medz commented on May 24, 2024

The Prisma query engine is placed in the .dart_tool/prisma directory by default

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

I'm sorry @medz, but you aren't suggesting anything useful... Like @EwigSol sad

Can you guide that how can we manually start the prisma query engine

We understand where is the engine... The question is: how can we try to start it? Is a binary without any extension...

Please, give us support πŸ™

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC @EwigSol Sorry, I understand. Below I will fully describe the specific debugging methods and steps of "Connection refused" in Prisma ORM in the deployed environment

OpenSSL/LibSSL

In the deployment environment, check whether OpenSSL or LibSSL has been installed, and if not, install it.

unix socket blocking

If your database is running locally, then you need to check whether it is blocked by the local unix socket.

Usually manifested as: Connection refused or Connection timed out.

Remote database connection

If your database is running remotely, then you need to check if it is a database connection problem.

Usually you can try to ping or use telnet to check if you can connect to the database.

Local database

If your database is running locally, then you need to check whether it is a problem with the database connection.

Prisma binary engine default location

The default location of the Prisma binary engine is .dart_tool/prisma/query-engine. On Windows, the default location is .dart_tool\prisma\query-engine.exe.

Start parameters

  • --debug: start debug mode, you can see more debug information
  • --enable-raw-queries: enable raw query mode
  • --enable-open-telemetry: enable OpenTelemetry mode
  • --enable-playground: enable GraphQL Playground
  • --datamodel: Prisma schema.prisma content Base64 encoded string, choose one of --datamodel-path
  • --datamodel-path: Prisma schema.prisma file path, choose one of --datamodel
  • --overwrite-datasources: Overwrite database sources
  • --port: start port

The startup parameters in Prisma ORM for Dart are:

PRISMA_DML={Base64 encoded prisma schema content} query-engine --enable-raw-queries --enable-metrics --enable-open-telemetry --port {free port}

Manually start the binary engine

DATABASE_URL={DB connect url} query-engine --enable-raw-queries --enable-playground --enable-metrics --enable-open-telemetry --port {port} --datamodel-path {path to schema.prisma}

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

The default location of the Prisma binary engine is .dart_tool/prisma/query-engine. On Windows, the default location is .dart_tool\prisma\query-engine.exe.

First of all... On Windows, I don't find any query-engine.exe, just query-engine exactly like all the other OSes...

The startup parameters in Prisma ORM for Dart are:

PRISMA_DML={Base64 encoded prisma schema content} query-engine --enable-raw-queries --enable-metrics --enable-open-telemetry --port {free port}

Manually start the binary engine

DATABASE_URL={DB connect url} query-engine --enable-raw-queries --enable-playground --enable-metrics --enable-open-telemetry --port {port} --datamodel-path {path to schema.prisma}

I've tried to manually start the binary engine in local - with Ubuntu, MacOS and Windows with WSL - where Prisma works. I've also tried to manually start the binary engine in the deployed environment (where Prisma do NOT work).

All the commands says that the query-engine command is not found...

Local MacOS (where Prisma Works):

project_server % cd .dart_tool 
.dart_tool % cd prisma
prisma % ls                                                                                                                                                                                                                                                                
query-engine

prisma % DATABASE_URL=[url...] query-engine --enable-raw-queries --enable-playground --enable-metrics --enable-open-telemetry --port [port...] --datamodel-path ../../prisma/schema.prisma
zsh: command not found: query-engine

Local Ubuntu (where Prisma Works):

$ cd project_server/
project_server$ cd .dart_tool/
project_server/.dart_tool$ cd prisma
project_server/.dart_tool/prisma$ ls
query-engine

project_server/.dart_tool/prisma$ DATABASE_URL=[url...] query-engine --enable-raw-queries --enable-playground --enable-metrics --enable-open-telemetry --port [port...] --datamodel-path ../../prisma/schema.prisma
query-engine: command not found

Amazon Linux 2 (where Prisma do NOT work):

[project_server]$ cd prisma

[project_server/prisma]$ ls
development.dart  prisma_version.dart  query-engine  schema.prisma

[project_server/prisma]$ DATABASE_URL=[url...] query-engine --enable-raw-queries --enable-playground --enable-metrics --enable-open-telemetry --port [port...] --datamodel-path schema.prisma
bash: query-engine: command not found
[project_server/prisma]$ query-engine
bash: query-engine: command not found

I've lost an entire day trying to start the query-engine even where it works... I don't understand if I'm doing something wrong or if you missed something in the reply.

By the way thank you for replying @medz

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC I know what you missed, the download of the query engine is a progressive download based on the demand of the cli command. So if you want to manually debug the binary engine, please use the precache command to download the binary engine. For details, please see https://prisma.pub/reference/cli#precache

from prisma-dart.

medz avatar medz commented on May 24, 2024

image

Replace executable binary name in command line:
DATABASE_URL=[url...] ./query-engine\
  --enable-raw-queries\
  --enable-playground --enable-metrics \
  --enable-open-telemetry --port [port...] \
  --datamodel-path ../../prisma/schema.prisma

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@medz thank you

Replace executable binary name in command line:

At lest we can go further πŸ˜„
./query-engine: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory

from prisma-dart.

medz avatar medz commented on May 24, 2024

error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory

@AndryHTC It means that the running environment lacks OpenSSL/LibSSL. My suggestion is to download the query engine in the running environment (CLI will search for the matching version of the local OpenSSL/LibSSL). If this prompt appears after the successful download, it means that OpenSSL/LibSSL is found locally but not sure Its version was then rolled back to LibSSL 1.0 (which is the minimum requirement for the Prisma binary engine to run)

Repair suggestion:

  1. Run openssl version -v to check whether there is this command or a version higher than 1.0 locally
  2. If step 1 is unsuccessful, run ls -l /lib64 && ls -l /usr/lib64 to see what matches it in the output: libssl.so.(\d+.\d+.\d+)
  3. Try to install OpenSSL
  4. After completing step 3, delete the locally cached query engine binary, and use the dart run orm precache command to re-download the binary engine

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024
  • Run openssl version -v to check whether there is this command or a version higher than 1.0 locally
[ec2-user@ip-**]$ openssl version -v
OpenSSL 1.0.2k-fips  26 Jan 2017

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@medz I've tried to re-run the dart run orm precache -t query as you shown in other issues, but:

[ec2-user@ip-** serverpod_server]$ dart run orm precache -t query
Dart_LoadScriptFromKernel: The binary program does not contain 'main'.

Is this talking about the project folder? It is a serverpod_server one, so there is no main.dart. The start script is the lib/server.dart

from prisma-dart.

medz avatar medz commented on May 24, 2024

image

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

... so? How this could help me in any way? 🀣

I will attach the same if you want

sh-4.2$ sudo su ec2-user
[ec2-user@ip-** bin]$ cd
[ec2-user@ip-** ~]$ cd serverpod
[ec2-user@ip-**1 serverpod]$ cd active
[ec2-user@ip-** active]$ cd serverpod_server
[ec2-user@ip-** serverpod_server]$ ls
analysis_options.yaml  aws  bin  CHANGELOG.md  config  docker-compose.yaml  generated  lib  prisma  pubspec.lock  pubspec.yaml  README.md  setup-tables.cmd  web
[ec2-user@ip-** serverpod_server]$ dart run orm precache -t query
Dart_LoadScriptFromKernel: The binary program does not contain 'main'.
[ec2-user@ip-** serverpod_server]$ cd prisma
[ec2-user@ip-** prisma]$ ls
development.dart  schema.prisma

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@medz cleaning dart cache e applying dart pub get the command starts but freezes the server instance (the console and all the calls to the server too)

[ec2-user@ip-** serverpod_server]$ dart pub get
Resolving dependencies... (2.5s)
  _fe_analyzer_shared 50.0.0 (51.0.0 available)
  analyzer 5.2.0 (5.3.1 available)
  build_runner 2.3.2 (2.3.3 available)
  googleapis 7.0.0 (9.2.0 available)
  intl 0.17.0 (0.18.0 available)
  js 0.6.5 (0.6.6 available)
  matcher 0.12.13 (0.12.14 available)
  path 1.8.2 (1.8.3 available)
  serverpod 0.9.20 (0.9.21 available)
  serverpod_auth_server 0.9.20 (0.9.21 available)
  serverpod_client 0.9.20 (0.9.21 available)
  serverpod_serialization 0.9.20 (0.9.21 available)
  serverpod_service_client 0.9.20 (0.9.21 available)
  serverpod_shared 0.9.20 (0.9.21 available)
Got dependencies!
[ec2-user@ip-** serverpod_server]$ dart run orm precache -t query
Building package executable... (15.4s)

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@medz I apologize for being so insistent, but the project is in production and I need to know if I have to fallback into something else

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC I'm sorry for not being able to reply to you these few days, because I was infected with COVID-19 these days and I just got better today. I will carefully analyze the entire issue context and mentioned content later, and then create a new example repository to reproduce this bug together.

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC I created a new warehouse to deal with this issue, and I have invited you to enter the warehouse (invitation link: https://github.com/odroe/prisma-dart-issue-74/invitations) to submit what you encountered Is there minimal code to reproduce the problem? Then I'd watch your code looking for problems.

from prisma-dart.

medz avatar medz commented on May 24, 2024

The best way is to write a simple deployment dockerfile, so that it is easier for me to grasp the running target environment information to collect problems.

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@AndryHTC I'm sorry for not being able to reply to you these few days, because I was infected with COVID-19 these days and I just got better today. I will carefully analyze the entire issue context and mentioned content later, and then create a new example repository to reproduce this bug together.

@medz you don't have to justify yourself. This is open source software you are not obligated to reply my questions 😊

So... I extremely appreciate your help, and I hope you feel better now.

Can we communicate just for this issue through an IM service? LinkedIn it's ok to me

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@AndryHTC I created a new warehouse to deal with this issue, and I have invited you to enter the warehouse (invitation link: https://github.com/odroe/prisma-dart-issue-74/invitations) to submit what you encountered Is there minimal code to reproduce the problem? Then I'd watch your code looking for problems.

I'm having some difficulty getting my minimal code published. It seems that I need to package a good chunk of the project to make it work, which can be a bit overwhelming. I'm using the Serverpod framework and have set up the infrastructure with a Terraform script on AWS. The deployment is triggered by a GitHub action that is chained to the Serverpod and AWS infrastructure secrets...

And at the end, I'm running into an issue only with the final output of these actions.

Do you have any suggestions or ideas that might help me out to provide you the minimal code to reproduce the issue?

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC I created a new warehouse to deal with this issue, and I have invited you to enter the warehouse (invitation link: https://github.com/odroe/prisma-dart-issue-74/invitations) to submit what you encountered Is there minimal code to reproduce the problem? Then I'd watch your code looking for problems.

I'm having some difficulty getting my minimal code published. It seems that I need to package a good chunk of the project to make it work, which can be a bit overwhelming. I'm using the Serverpod framework and have set up the infrastructure with a Terraform script on AWS. The deployment is triggered by a GitHub action that is chained to the Serverpod and AWS infrastructure secrets...

And at the end, I'm running into an issue only with the final output of these actions.

Do you have any suggestions or ideas that might help me out to provide you the minimal code to reproduce the issue?

My only suggestion is to use Docker to write a deployment architecture similar to your actual environment to implement reproduction. Because any runtime environment architecture can be simulated by writing a dockerfile.

This approach requires you to be familiar with Docker and to be able to write dockerize proficiently and successfully.

from prisma-dart.

medz avatar medz commented on May 24, 2024

prisma/prisma#16871 Perhaps my code downloaded the wrong binary engine on the target platform, I will update the code to find the SSL version and release a new version to verify this conjecture.

from prisma-dart.

medz avatar medz commented on May 24, 2024

prisma/prisma#16553 (comment)

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

prisma/prisma#16553 (comment)

This could be the key to everything... I'll give it a try! πŸ‘
@medz I appreciate all you efforts

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC Hey, I released 2.4.7-dev.0 refactored platform detection and published it as a separate package.

Can you try to upgrade to version 2.4.7-dev.0 to test whether it is fixed?

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

Can you try to upgrade to version 2.4.7-dev.0 to test whether it is fixed?

No joy...

prisma/prisma#16553 (comment)

This could be the key to everything... I'll give it a try! πŸ‘ @medz I appreciate all you efforts

I cannot upgrade my Amazon-Linux-2's openssl version to v.3.0.7

from prisma-dart.

medz avatar medz commented on May 24, 2024

Can you try to upgrade to version 2.4.7-dev.0 to test whether it is fixed?

No joy...

prisma/prisma#16553 (comment)

This could be the key to everything... I'll give it a try! πŸ‘ @medz I appreciate all you efforts

I cannot upgrade my Amazon-Linux-2's openssl version to v.3.0.7

It's such a pity and I feel bad for it.

I'll keep trying to find what's triggering this issue.

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

I was able to get it running in the current instance, even with version 2.4.6. I'm not sure how I managed to do it. I'm worried that if the EC2 instance is terminated and re-instantiated, the problem will occur again.

from prisma-dart.

syedzainqadri avatar syedzainqadri commented on May 24, 2024

How can i do this on a docker container. Should i just pass all of this in my CMD or As a run command i mean this does not make any clear sence to me

from prisma-dart.

syedzainqadri avatar syedzainqadri commented on May 24, 2024

I was able to get it running in the current instance, even with version 2.4.6. I'm not sure how I managed to do it. I'm worried that if the EC2 instance is terminated and re-instantiated, the problem will occur again.

can you refrence me through this as i am not able to run the prisma engine manually and it is not working by default. on my docker container.

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC @syedzainqadri @aschulz90 @jacobaraujo7 https://github.com/odroe/prisma-dart/blob/main/example/simple/Dockerfile I have solved this problem! This dockerfile is for your reference.

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@AndryHTC @syedzainqadri @aschulz90 @jacobaraujo7 https://github.com/odroe/prisma-dart/blob/main/example/simple/Dockerfile I have solved this problem! This dockerfile is for your reference.

@medz Here we are again 😒. We've managed to not touch the production code in the last 2 months but after an Instance destroy/creation here the problem is back.

The Dockerfile is not available anymore... Can you provide the info? How this applies to orm 3.3.0? What is the right time to generate the engine and the client when deploying?

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC https://github.com/odroe/prisma-dart/blob/main/example/Dockerfile I wrote a new

from prisma-dart.

medz avatar medz commented on May 24, 2024

@AndryHTC https://github.com/odroe/prisma-dart/blob/main/Dockerfile Here is a dockerfile that complements the official Dart landscape. Used to satisfy Prisma binary engine runtime dependencies in scratch.

from prisma-dart.

AndryHTC avatar AndryHTC commented on May 24, 2024

@AndryHTC https://github.com/odroe/prisma-dart/blob/main/Dockerfile Here is a dockerfile that complements the official Dart landscape. Used to satisfy Prisma binary engine runtime dependencies in scratch.

Thank you. I would like to know what are the minimum steps needed to get it working and the explanation of each one πŸ™πŸΌ

from prisma-dart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.