Skip to content

fix: stop uploads hanging forever when the connection drops mid-transfer#235

Open
pkeuter wants to merge 1 commit into
minio:mainfrom
pkeuter:fix/upload-hang-on-connection-drop
Open

fix: stop uploads hanging forever when the connection drops mid-transfer#235
pkeuter wants to merge 1 commit into
minio:mainfrom
pkeuter:fix/upload-hang-on-connection-drop

Conversation

@pkeuter

@pkeuter pkeuter commented Jun 23, 2026

Copy link
Copy Markdown

The libcurl multi-pump loop called select() with a nullptr timeout (block forever). A connection that drops mid-upload without a clean RST/FIN never makes the socket ready, so select() blocked indefinitely and the synchronous Execute() wedged the calling thread permanently -- no further uploads could run. Normal uploads also had no timeout configured (only the RDMA control plane set one), so libcurl had nothing to enforce even when woken.

  • Bound the select() wait to 1s so the loop keeps pumping libcurl.
  • Handle maxfd < 0 with a short poll-sleep instead of an invalid select() call (which also errors out / terminates on Windows).
  • Set a default low-speed timeout (1 byte/s for 60s) so a stalled transfer aborts with CURLE_OPERATION_TIMEDOUT. Gated on timeout_secs <= 0 to leave the RDMA control plane's explicit timeouts unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed HTTP requests that could hang indefinitely when network transfer stalls. Now detects low-speed transfers and terminates them gracefully instead of waiting forever.

The libcurl multi-pump loop called select() with a nullptr timeout (block
forever). A connection that drops mid-upload without a clean RST/FIN never
makes the socket ready, so select() blocked indefinitely and the synchronous
Execute() wedged the calling thread permanently -- no further uploads could
run. Normal uploads also had no timeout configured (only the RDMA control
plane set one), so libcurl had nothing to enforce even when woken.

- Bound the select() wait to 1s so the loop keeps pumping libcurl.
- Handle maxfd < 0 with a short poll-sleep instead of an invalid select()
  call (which also errors out / terminates on Windows).
- Set a default low-speed timeout (1 byte/s for 60s) so a stalled transfer
  aborts with CURLE_OPERATION_TIMEDOUT. Gated on timeout_secs <= 0 to leave
  the RDMA control plane's explicit timeouts unchanged.
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3df3e92b-f90a-43e9-8711-d6612a22079c

📥 Commits

Reviewing files that changed from the base of the PR and between e68f450 and f07563a.

📒 Files selected for processing (1)
  • src/http.cc

📝 Walkthrough

Walkthrough

src/http.cc gains <chrono> and <thread> includes plus a kStallTimeoutSecs = 60 constant. When timeout_secs <= 0, Request::execute() now sets libcurl low-speed detection options to abort stalled transfers. The synchronous polling loop replaces an unbounded select() with a 1-second bounded timeout and a 100ms sleep when libcurl reports no fds.

Changes

Stall timeout and bounded select loop

Layer / File(s) Summary
Includes and stall timeout constant
src/http.cc
Adds <chrono> and <thread> headers and defines kStallTimeoutSecs = 60 as the internal low-speed stall threshold constant.
Low-speed abort config and bounded select loop
src/http.cc
When timeout_secs <= 0, sets CURLOPT_LOW_SPEED_LIMIT and CURLOPT_LOW_SPEED_TIME to abort stalled transfers after 60 seconds. Rewrites the synchronous poll loop to initialize maxfd = -1, call requests.fdset(...), use a 1-second select() timeout, sleep 100ms if no fds are available, and break with a log on select() failure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hoppity-hop through the network tube,
No more hanging forever — how rude!
Sixty seconds of stillness? We bail,
A bounded select keeps progress on trail.
The rabbit says: timeouts are cool! 🕐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: preventing uploads from hanging indefinitely when network connections drop mid-transfer. It directly relates to the core problem addressed in the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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