Skip to content

native_agg reports the metadata aggregate node as absent when it is present: EPIPE into grep -q under pipefail #486

Description

@jdatcmd

Hit on #484's CI, PG18. The same job re-run on the identical commit passed, so
this is a flake, and the log says exactly which one.

What happened

/tmp/pgcolumnar-matrix-18.2QoMGY/test/native_agg.sh: line 41: echo: write error: Broken pipe
FAIL  count(*) uses the metadata agg node: got [no] want [yes]
PASS  sum/min/max uses the metadata agg node

The check that failed and the check that passed on the next line call the same
helper on plan text from the same node
.

Why

test/native_agg.sh:41:

has_aggnode() { echo "$1" | grep -q 'Columnar Vectorized Aggregates' && echo yes || echo no; }

The suite runs under set -o pipefail. grep -q exits as soon as it matches, so
the writer can take EPIPE, and pipefail then calls the whole pipeline failed.
The && arm is skipped and the helper answers no while the line it was looking
for is present.

This is the shape #473 already found once, in harness_selftest:

Never pipe into an early-exit reader under pipefail. The tell is a
Broken pipe line beside a result the same run's summary contradicts.

That is precisely the tell here.

Why it is worth fixing rather than tolerating

The failure direction is the dangerous one. It reports "the metadata aggregate
node did not run" when it did, which reads as a real planner regression in
exactly the area #133 and #140 live in. Anyone triaging it starts by looking for
a costing change that is not there.

has_gather() on line 42 has the identical shape.

Fix

No pipe and no subprocess:

has_aggnode() { case "$1" in *"Columnar Vectorized Aggregates"*) echo yes;; *) echo no;; esac; }

case cannot take EPIPE and is faster besides.

Scope

About twenty instances of <string> | grep -q exist across test/, including
native_ownership.sh:34, native_groupagg.sh:235 and :326, and several in
fuzz_arrow.sh and fuzz_parquet.sh. They are not all equally exposed: the
larger the string, the likelier the writer is still writing when the reader
exits. Worth sweeping the lot in one pass, since the fix is mechanical and the
failure mode is a false red that names innocent code.

A harness_selftest check that greps test/*.sh for the shape would keep it
from coming back, which is what stopped the SUITES mistake recurring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions