Skip to content

Improve fatal messages in disconnect_server and disconnect_client - #1382

Merged
JelteF merged 2 commits into
pgbouncer:masterfrom
JelteF:more-helpful-fatal-messages
Aug 28, 2025
Merged

JelteF merged 2 commits into
pgbouncer:masterfrom
JelteF:more-helpful-fatal-messages

Conversation

@JelteF

@JelteF JelteF commented Aug 27, 2025

Copy link
Copy Markdown
Member

These functions are called from many places so it's hard to figure out what might have caused an issue with an unexpected state. This helps narrowing that down by including the provided reason in the fatal message.

Related to #1376

These functions are called from many places so it's hard to figure out
what might have caused an issue with an unexpected state. This helps
narrowing that down by including the provided reason in the fatal
message.
@eulerto

eulerto commented Aug 27, 2025

Copy link
Copy Markdown
Member

There is one case (see client_proto()) that disconnect_client() is called with reason equals to NULL.

Some fatal() messages provide a function name. It might be a good idea to have it because this "bad client state" message isn't unique.

Since you are working on this area, I suggest that you also do the same for "bad server state" messages. We already had bugs in this area (see #927 , #928).

@JelteF

JelteF commented Aug 27, 2025 •

Copy link
Copy Markdown
Member Author

There is one case (see client_proto()) that disconnect_client() is called with reason equals to NULL.

Oops, yeah fixed now.

Regarding the function name in the fatal log messages. That's already happening, see the original bug report (it even includes the line number): #1376

That's because the fatal definition is like this:

/** Log and die.  It also logs source location */
#define fatal(...) do { LOG_CONTEXT_DEF; \
			log_fatal(__FILE__, __LINE__, __func__, false, LOG_CONTEXT, __VA_ARGS__); \
			exit(1); } while (0)

@JelteF
JelteF merged commit 7fbda57 into pgbouncer:master Aug 28, 2025
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