yandex / odyssey

Scalable PostgreSQL connection pooler
BSD 3-Clause "New" or "Revised" License
3.21k stars 164 forks source link

Wrong database/user names in statistics output #403

Open Firm opened 2 years ago

Firm commented 2 years ago

It seems that statistics being logged into console/file shows backend database/user names instead of frontend. Consider this config:

database "mydb" {
  user "myuser" {
    ...
  }
  user "myuser_ro" {
    storage_user "myuser"
    ...
  }
}
database "mydb_ro" {
  user "myuser" {
    storage_db "mydb"
    ...
  }
}
database "mydb_cron" {
  user "myuser" {
    storage_db "mydb"
    ...
  }
  user "myuser_ro" {
    storage_user "myuser"
    storage_db "mydb"
    ...
  }
}

When running show clients query one could see all defined virtual users and databases in output. But show pools and show stats show only "mydb" and "myuser" related-data, like multiple lines with "mydb" and "myuser".

Even more, stats output in /var/log/odyssey.log has the same issue: multiple lines with "mydb"."myuser" data:

1300 2022-01-19T12:17:46Z info [none none] (stats) [mydb.myuser] 27 clients, 3 active servers, 1 idle servers, 1 transactions/sec (1045 usec) 2 queries/sec (353 usec) 1095 in bytes/sec, 476 out bytes/sec
1300 2022-01-19T12:17:46Z info [none none] (stats) [mydb.myuser] 15 clients, 15 active servers, 0 idle servers, 2 transactions/sec (638 usec) 2 queries/sec (638 usec) 369 in bytes/sec, 341 out bytes/sec
1300 2022-01-19T12:17:46Z info [none none] (stats) [mydb.myuser] 1 clients, 0 active servers, 1 idle servers, 0 transactions/sec (3233 usec) 0 queries/sec (3233 usec) 355 in bytes/sec, 569 out bytes/sec
1300 2022-01-19T12:17:46Z info [none none] (stats) [mydb.myuser] 60 clients, 0 active servers, 2 idle servers, 13 transactions/sec (534 usec) 13 queries/sec (534 usec) 1915 in bytes/sec, 1991 out bytes/sec

They're definitely different "frontend" database/user names from config (which are mapped to single pair of "mydb"/"myuser" when communicating with different backends).

uspen commented 2 years ago

We also encountered this after switching from pgbouncer about 2 years ago

uspen commented 2 years ago

up