Skip to content

fix(common.postgresql): Skip connection liveness ping for PgBouncer - #19258

Merged
skartikey merged 2 commits into
influxdata:masterfrom
skartikey:pgbouncer_issue_19252
Jul 16, 2026
Merged

skartikey merged 2 commits into
influxdata:masterfrom
skartikey:pgbouncer_issue_19252

Conversation

@skartikey

@skartikey skartikey commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Since the pgx v5 bump (#18587, v1.38.2) the driver executes "-- ping" before reusing a connection idle for more than one second. PgBouncer's admin console cannot parse this query, so every gather cycle floods the PgBouncer log with "invalid command" errors and the failed ping forces a reconnect.

Skip the ping for admin console connections via the driver's OptionShouldPing hook. This requires creating the database handle from a connector instead of a registered DSN, which as a side effect no longer leaks a driver-registry entry per plugin initialization.

The skip must not reach anything else, which the shared IsPgBouncer flag could not express: inputs.postgresql and inputs.postgresql_extensible also set it whenever prepared_statements is disabled, i.e. for a real PostgreSQL behind a PgBouncer in transaction mode, which parses "-- ping" fine and needs the liveness check. IsPgBouncer now marks the admin console only, with prepared statements moved to a separate SimpleProtocol flag.

Integration tests cover both sides: the PgBouncer one fails without the fix with the log lines from the issue, the PostgreSQL one asserts the ping survives disabling prepared statements.

Checklist

Related issues

resolves #19252

@telegraf-tiger telegraf-tiger Bot added area/postgresql fix pr to fix corresponding bug labels Jul 13, 2026
@skartikey skartikey self-assigned this Jul 13, 2026
…admin console

The IsPgBouncer flag is also set by the postgresql and postgresql_extensible
plugins whenever prepared_statements is disabled, which is the documented
setting for reaching a server through a PgBouncer with pool_mode set to
transaction. Those connections talk to a real PostgreSQL that parses the
"-- ping" liveness query fine, so skipping the ping there only drops the
liveness check without fixing anything.

Let IsPgBouncer mark the admin console only and move the prepared-statement
handling to a separate SimpleProtocol flag. Cover the PostgreSQL side with an
integration test asserting that disabling prepared statements keeps the ping.
@telegraf-tiger

Copy link
Copy Markdown
Contributor

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job @skartikey! Approving it, so feel free to merge it if testing succeeds without any change to the code...

@skartikey
skartikey merged commit c9d330a into influxdata:master Jul 16, 2026
29 checks passed
srebhan pushed a commit that referenced this pull request Jul 20, 2026
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
telegraf 1.39.2

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## v1.39.2 [2026-07-20]

### Bugfixes

- [#19050](influxdata/telegraf#19050) `disk-buffer` Cache length when closing buffer to avoid panic with --once
- [#19258](influxdata/telegraf#19258) `common.postgresql` Skip connection liveness ping for PgBouncer
- [#19218](influxdata/telegraf#19218) `inputs.azure_monitor` Defer target validation to startup
- [#19223](influxdata/telegraf#19223) `inputs.chrony` Apply read timeout so lost responses do not block collection
- [#19244](influxdata/telegraf#19244) `inputs.elasticsearch_query` Release client on startup failure
- [#19206](influxdata/telegraf#19206) `inputs.jti_openconfig_telemetry` Remove duplicate sensors key
- [#19295](influxdata/telegraf#19295) `inputs.redfish` Add URL and content type to JSON parse error
- [#19254](influxdata/telegraf#19254) `inputs.sql` Respect timeout for unprepared query fallback
- [#19217](influxdata/telegraf#19217) `outputs.opentelemetry` Install gRPC proxy dialer only when enabled
- [#19222](influxdata/telegraf#19222) `parsers.json_v2` Reset sub-path results for each object config
- [#19293](influxdata/telegraf#19293) `secretstores.vault` Preserve sibling keys when setting a secret

### Dependency Updates

- [#19278](influxdata/telegraf#19278) `deps` Bump cloud.google.com/go/auth from 0.20.0 to 0.22.0
- [#19276](influxdata/telegraf#19276) `deps` Bump cloud.google.com/go/bigquery from 1.77.0 to 1.79.0
- [#19277](influxdata/telegraf#19277) `deps` Bump cloud.google.com/go/monitoring from 1.29.0 to 1.30.0
- [#19281](influxdata/telegraf#19281) `deps` Bump cloud.google.com/go/pubsub/v2 from 2.6.0 to 2.6.1
- [#19179](influxdata/telegraf#19179) `deps` Bump cloud.google.com/go/storage from 1.62.3 to 1.63.0
- [#19272](influxdata/telegraf#19272) `deps` Bump cloud.google.com/go/storage from 1.63.0 to 1.63.1
- [#19175](influxdata/telegraf#19175) `deps` Bump github.com/ClickHouse/clickhouse-go/v2 from 2.46.0 to 2.47.0
- [#19284](influxdata/telegraf#19284) `deps` Bump github.com/IBM/sarama from 1.50.3 to 1.60.0
- [#19274](influxdata/telegraf#19274) `deps` Bump github.com/apache/thrift from 0.23.1-0.20260429145742-d2acd3c49e58 to 0.24.0
- [#19180](influxdata/telegraf#19180) `deps` Bump github.com/aws/smithy-go from 1.27.2 to 1.27.3
- [#19227](influxdata/telegraf#19227) `deps` Bump github.com/emiago/sipgo from 1.4.0 to 1.4.3
- [#19236](influxdata/telegraf#19236) `deps` Bump github.com/google/cel-go from 0.28.1 to 0.29.1
- [#19268](influxdata/telegraf#19268) `deps` Bump github.com/google/cel-go from 0.29.1 to 0.29.2
- [#19229](influxdata/telegraf#19229) `deps` Bump github.com/gopacket/gopacket from 1.6.1 to 1.7.0
- [#19176](influxdata/telegraf#19176) `deps` Bump github.com/gophercloud/gophercloud/v2 from 2.12.0 to 2.13.0
- [#19265](influxdata/telegraf#19265) `deps` Bump github.com/hashicorp/consul/api from 1.34.3 to 1.34.4
- [#19264](influxdata/telegraf#19264) `deps` Bump github.com/jaypipes/ghw from 0.24.0 to 0.25.0
- [#19237](influxdata/telegraf#19237) `deps` Bump github.com/jedib0t/go-pretty/v6 from 6.8.1 to 6.8.2
- [#19234](influxdata/telegraf#19234) `deps` Bump github.com/klauspost/compress from 1.18.6 to 1.19.0
- [#19261](influxdata/telegraf#19261) `deps` Bump github.com/leodido/go-syslog/v4 from 4.5.0 to 4.6.0
- [#19181](influxdata/telegraf#19181) `deps` Bump github.com/nats-io/nats-server/v2 from 2.14.2 to 2.14.3
- [#19239](influxdata/telegraf#19239) `deps` Bump github.com/pborman/ansi from 1.1.0 to 1.2.0
- [#19269](influxdata/telegraf#19269) `deps` Bump github.com/pborman/ansi from 1.2.0 to 1.3.0
- [#19228](influxdata/telegraf#19228) `deps` Bump github.com/pion/dtls/v3 from 3.1.4 to 3.1.5
- [#19174](influxdata/telegraf#19174) `deps` Bump github.com/prometheus-community/pro-bing from 0.9.0 to 0.9.1
- [#19275](influxdata/telegraf#19275) `deps` Bump github.com/prometheus/common from 0.69.0 to 0.70.0
- [#19178](influxdata/telegraf#19178) `deps` Bump github.com/prometheus/procfs from 0.20.1 to 0.21.0
- [#19238](influxdata/telegraf#19238) `deps` Bump github.com/prometheus/procfs from 0.21.0 to 0.21.1
- [#19233](influxdata/telegraf#19233) `deps` Bump github.com/prometheus/prometheus from 0.312.0 to 0.313.0
- [#19263](influxdata/telegraf#19263) `deps` Bump github.com/prometheus/prometheus from 0.313.0 to 0.313.1
- [#19230](influxdata/telegraf#19230) `deps` Bump github.com/shirou/gopsutil/v4 from 4.26.5 to 4.26.6
- [#19266](influxdata/telegraf#19266) `deps` Bump github.com/vertica/vertica-sql-go from 1.3.6 to 1.3.7
- [#19177](influxdata/telegraf#19177) `deps` Bump github.com/vmware/govmomi from 0.54.1 to 0.55.0
- [#19232](influxdata/telegraf#19232) `deps` Bump github.com/vmware/govmomi from 0.55.0 to 0.55.1
- [#19267](influxdata/telegraf#19267) `deps` Bump github.com/yuin/goldmark from 1.8.2 to 1.8.4
- [#19183](influxdata/telegraf#19183) `deps` Bump go.opentelemetry.io/collector/pdata from 1.60.0 to 1.61.0
- [#19279](influxdata/telegraf#19279) `deps` Bump go.opentelemetry.io/collector/pdata from 1.61.0 to 1.62.0
- [#19184](influxdata/telegraf#19184) `deps` Bump go.step.sm/crypto from 0.83.0 to 0.84.1
- [#19273](influxdata/telegraf#19273) `deps` Bump golang.org/x/crypto from 0.53.0 to 0.54.0
- [#19114](influxdata/telegraf#19114) `deps` Bump golang.org/x/net from 0.55.0 to 0.56.0
- [#19262](influxdata/telegraf#19262) `deps` Bump golang.org/x/sync from 0.21.0 to 0.22.0
- [#19270](influxdata/telegraf#19270) `deps` Bump golang.org/x/term from 0.44.0 to 0.45.0
- [#19226](influxdata/telegraf#19226) `deps` Bump golang.org/x/text from 0.38.0 to 0.39.0
- [#19173](influxdata/telegraf#19173) `deps` Bump golang.org/x/tools from 0.46.0 to 0.47.0
- [#19282](influxdata/telegraf#19282) `deps` Bump golang.org/x/tools from 0.47.0 to 0.48.0
- [#19235](influxdata/telegraf#19235) `deps` Bump google.golang.org/api from 0.286.0 to 0.287.0
- [#19280](influxdata/telegraf#19280) `deps` Bump google.golang.org/api from 0.287.1 to 0.288.0
- [#19231](influxdata/telegraf#19231) `deps` Bump google.golang.org/grpc from 1.81.1 to 1.82.0
- [#19182](influxdata/telegraf#19182) `deps` Bump software.sslmate.com/src/go-pkcs12 from 0.7.2 to 0.7.3
- [#19171](influxdata/telegraf#19171) `deps` Bump srebhan/label-milestone-action from 1.1.0 to 1.1.1
- [#19172](influxdata/telegraf#19172) `deps` Bump the aws-sdk-go-v2 group across 1 directory with 9 updates
- [#19225](influxdata/telegraf#19225) `deps` Bump the aws-sdk-go-v2 group with 11 updates
- [#19260](influxdata/telegraf#19260) `deps` Bump the aws-sdk-go-v2 group with 9 updates

### Packages

Arch | Platform | Package | SHA256
---| --- | --- | ---
arm64 | CentOS | [telegraf-1.39.2-1.aarch64.rpm](https://dl.influxdata.com/telegraf/releases/telegraf-1.39.2-1.aarch64.rpm) | ce421d564fe9ad546dd21f63f83272c84f17cfcd46f0993938be5b16af4acedd
armel | CentOS | [telegraf-1.39.2-1.armel.rpm](https://dl.influxdata.com/telegraf/releases/telegraf-1.39.2-1.armel.rpm) | 970292eec5dd14017c4c69271875efc363b46c174c08c88fb5b6510cd8be5656
armv6hl | CentOS | [telegraf-1.39.2-1.armv6hl.rpm](https://dl.influxdata.com/telegraf/releases/telegraf-1.39.2-1.armv6hl.rpm) | bc8a9044e2c68e69ff2ec8541b5affe2a4bb3ea5755816f164dd1a155c6f0f12
i386 | CentOS | [telegraf-1.39.2-1.i386.rpm](https://dl.influxdata.com/telegraf/releases/telegraf-1.39.2-1.i386.rpm) | 0ba3cbd579d238272bf39f55fe5f892b7d20cd1e162482641add138da89e39c4
unknown | CentOS | [telegraf-1.39.2-1.loongarch64.rpm](https://dl.influxdata.com/telegraf/releases/telegraf-1.39.2-1.loongarch64.rpm) | 2c11e401f7fefa377a4d3c5f9fc0bd50a2beb4bbd6173cf63582137a2d43ebdd
ppc64le | CentOS | [telegraf-1.39.2-1.ppc64le.rpm](https://dl.influxdata.com/telegraf/releases/telegraf-1.39.2-1.ppc64le.rpm) | 579e252b8c5eae751db87ee4262fe6969868e445481be21d1b98a94232fde6e0
riscv64 | CentOS | [telegraf-1.39.2-1.riscv64.rpm](https://dl.influxdata.com/telegraf/releases/telegraf-1.39.2-1.riscv64.rpm) | d0b15611e969532fe470580302c2a57dae874b302e39520da1b50cd137120004
s390x | CentOS | [telegraf-1.39.2-1.s390x.rpm](https://dl.influxdata.com/telegraf/releases/telegraf-1.39.2-1.s390x.rpm) | a0ac777a7013242ec658d3540b58891ad2b8375614abc21918d8c2eaabb57778
amd64 | CentOS | [telegraf-1.39.2-1.x86_64.rpm](https://dl.influxdata.com/telegraf/releases/telegraf-1.39.2-1.x86_64.rpm) | 8ff1be8f87d0388c09ee019ca6ddbda2b23fe0701088928c038f4f908c885e01
amd64 | m

See merge request: Harmonybrew/homebrew-core!14727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/postgresql fix pr to fix corresponding bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inputs.pgbouncer floods with "ERROR invalid command '-- ping'" to pgbouncer.log

2 participants