fix: skip autovacuum metric when xact_start is NULL - #1381
Open
locker95 wants to merge 1 commit into
Open
Conversation
The stat_activity_autovacuum collector scanned xact_start into a plain float64, so a NULL value (possible for autovacuum workers) failed the whole collector with "converting NULL to float64 is unsupported". Scan into sql.NullFloat64 and skip the row when it is NULL, matching the pg_stat_walreceiver / pg_stat_database collectors. Fixes prometheus-community#952 Signed-off-by: Dean Chen <862469039@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The stat_activity_autovacuum collector scans
EXTRACT(EPOCH FROM xact_start)into a plainfloat64.xact_startcan be NULL for autovacuum workers, and when that happens the Scan fails withconverting NULL to float64 is unsupportedand the entire collector errors out, as reported in #952.This changes the scan target to
sql.NullFloat64and skips the row when the value is NULL, following the same pattern the pg_stat_walreceiver and pg_stat_database collectors use. Skipping rather than reporting 0 matches sysadmind's comment on the issue: "The typical options are to report a 0 value or to skip the metric all together. I usually lean towards the latter." Rows with a valid timestamp keep being emitted as before.The regression test adds a NULL-timestamp row mixed with a normal row; it reproduces the exact Scan error before the fix and verifies the NULL row is skipped and the valid row still emitted after.
Fixes #952