Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: DB Connect Error #6878

Closed
2 of 4 tasks
chenxv399 opened this issue Dec 11, 2024 · 2 comments
Closed
2 of 4 tasks

bug: DB Connect Error #6878

chenxv399 opened this issue Dec 11, 2024 · 2 comments
Labels
bug Something isn't working pending-verification Something is still under investigation

Comments

@chenxv399
Copy link

Describe the bug

When deploying logto using docker according to the official documentation, the container reports “timeout expired” and exits abnormally.

Expected behavior

Logto should start successfully and connect to the PostgreSQL database without timing out.

How to reproduce?

The problem started when I wanted to deploy logto via 1panel, and the problem occurred after doing so by default. The container log reported the following error:

> cli
> logto db seed --swe

- Create tables
info ✔ Create tables
info ✔ [default] Generated config oidc.privateKeys
info ✔ [default] Generated config oidc.cookieKeys
info ✔ [default] Seed OIDC config
info ✔ [admin] Generated config oidc.privateKeys
info ✔ [admin] Generated config oidc.cookieKeys
info ✔ [admin] Seed OIDC config
info ✔ Cloud Service Application successfully created for: default
info ✔ Created machine-to-machine applications for Management API proxy
info ✔ Initialized tenant organization template
info ✔ Assigned the proxy roles to the applications
info ✔ Created tenant organizations
info ✔ Seed data
npm notice
npm notice New minor version of npm available! 10.8.2 -> 10.9.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.9.2
npm notice To update run: npm install -g [email protected]
npm notice

> start
> cd packages/core && NODE_ENV=production node .

(node:44) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
index    error Error while initializing app:
index    error Error: timeout expired
    at Timeout._onTimeout (/etc/logto/node_modules/.pnpm/[email protected]/node_modules/pg/lib/client.js:106:28)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

After this, I tried to re-deploy according to the official documentation. I tried deploying via docker, deploying via docker-compose, and deploying via npm-init, but the same problem happened in all three cases. I even tried different versions of the database, including pgSQL14, pgSQL16 and pgSQL17 containers, but none of them worked and the same problem happened again.

I then tried the solution provided by others in #6748, but it still didn't work. I also checked #6187 and PR #6674, but I don't seem to understand them very well.

Up to this point, I had exhausted everything I could think of, but the problem remained unsolved.

Context

  • Logto Cloud
  • Self-hosted, Logto version = 1.22.0
    • Container (Docker image)
    • Raw Node.js
@chenxv399 chenxv399 added the bug Something isn't working label Dec 11, 2024
@charIeszhao
Copy link
Member

charIeszhao commented Dec 12, 2024

Hi. I think you actually found the answer yourself. We've had several similar cases before and it was due to a low connection speed between the web application / CLI client / 1panel platform and the postgres DB, as by default we have the DB connection timeout set to 5000ms.

Therefore, try to set a bigger timeout value by specifying the DATABASE_CONNECTION_TIMEOUT env variable when deploying Logto.

@charIeszhao charIeszhao added the pending-verification Something is still under investigation label Dec 12, 2024
@chenxv399
Copy link
Author

Hi @charIeszhao , thank you for your help. The problem has been solved.
After trying, the problem was solved when the value of DATABASE_CONNECTION_TIMEOUT was set to 30000. And for those who are experiencing the same problem after using the 1panel to deploy “one-click”, this method can be used to resolve the issue.
This issue can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-verification Something is still under investigation
Development

No branches or pull requests

2 participants