Skip to content

Fix dirtsand starting with dead auth daemon.#207

Merged
zrax merged 1 commit into
H-uru:masterfrom
Hoikas:dead_auth_daemon
Mar 3, 2026
Merged

Fix dirtsand starting with dead auth daemon.#207
zrax merged 1 commit into
H-uru:masterfrom
Hoikas:dead_auth_daemon

Conversation

@Hoikas

@Hoikas Hoikas commented Mar 2, 2026

Copy link
Copy Markdown
Member

Currently, if DirtSand starts and the auth daemon cannot connect to PostgreSQL, the auth daemon thread exits immediately but the server remains up. This leads to a situation where clients can patch but when they attempt to actually log in, they never get a response because the auth daemon never actually started.

There are basically two ways to fix this. One way is to kill the whole process if the database isn't up. This would be workable, but the design of the system doesn't really support the individual daemons communicating back to the DirtSand process itself, except via hacks like exit(1). Instead, I've opted to allow the auth daemon to try deferring initializaion. This allows us to centralize the database connection reset logic and remove all of the manual check_postgres() calls.

Currently, if DirtSand starts and the auth daemon cannot connect to
PostgreSQL, the auth daemon thread exits immediately but the server
remains up. This leads to a situation where clients can patch but when
they attempt to actually log in, they never get a response because the
auth daemon never actually started.

There are basically two ways to fix this. One way is to kill the whole
process if the database isn't up. This would be workable, but the design
of the system doesn't really support the individual daemons
communicating back to the DirtSand process itself, except via hacks like
`exit(1)`. Instead, I've opted to allow the auth daemon to try deferring
initializaion. This allows us to centralize the database connection
reset logic and remove all of the manual `check_postgres()` calls.
@Hoikas Hoikas force-pushed the dead_auth_daemon branch from e9f3007 to de52b32 Compare March 2, 2026 16:39
@Hoikas Hoikas marked this pull request as ready for review March 2, 2026 16:41
Comment thread AuthServ/AuthDaemon.cpp
ST::printf(stderr, "Error connecting to postgres: {}", PQerrorMessage(s_postgres));

// If the connection to postgres was successful, initialize the vault here.
dm_authCheck(false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still probably room for improvement here -- for example, if we failed due to an invalid DB config rather than a server issue, we'll just keep spitting out errors on every incoming message and hope the user eventually notices :). But not dropping the thread and continuing silently is a definite improvement, so +1 from me.

@zrax zrax merged commit b3331d2 into H-uru:master Mar 3, 2026
4 checks passed
@Hoikas Hoikas deleted the dead_auth_daemon branch March 3, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants