moqui / moqui-framework

Use Moqui Framework to build enterprise applications based on Java. It includes tools for databases (relational, graph, document), local and web services, web and other UI with screens and forms, security, file/resource access, scripts, templates, l10n, caching, logging, search, rules, workflow, multi-instance, and integration.
http://www.moqui.org
Other
279 stars 200 forks source link

Database connection errors at startup do not cause any errors #568

Closed eigood closed 1 year ago

eigood commented 1 year ago
...
Caused by: org.postgresql.util.PSQLException: Connection to moqui-postgresql:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
...
15:21:20.325  INFO         main        o.eclipse.j.s.AbstractConnector Started ServerConnector@2f16c6b3{HTTP/1.1, (http/1.1)}{0.0.0.0:80}
15:21:20.328  INFO         main                   o.eclipse.j.s.Server Started Server@3d97a632{STARTING}[10.0.9,sto=30000] @24435ms

Basically, when both postgresql and moqui are started at the same time, moqui fails to connect to the database, but then stays running. It never retries the connection. The best thing to do in this case is to exit, and let the runtime use graceful restarts(with a configurable back-off setting).

jonesde commented 1 year ago

Do you have a full startup log for that? The behavior should be that when it fails to connect to the DB it waits a few seconds and retries a few times (I don't remember the default numbers, but something like a total of 30 seconds before it gives up).

eigood commented 1 year ago

At start up, it should not wait at all, it should immediately exit. The external system that started the moqui process can then use whatever rate-limited fallback is needed to continue moving forward.

As for the startup log, I might be able to get that, I've almost got a working helm chart, and I could turn off the initContainer that is waiting for the database.

eigood commented 1 year ago

I just added an initContainer to the postgresql, to make it sleep for 10s, before continuing with it's configuration. Moqui attempts to connect 5 times. It's not 30s, it's much less.

What confuses me, tho, is the following line is sometimes printed.

15:49:54.040  INFO         main        o.eclipse.j.s.AbstractConnector Started ServerConnector@2f16c6b3{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}

I would have thought that is never printed at all if there is such a start-of-day error.

This ticket could be closed for now, I guess.