Skip to content

Fix 'invalid result' in pgcenter report for tar files (issue #122)#135

Merged
lesovsky merged 3 commits into
masterfrom
develop
May 18, 2026
Merged

Fix 'invalid result' in pgcenter report for tar files (issue #122)#135
lesovsky merged 3 commits into
masterfrom
develop

Conversation

@lesovsky
Copy link
Copy Markdown
Owner

Summary

  • pgcenter report printed invalid result for every row when reading any tar file recorded with pgcenter >= 0.9.x
  • Root cause: a mismatch between the metadata column count written during record and the count expected during report

Root cause

Commit cbfa0a4 (July 2021) added shared_preload_libraries to SelectCommonProperties, increasing the metadata query from 7 to 8 columns. The readMeta function in report/report.go was not updated and continued to check res.Ncols != 7, rejecting all metadata with 8 columns with the error invalid result.

Because readMeta fails on every metadata entry, the readTar loop never delivers any data to the processing goroutine — hence every report row shows invalid result.

Fix

Changed res.Ncols != 7res.Ncols < 2 in readMeta.

readMeta only reads res.Values[0][1] (the version_num field at index 1), so the actual minimum requirement is 2 columns. The loose check makes the function robust to both old (7-col) and current (8-col) metadata, and any future column additions.

Test plan

  • New test case in Test_readMeta: 8-column metadata (with shared_preload_libraries) — was failing before, passes after
  • Existing 7-column test case continues to pass (backward compat with old tar files)
  • {Ncols: 1, Nrows: 1} still fails (insufficient columns guard)
  • Full go test ./... passes

Closes #122

🤖 Generated with Claude Code

Alexey Lesovsky and others added 3 commits May 18, 2026 18:18
Two structural problems in statements tests:

1. t.Skipf inside a bare for-loop caused the entire timing/report/wal
   suite to be skipped when the first PG version (9.5) was unavailable.
   Timing and report query integration tests never ran against PG 17/18.

2. TestSelectStatStatementsTimingQuery and TestSelectQueryReportQuery
   only asserted version routing up to PG 13, so a regression in the
   PG 17+ routing would go undetected.

Fixes:
- Split timing and WAL loops into per-version t.Run sub-tests; missing
  instances now skip only that version, not the entire suite.
- Extend WAL stats test to cover PG 13-18 (was hardcoded to PG 13).
- Add PG 14/16/17/18 cases to both unit routing tests, asserting that
  PG 17+ returns the blk_read_time-free PG17 query variants.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…version

Convention: PGxx suffix marks a query valid from PG xx (now superseded);
Default marks the query for the current/latest supported version.

Previously violated by two files:
- wal.go: PgStatWALDefault covered PG 14-17 (not latest);
  PgStatWALPG18 covered PG 18+ (latest).
- statements.go: PgStatStatementsTimingDefault / ReportQueryDefault
  covered PG 13-16; PG17 variants covered PG 17+ (latest).

Renames:
- PgStatWALDefault       → PgStatWALPG14
- PgStatWALPG18          → PgStatWALDefault
- PgStatStatementsTimingDefault      → PgStatStatementsTimingPG13
- PgStatStatementsTimingPG17         → PgStatStatementsTimingDefault
- PgStatStatementsReportQueryDefault → PgStatStatementsReportQueryPG13
- PgStatStatementsReportQueryPG17    → PgStatStatementsReportQueryDefault

Updated: selector functions, view.go initial templates, all test references.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ssue #122)

Commit cbfa0a4 added shared_preload_libraries to SelectCommonProperties,
increasing the metadata column count from 7 to 8. readMeta's strict
"Ncols != 7" check rejected all tar files recorded after that commit,
printing "invalid result" for every report row.

Fix: replace "!= 7" with "< 2" — readMeta only reads column 1
(version_num), so the minimum required is 2 columns. This accepts
both old (7-col) and current (8-col) metadata without breaking
forward compatibility for any future column additions.

Adds a regression test with 8-column metadata that previously failed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lesovsky lesovsky merged commit f055b3a into master May 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can not get some report from tar file.

1 participant