plankanban / planka

The realtime kanban board for workgroups built with React and Redux.
https://planka.app
GNU Affero General Public License v3.0
7.82k stars 727 forks source link

Escaping characters in database url variable #698

Open kalxasus opened 5 months ago

kalxasus commented 5 months ago

I trying run planka with variable:

DATABASE_URL=postgresql://planka:aeN=oongee\T8gie@172.172.172.222:5432/planka

And on start get this error:

2024-04-11 06:45:16 [E] A hook (`orm`) failed to load!
2024-04-11 06:45:16 [E] Failed to lift app: `getConnection` failed ("failed").  Could not acquire a connection to the database using the specified manager.
Additional data:

{
  error: Error: connect ECONNREFUSED 172.31.0.2:5432
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '172.31.0.2',
    port: 5432
  },
  meta: undefined
}
2024-04-11 06:45:16 [E] More details (raw):

I was confusing by this message, why his try connect to internal container IP address. And in a same time on every try starting container, in postgresql created db structure and seen error in postgresql log: ERROR: conflicting key value violates exclusion constraint "user_email_unique"

when service try to create admin user in DB.

I spent a lot of time, to try run service via helm or docker-compose before I understood that problem in character \ in connection password.

meltyshev commented 5 months ago

Hi! Thanks for reporting this.

I don't understand how to fix this yet, it seems that the adapter doesn't connect if there is a backslash in DATABASE_URL (even if escaped), for some reason it automatically replaces it with a normal slash when connecting. The only way to get around this quickly is to not use them in DATABASE_URL.

And in a same time on every try starting container, in postgresql created db structure and seen error in postgresql log: ERROR: conflicting key value violates exclusion constraint "user_email_unique" when service try to create admin user in DB.

This is the correct behavior, it tries to create an administrator on startup every time (in case it's suddenly deleted). Seems like we should hide this message because it's confusing.

gelomon commented 1 month ago

I have been experiencing this issue and what I have done is to adjust the postgres healthcheck from 10s to 20s to give additional time.

With original values, my instance is logging this same issue ECONNREFUSED , but the difference is I am using docker