Skip to content

Fix slog log prefix for peers#922

Merged
JelteF merged 1 commit intopgbouncer:masterfrom
JelteF:peer-slog-fix
Aug 16, 2023
Merged

Fix slog log prefix for peers#922
JelteF merged 1 commit intopgbouncer:masterfrom
JelteF:peer-slog-fix

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
@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.

2 participants