Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix converting NULL to uint64 is unsupported in size table #1070

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions collector/pg_wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package collector

import (
"context"

"database/sql"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down Expand Up @@ -66,19 +66,34 @@ func (c PGWALCollector) Update(ctx context.Context, instance *instance, ch chan<
pgWALQuery,
)

var segments uint64
var size uint64
var segments sql.NullInt64
var size sql.NullInt64
err := row.Scan(&segments, &size)
if err != nil {
return err
}

var segmentsValue float64
Copy link
Contributor

Choose a reason for hiding this comment

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

segments should never be NULL. It's a count(*) which I don't believe can return a NULL value. The error you reported was on the size column. If Aurora is returning NULL for that column, I think there should not be a metric emitted from the exporter. I don't know what value a metric for WAL size with a value of 0 is.

if segments.Valid {
segmentsValue = float64(segments.Int64)
} else {
segmentsValue = 0
}

var sizeValue float64
if size.Valid {
sizeValue = float64(size.Int64)
} else {
sizeValue = 0
}

ch <- prometheus.MustNewConstMetric(
pgWALSegments,
prometheus.GaugeValue, float64(segments),
prometheus.GaugeValue, segmentsValue,
)
ch <- prometheus.MustNewConstMetric(
pgWALSize,
prometheus.GaugeValue, float64(size),
prometheus.GaugeValue, sizeValue,
)
return nil
}