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

core: separate internal dispatch from http path #1272

Merged
merged 52 commits into from
Apr 26, 2021
Merged

core: separate internal dispatch from http path #1272

merged 52 commits into from
Apr 26, 2021

Conversation

goaway
Copy link
Contributor

@goaway goaway commented Mar 1, 2021

Description: Previously the Http::Dispatcher served the dual purpose of dispatching incoming library calls onto Envoy's main thread event loop and also functioning as the HTTP client. This conflation led to a bunch of incidental complexity, including that the Http::Dispatcher needed to exist as soon as the Engine did, but before Envoy was actually up and running and could provide the interfaces the Http::Dispatcher would need to call to actually accomplish anything.

This change splits the logic into an Http::Client that is largely single-threaded code and contains no synchronization/locking and an Event::ProvisionalDispatcher that wraps Envoy's internal Event::Dispatcher but can persist beyond (before and after) the underlying dispatcher's lifecycle.

The change simplifies the dispatch and threading model of incoming calls, opens the door to resolving some types of races during Engine shutdown, and supports non-singleton integrations.

Risk Level: High
Testing: Local, Unit, Integration, E2E, CI

Signed-off-by: Mike Schore mike.schore@gmail.com

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

Thanks for these changes I think this: a) separates concerns more cleanly, b) allocating the engine on the heap and not stopping the event loop/destructing will obviously solve the pesky shutdown crashes that remain.

First pass of comments. I know you have more commits coming, so some of this might have changed already.

Also can you refresh me on the thread safety/locking conversation we had a couple weeks ago and the decisions we came to? I can't quite remember, but to me it looks like all the locking has been preserved here? Sorry I am a little foggy, the last two weeks where a whirlwind as you know 😅

library/common/engine.cc Show resolved Hide resolved
library/common/engine.cc Outdated Show resolved Hide resolved
library/common/event/BUILD Outdated Show resolved Hide resolved
library/common/event/provisional_dispatcher.h Outdated Show resolved Hide resolved
library/common/event/provisional_dispatcher.h Outdated Show resolved Hide resolved
library/common/event/provisional_dispatcher.cc Outdated Show resolved Hide resolved
library/common/event/provisional_dispatcher.h Outdated Show resolved Hide resolved
library/common/http/client.h Outdated Show resolved Hide resolved
library/common/http/client.cc Show resolved Hide resolved
library/common/http/client.h Outdated Show resolved Hide resolved
@goaway
Copy link
Contributor Author

goaway commented Mar 8, 2021

@junr03 please take a look and comment on approach (still needs fixed tests and cleanup).

Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

Awesome clean up.

re: approach -- it matches the synchronization model we had before just more cleanly thanks to logic separation in two (more) appropriate classes.

Per my previous comment, I thought we had discussed potentially going lock-free here... but I cannot remember the solution we arrived to. Not necessarily saying we should go there in this PR. I would just like it documented in an issue. In fact, it is probably best to land this, and get it out as it doesn't change the model and has less change for unforeseen edge cases, specially since tests should largely be the same as before just rejiggered for the class separation.

library/common/event/provisional_dispatcher.h Show resolved Hide resolved
library/common/event/provisional_dispatcher.h Show resolved Hide resolved
library/common/http/client.cc Show resolved Hide resolved
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

Just a few comments.

I think a format run is missing like you said.

library/common/engine.h Outdated Show resolved Hide resolved
library/common/event/provisional_dispatcher.cc Outdated Show resolved Hide resolved
library/common/engine.h Outdated Show resolved Hide resolved
library/common/event/provisional_dispatcher.h Outdated Show resolved Hide resolved
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
@goaway goaway changed the title wip: dispatcher/client split core: separate internal dispatch from http path Mar 24, 2021
@goaway goaway marked this pull request as ready for review March 24, 2021 20:39
Signed-off-by: Mike Schore <mike.schore@gmail.com>
@rebello95 rebello95 mentioned this pull request Mar 25, 2021
@goaway goaway requested a review from rebello95 April 10, 2021 05:36
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

some comments. I can't quite see from reviewing what is causing the ASAN and TSAN failures. I will take a look at the CI failures in more detail.

library/common/engine.cc Outdated Show resolved Hide resolved
library/common/event/provisional_dispatcher.cc Outdated Show resolved Hide resolved
library/common/http/dispatcher.cc Outdated Show resolved Hide resolved
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

Alright, a couple clean up things. Then lets merge!

library/common/engine.cc Show resolved Hide resolved
library/common/event/BUILD Outdated Show resolved Hide resolved
library/common/main_interface.cc Show resolved Hide resolved
test/common/http/client_test.cc Show resolved Hide resolved
test/common/mocks/event/mocks.cc Outdated Show resolved Hide resolved
test/python/integration/test_send_headers.py Show resolved Hide resolved
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: Mike Schore <mike.schore@gmail.com>
junr03
junr03 previously approved these changes Apr 26, 2021
test/common/mocks/event/mocks.cc Show resolved Hide resolved
library/common/engine.cc Show resolved Hide resolved
Signed-off-by: Mike Schore <mike.schore@gmail.com>
@goaway goaway merged commit 3a2fdb7 into main Apr 26, 2021
@goaway goaway deleted the ms/dispatcher branch April 26, 2021 23:22
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.

3 participants