Skip to content

Do not reuse the curl handle across a fork - #643

Open
dutow wants to merge 1 commit into
percona:release-2.2from
dutow:curl_fork_fix
Open

Do not reuse the curl handle across a fork#643
dutow wants to merge 1 commit into
percona:release-2.2from
dutow:curl_fork_fix

Conversation

@dutow

@dutow dutow commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

The postmaster does keyring requests while generating the WAL key, so keyringCurl and its keepalive socket get inherited by every child. Two processes then interleave HTTP on the same connection, which surfaces as CURLE_WEIRD_SERVER_REPLY, a timeout, or a garbled response body.

Re-init the handle when the pid changed. The inherited handle is abandoned instead of cleaned up, because curl_easy_cleanup would write a TLS shutdown to the connection the parent still uses.

@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-2.2@25f6612). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             release-2.2     #643   +/-   ##
==============================================
  Coverage               ?   56.69%           
==============================================
  Files                  ?       71           
  Lines                  ?    11237           
  Branches               ?     2778           
==============================================
  Hits                   ?     6371           
  Misses                 ?     3501           
  Partials               ?     1365           
Components Coverage Δ
access 80.95% <0.00%> (?)
bin 63.78% <0.00%> (?)
catalog 80.03% <0.00%> (?)
common 91.66% <0.00%> (?)
encryption 65.56% <0.00%> (?)
keyring 64.83% <0.00%> (?)
src 87.04% <0.00%> (?)
smgr 89.23% <0.00%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeltz jeltz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but maybe we should merge it into release-2.2 and update our release notes.

@dutow
dutow changed the base branch from main to release-2.2 July 28, 2026 10:17
The postmaster does keyring requests while generating the WAL key, so
keyringCurl and its keepalive socket get inherited by every child. Two
processes then interleave HTTP on the same connection, which surfaces as
CURLE_WEIRD_SERVER_REPLY, a timeout, or a garbled response body.

Re-init the handle when the pid changed. The inherited handle is
abandoned instead of cleaned up, because curl_easy_cleanup would write a
TLS shutdown to the connection the parent still uses.
@dutow

dutow commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

@jeltz updated

### Bug Fixes

- [PG-2492](https://perconadev.atlassian.net/browse/PG-2492) - Fixed crash when empty certificate parameters are passed to `pg_tde_add_global_key_provider_kmip()` or `pg_tde_add_database_key_provider_kmip()`
- [PG-2608](https://perconadev.atlassian.net/browse/PG-2608) - Fix race condition in Vault key provider

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly more descriptive:

Fixed a race condition in the Vault key provider that could occur when multiple processes accessed the same cURL handle after a fork.

LGTM!

@jeltz

jeltz commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Looks good to me.

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.

4 participants