github nbari/pg_exporter 0.22.3

2 hours ago

Fixed

  • pg_replication_slots_pg_wal_lsn_diff reported 0 for every slot and
    pg_stat_replication_reply_time reported 0 for every standby on PostgreSQL 14+.
    Both values are numeric in PostgreSQL and were read as f64 without a cast; the
    failed decode was swallowed and replaced by 0, so the documented WAL-retention alert
    could never fire. Both are now cast to double precision, and a decode failure fails
    the collector instead of publishing 0. A slot without reserved WAL and a standby
    that has not replied yet still report 0.
  • pg_wait_event_type under-reported any type with more than one distinct wait event.
    The query returns one row per (type, event) and each row overwrote the gauge, so
    three sessions waiting on Lock/relation and one on Lock/transactionid
    exported pg_wait_event_type{type="Lock"} 1 instead of 4. Counts are now summed
    per type. pg_wait_event is summed the same way for an event name that exists
    under two types (SyncRep).
  • A PostgreSQL major upgrade under a running exporter no longer needs an exporter
    restart. The server version was detected once per process, so version-gated
    collectors kept using the old server's SQL: after a 17 to 18 upgrade
    --collector.stat_io failed every scrape with column "op_bytes" does not exist
    (503), and after a 16 to 17 upgrade pg_stat_checkpointer_* stayed absent. The
    version is now read on every scrape, in the same round trip as the connectivity
    check (SHOW server_version_num replaces SELECT 1), and a change is logged.
  • After a PostgreSQL restart or failover, scrapes no longer report pg_up 0 while the
    server is already accepting connections. Pooled connections were handed out without
    validation, so each scrape drew one dead connection, failed its connectivity check,
    and discarded it: up to one false outage per pooled connection (three). The
    validation had been disabled together with a recovery pool that was later removed.
    Idle connections are now checked on checkout and replaced within the same acquire,
    at the cost of one extra round trip per checkout.
  • --collector.statements no longer fails every scrape when pg_stat_statements
    disappears under a running exporter (DROP EXTENSION, or a cut-over to a server
    where it was never created). The collector cached "installed" without rechecking,
    so its query failed with function pg_stat_statements(boolean) does not exist and
    the whole scrape returned 503 until restart. It now skips, clears its series, and
    probes for the extension again after a minute.
  • A table whose reloptions set both autovacuum_vacuum_threshold and
    autovacuum_vacuum_scale_factor (or the analyze pair) to 0 made the stat collector
    query fail with division by zero. Every pg_stat_user_tables_* series of that
    database disappeared, and the scrape returned 503 when every database had such a
    table. The divisor is now guarded. Such a table reports its dead (or modified) tuple
    count as the ratio, so any pending work reads as at or past the threshold.
  • pg_version_info reported a version PostgreSQL does not use: short_version was
    padded to three parts, so a 18.6 server showed as 18.6.0 in the dashboard's
    Version panel (#42). The label is now major.minor (18.6), taken from
    server_version_num. A pre-release such as 19beta1 reports 19.0; the full
    string stays in the version label. A rule that matches the three-part form
    exactly, such as short_version="18.6.0", must be updated
    ; matches on the
    major (short_version=~"18\\..*") keep working. The dashboard also trims the old
    padding itself, so it shows 18.6 against an exporter older than this release.
    The collector no longer runs SELECT version() twice per scrape.

Security

  • --help and -h no longer print the value of PG_EXPORTER_DSN. With a password
    embedded in the DSN, help output showed it in clear text
    ([env: PG_EXPORTER_DSN=postgresql://user:password@...]); it now shows only the
    variable name.
  • Refresh dependencies to clear the security audit: libz-sys 1.1.33
    (RUSTSEC-2026-0418, RUSTSEC-2026-0544), url 2.5.9 (RUSTSEC-2026-0592), and
    libsqlite3-sys 0.40.0 (RUSTSEC-2026-0459). None was reachable from the shipped
    binary: libz-sys is a build-time dependency, libsqlite3-sys is only named in the
    lockfile, and the affected Url::origin() is never called.

Changed

  • Update SQLx to 0.9.1, which sets TCP_NODELAY on PostgreSQL sockets again. SQLx
    0.9.0 dropped it, adding a ~40 ms stall to every new TLS connection; the
    multi-database collectors (stat, index, sequences) open one connection per
    database, so the cost grew with the database count. A TLS scrape of 50 databases
    went from about 4.0 s to 0.7 s; plaintext connections were not affected. The same
    release fixes a TLS close that could wait on the server indefinitely and a pool
    idle-counter underflow.

  • SQLx 0.9.1 changes three connection behaviours:

    • The TLS configuration is built once per process instead of once per connection.
      Rotated sslrootcert, sslcert, or sslkey files are picked up after an
      exporter restart, no longer on the next connection.
    • hostaddr no longer replaces host. With both set, host is used for TLS
      server-name verification and .pgpass lookup, and hostaddr only for the TCP
      connection.
    • PGHOSTADDR is applied even when the DSN names a host.

    The --collector.system remote-database startup warning follows hostaddr as
    well, so host=localhost&hostaddr=10.0.0.5 is still recognised as remote. It also
    recognises a bracketed IPv6 loopback host ([::1]) as local.

  • Refresh the remaining compatible dependencies, including clap 4.6.10, tonic 0.14.9,
    and hyper 1.13.0.

  • Replace chrono with jiff for the certificate-expiry arithmetic in the tls
    collector, the only place a date-time crate is used. chrono is flagged as
    unmaintained (RUSTSEC-2026-0543) and is no longer compiled into the binary; jiff is
    built without its time zone database, since only UTC instants are needed. chrono
    still appears in Cargo.lock as an optional dependency of SQLx, so cargo audit
    keeps listing that warning.

  • Use Option::map_or_default where Rust 1.100 Clippy now requires it.

  • Releases now go through one workflow run that builds the commit CI already tested;
    see RELEASING.md. just release replaces just deploy, and pushing a
    tag no longer starts anything: the tag is created by publishing the GitHub release,
    after every build succeeded. just bump moves to the work branch and no longer
    pushes. What this changes for users of a release:

    • Release files gain SHA256SUMS, the .crate, and a build-provenance attestation
      for every file and for the container image.
    • The container image is made from the same two binaries as the release archives
      (the new prebuilt stage of the Containerfile) instead of being compiled a
      second time under emulation. Building the Containerfile yourself is unchanged.
    • The crate is published with crates.io Trusted Publishing instead of a stored token.
  • CI now also builds the aarch64 binary, the .deb and .rpm and the two-platform
    container image (which it runs), and runs cargo package and a publish dry run on
    every push. It reports one aggregate CI OK check.

  • Every GitHub Action is pinned to a commit and the Rust toolchain is installed with
    rustup directly instead of a third-party action. Dependabot proposes action, crate
    and Dev Container updates as pull requests into sandbox.

Tests

  • Add PostgreSQL 19 to the CI matrix and to just test-all-pg. The suite passes on 19
    unchanged, with every collector enabled and no metric family missing compared to 18.
  • The primary/replica topology test now takes its image tag from
    PG_EXPORTER_TEST_POSTGRES_TAG like the other container tests, so the CI matrix
    exercises replication on every supported major instead of always on 16.
  • Fix two races between tests that share one PostgreSQL. The on-CPU backend test ran
    generate_series(1, 2000000000) in FROM, which spills to disk at about 300 MB/s
    and kept running after the test ended, so the cluster-wide temp-file test could see
    tens of gigabytes that never shrank; the series is now streamed from the SELECT
    list and bounded by statement_timeout. The database catalog test rejected
    datconnlimit = -2, which PostgreSQL sets while a database is being dropped.
  • Fix a third race, in the vacuum-progress test that follows a VACUUM in another
    database. It set its cost throttle through the pool and ran the VACUUM through the
    pool too, so the two could land on different connections: the VACUUM then ran
    unthrottled and the test passed only when it caught a short vacuum in flight. Both
    now share one connection, and the throttled VACUUM is cancelled once it was seen.
  • Cover the short_version fix (#42) on both sides: the collector tests compare the
    label with server_version_num and server_version of the live server, and a
    dashboard test applies the Version panel's own label_replace pattern to old
    (18.6.0) and new (18.6, 18.0) label values.

Documentation

  • Statements: document that query_short can republish a secret from a utility
    statement such as CREATE ROLE ... PASSWORD '...', and how to rule it out. Correct
    the claim that utility statements have no query text.
  • Sequences: document that the collector needs SELECT on the sequences it watches
    (pg_monitor alone exports nothing), and that it holds one lock per sequence, which
    can exhaust the lock table in databases with many thousands of sequences.
  • Database: document that --exclude-databases also narrows the cluster-wide connection
    totals of the activity collector and drops the shared-objects row of
    pg_stat_database_*.

Full changelog: 0.22.2...0.22.3

Container image

podman pull ghcr.io/nbari/pg_exporter:0.22.3

Digest: sha256:25ee080ddf59e30b0325a8b1b9785795791d0e276c182fce2178343b70667941

Verify a download

sha256sum --check --ignore-missing SHA256SUMS
gh attestation verify <file> --repo nbari/pg_exporter --signer-workflow nbari/pg_exporter/.github/workflows/release.yml
gh attestation verify oci://ghcr.io/nbari/pg_exporter:0.22.3 --repo nbari/pg_exporter --signer-workflow nbari/pg_exporter/.github/workflows/release.yml

Built with Rust 1.100.0.

Don't miss a new pg_exporter release

NewReleases is sending notifications on new releases.