CI: Skip minfree file in cores_backtrace.sh
The Core Problem
PostgreSQL's CI infrastructure uses a script (src/tools/ci/cores_backtrace.sh) that iterates over files in a core dump directory to extract backtraces from crashed processes. On OpenBSD (and potentially other BSDs), the /var/crash/ directory contains a file named minfree — a kernel configuration file that specifies the minimum free disk space required before the system will write crash dumps. This file is not a core dump, but the script naively processes all files in the core directory, causing the "Run cores" CI step to fail when it tries to feed minfree to a debugger.
This is a CI reliability issue: spurious failures in post-mortem analysis steps erode confidence in CI results and mask real test failures. The problem was first observed in OpenBSD CI tasks (e.g., Cirrus CI task 6309105838587904) and persisted for months.
Architectural Context
The CI infrastructure is configured via .cirrus.yml (or equivalent) and uses platform-specific core file naming conventions:
- Linux:
/tmp/cores/%e-%s-%p.core - FreeBSD:
/tmp/cores/%N.%P.core - NetBSD/OpenBSD:
*.corefiles moved into a common directory - macOS:
${HOME}/cores/core.%P
All configured core file names contain the substring core. The minfree file does not. This observation is the key to the v2 solution.
Proposed Solutions
v1: Explicit exclusion of minfree
The initial patch added a check to skip the minfree file by name. This is a direct, minimal fix but was criticized by Álvaro Herrera as fragile — if other non-core files appear in the directory (due to platform changes or CI configuration drift), the script would break again.
v2: Pattern-based filtering with *core* glob
The v2 approach, following Álvaro's suggestion, changes the file selection logic to only process files matching *core*. This is more robust because:
- All platform core file naming conventions already include "core" in the filename
- The script already implicitly assumed this (OpenBSD processing uses
sed 's/\.core.*$//'to extract the base name) - It naturally excludes
minfreeand any future non-core files without maintaining an exclusion list
This is the superior solution because it uses a positive match (process only what looks like a core file) rather than a negative match (skip known non-core files).
Intermediate proposal: Exclusion array variable
The patch author briefly proposed maintaining an array of files to exclude, which would be more maintainable than a hardcoded string but still inferior to the positive-match approach since it requires updates for each new non-core file discovered.
Key Design Tradeoff
Daniel Gustafsson raised an important counterpoint: in a controlled CI environment, unexpected files in the core directory might indicate a real problem worth investigating. A too-permissive filter could silently ignore something important. However, minfree is a well-known system file with a specific purpose in crash dump handling, so skipping it is clearly correct. The *core* pattern strikes a reasonable balance — it's specific enough to avoid processing obviously unrelated files while still being broad enough to catch any core file format a platform might produce.
Current Status
The v2 patch applies cleanly to master, passes sh -n syntax checking and git diff --check. Review confirmed that the *core* pattern matches all currently configured core file naming patterns across all CI platforms. The patch has been verified in a live Cirrus CI run where OpenBSD successfully loaded and backtraced initdb.core. It awaits committer pickup.