Skip to content

Align native transport option selection with default order - #3818

Merged
a-TODO-rov merged 3 commits into
redis:mainfrom
karunsehwag:fix/keepalive-transport-priority-order
Jul 6, 2026
Merged

a-TODO-rov merged 3 commits into
redis:mainfrom
karunsehwag:fix/keepalive-transport-priority-order

Conversation

@karunsehwag

@karunsehwag karunsehwag commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Transports.NativeTransports prefers native transports in the order:

Epoll > Kqueue > IOUring

However, ExtendedKeepAliveSupport and the TCP_USER_TIMEOUT handling in ConnectionBuilder checked io_uring availability before epoll. When both epoll and io_uring are present on the classpath, Lettuce can create an epoll-backed channel while these option paths attempt to apply io_uring-specific channel options.

That can result in unknown channel option warnings and prevents the epoll keep-alive / TCP_USER_TIMEOUT options from being applied consistently.

This change aligns those option-selection paths with the existing native transport priority order by checking epoll before io_uring.

The fix is intentionally small. A broader refactor to centralize the priority order can be handled separately if maintainers prefer.

Fixes #3816


Note

Low Risk
Small, localized change to transport option selection order on Linux; no API or auth changes.

Overview
When both epoll and io_uring are on the classpath, Lettuce builds channels with epoll (Transports.NativeTransports: Epoll > Kqueue > IOUring), but TCP_USER_TIMEOUT in ConnectionBuilder and extended keep-alive in ExtendedKeepAliveSupport still preferred io_uring first. That mismatch could apply transport-specific options to the wrong bootstrap and trigger unknown channel option warnings.

This PR checks epoll before io_uring in those code paths and documents that the order must match channel/event-loop selection. The static EXTENDED_KEEPALIVE_SUPPORTED flag uses the same epoll-then-io_uring ordering for consistency.

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

Fixes redis#3816. ExtendedKeepAliveSupport and ConnectionBuilder checked
io_uring before epoll when applying extended keep-alive and
TCP_USER_TIMEOUT options, while Transports.NativeTransports builds
the channel/event loop with Epoll prioritized over io_uring. When
both native transports are on the classpath, this mismatch caused
io_uring-specific ChannelOptions to be applied to an epoll-backed
bootstrap, triggering Netty warnings and skipping the real keep-alive
config.

Reorders both checks to Epoll > IOUring, matching the existing
priority used by Transports.NativeTransports and
DefaultEventLoopGroupProvider.

Signed-off-by: Karun Choudhary <karunchoudhary2000@gmail.com>
@karunsehwag karunsehwag closed this Jul 3, 2026
@karunsehwag karunsehwag reopened this Jul 3, 2026
@a-TODO-rov

Copy link
Copy Markdown
Collaborator

Hey @karunsehwag
I tried to make the solution testable, but it seems its not very straight forward to do so ...

@a-TODO-rov
a-TODO-rov merged commit 9894904 into redis:main Jul 6, 2026
12 checks passed
a-TODO-rov added a commit that referenced this pull request Jul 13, 2026
* Align native transport option selection with default order

Fixes #3816. ExtendedKeepAliveSupport and ConnectionBuilder checked
io_uring before epoll when applying extended keep-alive and
TCP_USER_TIMEOUT options, while Transports.NativeTransports builds
the channel/event loop with Epoll prioritized over io_uring. When
both native transports are on the classpath, this mismatch caused
io_uring-specific ChannelOptions to be applied to an epoll-backed
bootstrap, triggering Netty warnings and skipping the real keep-alive
config.

Reorders both checks to Epoll > IOUring, matching the existing
priority used by Transports.NativeTransports and
DefaultEventLoopGroupProvider.

Signed-off-by: Karun Choudhary <karunchoudhary2000@gmail.com>

---------

Signed-off-by: Karun Choudhary <karunchoudhary2000@gmail.com>
Co-authored-by: aleksandar.todorov <a_t_todorov@yahoo.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.

Inconsistent defaults when picking between epoll and io_uring

2 participants

⌂ 换网址