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

IteratingCallback not serializing close() and failed() #9059

Closed
sbordet opened this issue Dec 15, 2022 · 5 comments · Fixed by #9062
Closed

IteratingCallback not serializing close() and failed() #9059

sbordet opened this issue Dec 15, 2022 · 5 comments · Fixed by #9062
Labels
Bug For general bugs on Jetty side

Comments

@sbordet
Copy link
Contributor

sbordet commented Dec 15, 2022

Jetty version(s)
10+

Description
Thread1 is inside IC.process(), acting on some custom state.

Thread2 calls IC.close() or IC.failed(failure), and this may call onCompleteFailure() directly, which may (for example) reset the custom state, or null it out, etc.

Therefore, the contract of IC that it will serialize the processing is not respected, because now 2 threads can access the IC custom state.

We should be more precise at serializing in case of a close() call, and possibly introduce a close(Throwable) or fail(Throwable) different from failed(Throwable) if necessary to handle the serialization more precisely.

@sbordet
Copy link
Contributor Author

sbordet commented Dec 15, 2022

@gregw throughts? See discussion in #9054.

I think we need to fix it, but we probably need one more state (CLOSING or such).

@gregw
Copy link
Contributor

gregw commented Dec 16, 2022

@sbordet We need to handle a call to failed(Throwable) in PROCESSING state the same as a call to succeeded. Specifically we should not act on that until the process method has returned attempts to switch to PENDING state.

Experimental branch coming....

gregw added a commit that referenced this issue Dec 16, 2022
gregw added a commit that referenced this issue Dec 16, 2022
gregw added a commit that referenced this issue Dec 16, 2022
@sbordet sbordet linked a pull request Dec 16, 2022 that will close this issue
gregw added a commit that referenced this issue Dec 16, 2022
Serialize onCompleteFailure for #9059

* Fixed case where process() throws an exception.
   Before, exiting the processing loop would always skip to invoke onCompleteFailure(), causing the callback to not be completed.
   Now we fall through and possibly invoke onCompleteFailure() if it was not already invoked.

* Updated javadocs.

* Code cleanups.

Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
@gregw
Copy link
Contributor

gregw commented Dec 16, 2022

@sbordet I will merge forward to 12. Does this need to be cherry-picked back to 9?

@gregw gregw reopened this Dec 16, 2022
@sbordet
Copy link
Contributor Author

sbordet commented Dec 20, 2022

@gregw I think cherry-picking to 9 would be good, it is a stabilization fix that may help 9 too.

gregw added a commit that referenced this issue Dec 20, 2022
Serialize onCompleteFailure for #9059

* Fixed case where process() throws an exception.
   Before, exiting the processing loop would always skip to invoke onCompleteFailure(), causing the callback to not be completed.
   Now we fall through and possibly invoke onCompleteFailure() if it was not already invoked.

* Updated javadocs.

* Code cleanups.

Co-authored-by: Simone Bordet <simone.bordet@gmail.com>
@gregw
Copy link
Contributor

gregw commented Dec 20, 2022

done

@gregw gregw closed this as completed Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants