Skip to content

Drop the redundant echo pipe that makes search-index.db fail with SIGPIPE - #106

Merged
thomasjm merged 1 commit into
mainfrom
fix-search-index-sigpipe
Aug 30, 2026
Merged

Drop the redundant echo pipe that makes search-index.db fail with SIGPIPE#106
thomasjm merged 1 commit into
mainfrom
fix-search-index-sigpipe

Conversation

@thomasjm

Copy link
Copy Markdown
Contributor

search-index.db intermittently fails to build with exit code 141 (128 + SIGPIPE):

error: Cannot build '/nix/store/...-search-index.db.drv'.
       Reason: builder failed with exit code 141

The builder is:

echo | sqlite3 $out <<- EOF
...
EOF

The pipe makes sqlite3's stdin the read end, but the heredoc then reassigns stdin to the temp file. Nothing ever reads the pipe, so echo writes to a pipe whose read end is already closed and takes SIGPIPE. Whether it dies is a race: if the write lands in the pipe buffer before sqlite3 drops the read end it survives, otherwise it doesn't. stdenv runs builders under set -o pipefail, so the pipeline reports echo's 141 and the build fails.

The echo has no effect on sqlite3 either way — the heredoc already supplies stdin — so removing it is the whole fix.

Reproduction, 3000 iterations:

for i in $(seq 1 3000); do
  bash -c 'set -eu -o pipefail; echo | cat > /dev/null <<- EOF
hello
EOF' 2>/dev/null || echo fail
done | wc -l

15 failures out of 3000 (~0.5%), each with exit code 141. With the echo | removed: 0 out of 3000.

@thomasjm
thomasjm merged commit 4b4eccd into main Aug 30, 2026
60 checks 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.

1 participant