Skip to content

Fix Linux TCP connect error queue in hiredis - #15917

Merged
sundb merged 3 commits into
redis:unstablefrom
vitahlin:fix-hiredis
Oct 10, 2026
Merged

sundb merged 3 commits into
redis:unstablefrom
vitahlin:fix-hiredis

Conversation

@vitahlin

@vitahlin vitahlin commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Issue

Sentinel can enter a busy loop when a stale Linux socket error queue entry remains after TCP connection succeeds.

Related Issue:

Change

Port hiredis#1375 into deps/hiredis.

Drain the Linux error queue when TCP connect is pending or completed, preserving errno. Blocking connections continue polling with the remaining original timeout.
Add the upstream timestamping regression to verify that EPOLLERR clears and the connection still reads PONG.

Co-authored-by: Steve Wills [email protected]


Note

Medium Risk
Changes core TCP connect completion and blocking wait logic on Linux; behavior is scoped to TCP and matches an upstream hiredis fix with a dedicated regression test.

Overview
Ports upstream hiredis fix for stale Linux TCP socket error-queue entries after non-blocking connect, which could leave EPOLLERR stuck and drive Sentinel/event-loop busy loops.

On Linux TCP sockets, hiredis now drains the error queue (recvmsg with MSG_ERRQUEUE) while connect is still in progress and again when connect completes, without clobbering errno. Blocking connect wait (redisContextWaitReady) is reworked to poll in a loop with a monotonic deadline so the full connect timeout is honored across repeated poll/redisCheckConnectDone cycles.

Adds a Linux-only regression test that uses SO_TIMESTAMPING to queue timestamp errors, asserts redisCheckConnectDone clears EPOLLERR, and confirms the connection can still read PONG.

Reviewed by Cursor Bugbot for commit 0cb27fd. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit dde7db1. Configure here.

Comment thread deps/hiredis/net.c Resolved
Comment thread deps/hiredis/net.c Resolved
@sundb sundb added the release-notes indication that this issue needs to be mentioned in the release notes label Oct 8, 2026
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.67%. Comparing base (e1d8731) to head (0cb27fd).
⚠️ Report is 5 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable   #15917      +/-   ##
============================================
+ Coverage     77.66%   77.67%   +0.01%     
============================================
  Files           146      146              
  Lines         88021    88096      +75     
============================================
+ Hits          68358    68432      +74     
- Misses        19663    19664       +1     

see 23 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants