Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10229 EE10 Idle Timeout #10233

Merged
merged 12 commits into from
Aug 6, 2023
Merged

Fix #10229 EE10 Idle Timeout #10233

merged 12 commits into from
Aug 6, 2023

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Aug 4, 2023

Fix #10229

Added test to reproduce
Fixed NPE if no failure listener
@gregw
Copy link
Contributor Author

gregw commented Aug 4, 2023

@sbordet I think the issue here is that we created the Request.addIdleTimeoutListener API, but then never got around to actually using it to ignore the idle timeouts as we need to whilst dispatched! Brain fade!!!!

@gregw
Copy link
Contributor Author

gregw commented Aug 4, 2023

Ah we do add a listener : org.eclipse.jetty.ee10.servlet.ServletContextRequest#onIdleTimeout
If I hack it to always return false, the test passes. So something wrong in the impl.... I'll probably fix on my flight, so 10 hours until fix.

@gregw
Copy link
Contributor Author

gregw commented Aug 4, 2023

hmmmm ServletRequestState:

    public boolean onIdleTimeout(TimeoutException timeout)
    {
        try (AutoLock ignored = lock())
        {
            if (LOG.isDebugEnabled())
                LOG.debug("onIdleTimeout {}", getStatusStringLocked(), timeout);
            // TODO this is almost always returning false?!? what about read/write timeouts???
            //      return _state == State.IDLE;
            return true;
        }
    }

yeah we didn't finish this!

If I implement the TODO, the test passes!

@gregw
Copy link
Contributor Author

gregw commented Aug 4, 2023

@sbordet @joakime I've pushed the fix suggested by the TODO. I'll look more during the flight, but it seams reasonable.

Added test that idle works between requests
@gregw gregw marked this pull request as ready for review August 4, 2023 23:02
gregw added 4 commits August 5, 2023 09:50
EE9 idle timeout
idle if read operation
Handle idleTimeout for IO operations differently
improve comments
Comment on lines 358 to 379
Runnable invokeOnContentAvailable = _onContentAvailable;
_onContentAvailable = null;

// If a write call is in progress, take the writeCallback to fail below
Runnable invokeWriteFailure = _response.lockedFailWrite(t);

// If an IO operation was in progress
if (invokeOnContentAvailable != null || invokeWriteFailure != null)
{
// Then we will just fail the current operation and all future IO operation.
// No listeners are called at all, as the application is already notified
// TODO should we make this read failure transient, so it can be ignored by the application?
if (_failure == null)
{
_failure = Content.Chunk.from(t);
}
else if (ExceptionUtil.areNotAssociated(_failure.getFailure(), t) && _failure.getFailure().getClass() != t.getClass())
{
_failure.getFailure().addSuppressed(t);
}

return _serializedInvoker.offer(invokeOnContentAvailable, invokeWriteFailure);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much of this was copied over from onFailure, so if there is an IO operation in progress, we just fail them when an idle timeout occurs.

I think this needs careful review

@joakime joakime mentioned this pull request Aug 5, 2023
50 tasks
gregw added 3 commits August 6, 2023 08:59
fixed test to not expect timeout listener to be called if there is demand
Idle timeouts for IO operations are not last.
Disable transient idle timeouts since AsyncContentProducer cannot handle them.
@gregw
Copy link
Contributor Author

gregw commented Aug 6, 2023

@lorban @sbordet I've mode all the changes necessary to make idle timeouts for IO operations transient, but AsyncContentProducer has been written on the assumption that it can always re-read a failure. So that class will need some reworking if we are ever to support transient idle timeouts.

revert test to persistent idle failures
@gregw gregw merged commit 70a7a67 into jetty-12.0.x Aug 6, 2023
@gregw gregw deleted the fix/10229/ee10-idle-timeout branch August 6, 2023 20:05
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.

HttpConfiguration.setIdleTimeout() breaks long running requests
2 participants