Skip to content

Improved handling of idle sessions by AbstractIOSessionPool / H2ConnPool - #715

Merged
ok2c merged 1 commit into
apache:masterfrom
ok2c:io-session-pool-improvements
Oct 5, 2026
Merged

ok2c merged 1 commit into
apache:masterfrom
ok2c:io-session-pool-improvements

Conversation

@ok2c

@ok2c ok2c commented Sep 30, 2026

Copy link
Copy Markdown
Member

@arturobernalg you have been working a lot with the connection pools. Could you please double-check my changes to make sure we are on the same page as far as idle connection handling is concerned?

@ok2c
ok2c requested a review from arturobernalg September 30, 2026 17:01

@arturobernalg arturobernalg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ok2c IOSession#getLastEventTime() is based on System.nanoTime(), while inactivityDeadline() is based on Clock#millis() converted to nanoseconds. These use different time origins, so I don't think they can be compared directly. Am I missing something?

@ok2c

ok2c commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

@arturobernalg I suspected something was off. I misunderstood how System.nanoTime() worked. Now I think we have a problem. Why did we need to convert the i/o reactor timestamps to using System.nanoTime()? What was the point? I will start a discussion on the dev list.

@ok2c
ok2c force-pushed the io-session-pool-improvements branch from 86eee99 to e1800cd Compare October 5, 2026 10:16
@ok2c

ok2c commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

@arturobernalg Please do another pass

@ok2c
ok2c requested a review from arturobernalg October 5, 2026 10:18
protected boolean isIdle(final IOSession session) {
final IOEventHandler handler = session.getHandler();
if (handler instanceof HttpConnection) {
return ((HttpConnection) handler).isIdle();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this condition be inverted? Shouldn’t isIdle() return true when streamCount() == 0 rather than > 0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@arturobernalg Good catch. Corrected.

super(clock);
this.connectionInitiator = Args.notNull(connectionInitiator, "Connection initiator");
this.addressResolver = addressResolver != null ? addressResolver : DefaultAddressResolver.INSTANCE;
this.addressResolver = addressResolver;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was the change in the addressResolver fallback intentional? With a null resolver this no longer seems equivalent to DefaultAddressResolver, in particular for default ports and an explicitly provided HttpHost address.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@arturobernalg It was. H2ConnPool violates our package layering policy by importing an impl class into a non-impl one. However you likely have more violations like that. They all should be addressed consistency across teh entire code base.
I reverted my changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ok2c your right here about the package layering.

@ok2c
ok2c force-pushed the io-session-pool-improvements branch 2 times, most recently from 0e67a26 to a161925 Compare October 5, 2026 12:12
@ok2c
ok2c force-pushed the io-session-pool-improvements branch from a161925 to 72cc85a Compare October 5, 2026 12:19
@ok2c
ok2c requested a review from arturobernalg October 5, 2026 12:24

@arturobernalg arturobernalg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ok2c
LGTM

@ok2c
ok2c merged commit 5913abf into apache:master Oct 5, 2026
12 checks passed
@ok2c
ok2c deleted the io-session-pool-improvements branch October 5, 2026 14:17
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