Skip to content

Fix csvlog duration leak for statement-only entries#879

Merged
darold merged 1 commit into
darold:masterfrom
NikuleskoA:fix/csvlog-duration-leak
May 25, 2026
Merged

Fix csvlog duration leak for statement-only entries#879
darold merged 1 commit into
darold:masterfrom
NikuleskoA:fix/csvlog-duration-leak

Conversation

@NikuleskoA
Copy link
Copy Markdown
Contributor

PostgreSQL csvlog entries logged as statement: without a duration: tag could inherit duration state from a previously parsed duration-bearing entry. This made pgBadger report statement-only queries as slow queries with incorrect total, min, and max durations.

This change resets csvlog parser state for each row and updates stats merging so duration-related fields are only preserved when they are actually present.

A regression test was added with synthetic csvlog data covering:

  • one duration-bearing query;
  • one statement-only query without duration;
  • verification that the statement-only query does not get duration/min/max fields.

PostgreSQL csvlog entries logged as `statement:` without a `duration:` tag could
inherit duration state from a previously parsed duration-bearing entry. This made
pgBadger report statement-only queries as slow queries with incorrect total,
min, and max durations.

This change resets csvlog parser state for each row and updates stats merging so
duration-related fields are only preserved when they are actually present.

A regression test was added with synthetic csvlog data covering:
- one duration-bearing query;
- one statement-only query without duration;
- verification that the statement-only query does not get duration/min/max fields.
@darold darold merged commit 6b1ea9d into darold:master May 25, 2026
4 checks passed
@darold
Copy link
Copy Markdown
Owner

darold commented May 25, 2026

Many thanks!

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.

2 participants