Skip to content

[Bug]: Error Executing SHOW STATS in PgBouncer #6566

Description

@akirill0v

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I think this is a new bug.

I am running a supported version of CloudNativePG

  • I have read the troubleshooting guide and I think this is a new bug.

Contact Details

[email protected]

Version

1.25 (latest patch)

What version of Kubernetes are you using?

1.29

What is your Kubernetes environment?

Cloud: Other

How did you install the operator?

YAML manifest

What happened?

After updating PgBouncer to the new version (1.24.0) using the image ghcr.io/cloudnative-pg/pgbouncer:1.24.0, I have encountered several errors related to metrics.

{"level":"error","ts":"2025-01-11T10:28:58.707682986Z","msg":"Error while executing SHOW STATS","logger":"pgbouncer-manager"
,"error":"sql: expected 23 destination arguments in Scan, not 17","stacktrace":"github.com/cloudnative-pg/machinery/pkg/log.(*logger).
Error\n\tpkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/
cloudnative-pg/pkg/management/pgbouncer/metricsserver.(*Exporter).collectShowStats\n\tpkg/management/pgbouncer/metricsserver/stats.go:
285\ngithub.com/cloudnative-pg/cloudnative-pg/pkg/management/pgbouncer/metricsserver.(*Exporter).collectPgBouncerMetrics\n\tpkg/manage
ment/pgbouncer/metricsserver/pgbouncer_collector.go:144\ngithub.com/cloudnative-pg/cloudnative-pg/pkg/management/pgbouncer/metricsserv
er.(*Exporter).Collect\n\tpkg/management/pgbouncer/metricsserver/pgbouncer_collector.go:119\ngithub.com/prometheus/client_golang/prome
theus.(*Registry).Gather.func1\n\tpkg/mod/github.com/prometheus/[email protected]/prometheus/registry.go:456"}

When executing the SHOW STATS command in PgBouncer, an error occurs indicating a mismatch between the expected number of columns and the actual output. The error message is as follows:

Error while executing SHOW STATS: sql: expected 23 destination arguments in Scan, not 17

This suggests that the code responsible for processing the results of the SHOW STATS command is not aligned with the actual structure of the output.

The same issue occurs when executing the SHOW POOLS command.

Details

The SHOW STATS command currently returns a set of statistics that includes various metrics about database connections and queries. However, it appears that the implementation in the codebase at stats.go is expecting a different number of columns than what is being returned.

The output from the SHOW STATS command is as follows:

-[ RECORD 1 ]-----------------+----------
database                      | my_database
total_server_assignment_count | 26
total_xact_count              | 7180
total_query_count             | 7180
total_received                | 1458529
total_sent                    | 8538725
total_xact_time               | 2190046
total_query_time              | 2190046
total_wait_time               | 282832
total_client_parse_count      | 0
total_server_parse_count      | 0
total_bind_count              | 0
avg_server_assignment_count   | 0
avg_xact_count                | 0
avg_query_count               | 0
avg_recv                      | 0
avg_sent                      | 0
avg_xact_time                 | 0
avg_query_time                | 0
avg_wait_time                 | 0
avg_client_parse_count        | 0
avg_server_parse_count        | 0
avg_bind_count                | 0

Expected Behavior

The code should correctly handle and parse all columns returned by the SHOW STATS command without throwing an error. The discrepancy indicates that either the PgBouncer version has changed the output format or there is an oversight in the metrics server's implementation.

Cluster resource

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    triage
    on Jan 11, 2025
  2. assigned and unassigned on Jan 11, 2025
  3. removed
    triage
    on Jan 11, 2025
  4. sxd commented on Jan 11, 2025

    @sxd
    Contributor

    Hi @akirill0v

    Thanks for reporting this, we're waiting for the tests to run about these to get a full result, but your report seems fair and related to this new feature in the version 1.24.0 pgbouncer/pgbouncer#1192 this may need a patch to support the version before merging.

    Regards,

  5. added
    bug 🐛
    on Jan 11, 2025
  6. added this to the 1.25.1 milestone on Jan 11, 2025
  7. added 2 commits that reference this issue on Jan 19, 2025
    1889b66
    dbdfe0b
  8. moved this from In Development to Waiting for First Review in CloudNativePG operator developmenton Jan 23, 2025
  9. added 2 commits that reference this issue on Jan 25, 2025
    04c3566
    08546ad
  10. moved this from Waiting for First Review to Done in CloudNativePG operator developmenton Jan 29, 2025
  11. added 3 commits that reference this issue on Jan 29, 2025
    b9b1018
    2c4ad4b
    5491e93
  12. added a commit that references this issue on Jan 29, 2025
    762c282
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions