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

Fix slog log prefix for peers #922

Merged
merged 1 commit into from Aug 16, 2023
Merged

Conversation

JelteF
Copy link
Member

@JelteF JelteF commented Aug 15, 2023

After setting up peering on a PgBouncer setup that had with log_connections
and log_disconnections enabled I saw some strange logs with empty database
names:

2023-08-15 12:51:08.205 CEST [333901] LOG S-0x55a7b1748950: /(nouser)@unix:6432 closing because: successfully sent cancel request (age=0s)
2023-08-15 12:51:08.205 CEST [333901] LOG C-0x55a7b173b300: /(nouser)@127.0.0.1:43772 closing because: successfully sent cancel request (age=0s)

This was because the database name for peers databases is all \0 bytes. This
changes our log prefix callback to include the peerid instead like this for
peer databases:

2023-08-15 13:04:52.504 CEST [337755] LOG S-0x555bfbf19950: peer-20@unix:6432 closing because: successfully sent cancel request (age=0s)
2023-08-15 13:04:52.504 CEST [337755] LOG C-0x555bfbf0c300: peer-20@127.0.0.1:40792 closing because: successfully sent cancel request (age=0s)

@eulerto
Copy link
Member

eulerto commented Aug 15, 2023

There are empty lines inside the ifs. Other than that, LGTM.

After setting up peering on a setup that had with `log_connections` and
`log_disconnections` enabled I saw some strange logs with empty database
names:

```
2023-08-15 12:51:08.205 CEST [333901] LOG S-0x55a7b1748950: /(nouser)@unix:6432 closing because: successfully sent cancel request (age=0s)
2023-08-15 12:51:08.205 CEST [333901] LOG C-0x55a7b173b300: /(nouser)@127.0.0.1:43772 closing because: successfully sent cancel request (age=0s)
```

This was because the database name for peers databases is all `\0`
bytes. This changes our log prefix callback to include the peerid
instead like this for peer databases:

```
2023-08-15 13:04:52.504 CEST [337755] LOG S-0x555bfbf19950: peer-20@unix:6432 closing because: successfully sent cancel request (age=0s)
2023-08-15 13:04:52.504 CEST [337755] LOG C-0x555bfbf0c300: peer-20@127.0.0.1:40792 closing because: successfully sent cancel request (age=0s)
```
@JelteF JelteF merged commit 1136186 into pgbouncer:master Aug 16, 2023
0 of 23 checks passed
@JelteF JelteF deleted the peer-slog-fix branch August 16, 2023 06:24
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.

None yet

2 participants