Fix swapped flushedLsn and receiveStartTli for wal_receiver collector
#1198
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.
In
pgStatWalReceiverQueryTemplate, the order of the columns (whenhasFlushedLSN == true) is:receive_start_lsnflushed_lsnreceive_start_tliHowever, columns were scanned in this order:
receive_start_lsn->receiveStartLsnreceive_start_tli->flushedLsn(!)flushed_lsn->receiveStartTli(!)This incorrect hydration of variables also manifests as swapped values for the
pg_stat_wal_receiver_flushed_lsnandpg_stat_wal_receiver_receive_start_tlimetrics.This seems to be a bug that has existed since the initial implementation:
In this patch, I'm:
fixing the
.Scan(), so that it hydrates variables in the correct orderadjusting the order in which metrics are pushed out to the channel, to follow the order we consume them in (..,
receive_start_lsn,flushed_lsn,receive_start_tli, ..)adjusting the walreceiver tests, to follow the new order (which matches .
Scan())fixing a small identation issue in
pgStatWalReceiverQueryTemplate