Skip to content

Cherry-pick stale fd fix from main#423

Open
mason-sharp wants to merge 3 commits intov5_STABLEfrom
fix/fd-cherry
Open

Cherry-pick stale fd fix from main#423
mason-sharp wants to merge 3 commits intov5_STABLEfrom
fix/fd-cherry

Conversation

@mason-sharp
Copy link
Copy Markdown
Member

No description provided.

@mason-sharp mason-sharp requested a review from rasifr April 19, 2026 19:16
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 19, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6cb2f9eb-e3c4-4fff-aea0-6c79062ea7f2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fd-cherry

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mason-sharp mason-sharp removed the request for review from rasifr April 19, 2026 19:16
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 19, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

rasifr and others added 3 commits April 20, 2026 13:30
Key changes from main:
- Export TESTLOGDIR as absolute path so SpockTest.pm can locate PG logs
- Add $LOG_DIR module variable; use it in create_postgresql_conf and
  create_cluster (fixes mismatch where PG wrote logs to parent/logs but
  create_cluster created cwd/logs)
- Expose log_dir in get_test_config() (needed by tests that read PG logs)
- Add File::Basename; derive per-test log filenames from $0
- Set PSQLRC/PSQL_HISTORY to /dev/null; add -X flag to all psql calls
  to prevent user psqlrc from polluting test output
- Improve destroy_cluster subscription cleanup query

Also update tests 013 and 016 to use $config->{log_dir} instead of
the hard-coded '../logs/' path that matched the old SpockTest.pm behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Test 019 covers the bug where fd = PQsocket(applyconn) is captured once
before stream_replay: and never refreshed.  When the provider is killed
with SIGKILL (no CopyDone), libpq reads a raw EOF, calls pqDropConnection
to close conn->sock, and the first exception is "connection to other side
has died".  On re-entry at stream_replay: with use_try_block=true, the
stale fd triggers epoll_ctl(EPOLL_CTL_ADD, closed_fd) -> EINVAL on Linux,
or a second exception from PQconsumeInput on macOS — both caught as
"error during exception handling".

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

fd = PQsocket(applyconn) was captured once before stream_replay: and
never refreshed.  When the provider connection dies, libpq's
pqDropConnection closes conn->sock (sets it to PGINVALID_SOCKET) and
marks status CONNECTION_BAD.  On re-entry at stream_replay: with
use_try_block=true, the stale fd is passed to WaitLatchOrSocket:

  epoll_ctl(EPOLL_CTL_ADD, closed_fd) -> EINVAL
  => ERROR "epoll_ctl() failed: Invalid argument"

This hits the use_try_block=true branch in PG_CATCH, producing
LOG "error during exception handling" + PG_RE_THROW.

Fix: at stream_replay:, refresh fd = PQsocket(applyconn) and return
cleanly if the connection is already dead.  The worker exits with
proc_exit(0) and the postmaster restarts it to reconnect.  Set
worker_status = SPOCK_WORKER_STATUS_STOPPED before returning so
monitoring sees the correct state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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