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 Content.Source reads from within naked threads #12143

Conversation

lorban
Copy link
Contributor

@lorban lorban commented Aug 6, 2024

We have methods implicitly assuming that they're only ever going to be called from an invoker. That's a bit of a leap of faith as there currently is no way to check that and that's not always documented. Let's add some code that allows asserting that the execution is happening from the invoker, akin to when we assert that a lock is held by calling AutoLock.isHeldByCurrentThread().

Adding such extra assertions surfaced a bug introduced by #12123, as calling Content.Source.read() out of the demand's runnable callback would call HttpReceiver.responseContentAvailable() outside the invoker's context, so modifications are needed to make sure that the invoker is always used when needed.

Let's also name the SerializedInvoker instances to improve readability when they are logged.

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban lorban requested review from gregw and sbordet August 6, 2024 08:48
@lorban lorban self-assigned this Aug 6, 2024
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban lorban changed the base branch from jetty-12.0.x to fix/jetty-12.0.x/12122/httpreceiver-npe August 6, 2024 12:23
@lorban lorban changed the base branch from fix/jetty-12.0.x/12122/httpreceiver-npe to jetty-12.0.x August 6, 2024 12:24
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
…tty-12.0.x/serialized-invoker-serialized-assertions
@lorban lorban marked this pull request as ready for review August 7, 2024 16:41
@lorban lorban changed the title add SerializedInvoker assertion Improve SerializedInvoker's serviceability Aug 7, 2024
@lorban lorban requested a review from sbordet August 7, 2024 16:44
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban lorban changed the title Improve SerializedInvoker's serviceability Fix Content.Source reads from within naked threads Aug 8, 2024
…oking

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
…ty to dump them

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
…ty to dump them

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
…ed-invoker-serialized-assertions' into experiment/jetty-12.0.x/serialized-invoker-serialized-assertions

# Conflicts:
#	jetty-core/jetty-client/src/main/java/org/eclipse/jetty/client/transport/HttpReceiver.java
…tty-12.0.x/serialized-invoker-serialized-assertions
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

LGTM other than a minor naming quibble... actually some javadoc would be good...

Comment on lines 50 to 53
public SerializedInvoker(Class<?> clazz)
{
this(clazz.getSimpleName());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public SerializedInvoker(Class<?> clazz)
{
this(clazz.getSimpleName());
}
public SerializedInvoker(Class<?> nameFrom)
{
this(nameFrom.getSimpleName());
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, and added javadoc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Somehow this got lost? Can you redo?

@lorban lorban requested a review from gregw August 26, 2024 08:50
…tty-12.0.x/serialized-invoker-serialized-assertions
@lorban lorban force-pushed the experiment/jetty-12.0.x/serialized-invoker-serialized-assertions branch from bd23b7f to 7d98c47 Compare August 26, 2024 08:55
…tty-12.0.x/serialized-invoker-serialized-assertions
…tty-12.0.x/serialized-invoker-serialized-assertions
@gregw
Copy link
Contributor

gregw commented Aug 27, 2024

@lorban why force push????? I now can't see what you have changed since my last review. I'm putting this to the back of my re-review queue as "punishment"!!!!!

@lorban
Copy link
Contributor Author

lorban commented Aug 27, 2024

This happened because I mistakenly merged in 12.1.x instead of 12.0.x, and re-merging 12.0.x afterwards gave me a million conflicts, so it was easier to reset the history to before the 12.1.x merge and force-push that. Sorry about the inconvenience.

@gregw
Copy link
Contributor

gregw commented Aug 27, 2024

Oh I did the same to Simone's PR!

Comment on lines 50 to 53
public SerializedInvoker(Class<?> clazz)
{
this(clazz.getSimpleName());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Somehow this got lost? Can you redo?

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban
Copy link
Contributor Author

lorban commented Aug 28, 2024

@gregw this PR was used to identify a problem, its cause and to propose and quick and dirty fix, all that being concentrated in responseContentAvailable(HttpExchange). The SerializedInvoker changes were made to help troubleshooting by making our tests fail early. Those are orthogonal to the original problem.

A much cleaner fix is being worked on in #12203 which is going to replace this PR.

@gregw
Copy link
Contributor

gregw commented Aug 28, 2024

@lorban so this is not going to be merged?

@lorban
Copy link
Contributor Author

lorban commented Aug 28, 2024

Superseded by #12203

@lorban lorban closed this Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants