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

mobile: Wait until the Engine is ready before calling terminate #34287

Merged
merged 1 commit into from
May 22, 2024

Conversation

fredyw
Copy link
Member

@fredyw fredyw commented May 21, 2024

When the Engine is not fully initialized, calling terminate() will cause an assertion failure.

[2024-05-21 21:28:16.718][18][critical][assert] [external/envoy/source/common/stats/thread_local_store.cc:49] assert failure: scopes_.empty().

This PR adds a workaround to wait until the Engine before proceeding to call terminate().

Risk Level: low
Testing: unit tests
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: mobile

Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #34287 was opened by fredyw.

see: more, trace.

@fredyw fredyw force-pushed the wait_on_terminate branch from bfd555b to 90fb292 Compare May 21, 2024 22:36
@fredyw
Copy link
Member Author

fredyw commented May 21, 2024

/retest

@fredyw fredyw force-pushed the wait_on_terminate branch 2 times, most recently from f052c23 to fc37924 Compare May 22, 2024 18:31
@fredyw
Copy link
Member Author

fredyw commented May 22, 2024

/retest

@fredyw fredyw marked this pull request as ready for review May 22, 2024 19:33
@fredyw
Copy link
Member Author

fredyw commented May 22, 2024

/assign @alyssawilk @abeyad

@@ -174,6 +177,7 @@ envoy_status_t InternalEngine::main(std::shared_ptr<Envoy::OptionsImplBase> opti
server_->api().randomGenerator());
dispatcher_->drain(server_->dispatcher());
callbacks_->on_engine_running_();
engine_running_.Notify();
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be added before the on_engine_running callback, in case e.g. that on_engine_running callback happens to block?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Updated.

@@ -11,6 +11,9 @@
#include "library/common/stats/utility.h"

namespace Envoy {
namespace {
constexpr absl::Duration ENGINE_RUNNING_TIMEOUT = absl::Seconds(3);
Copy link
Contributor

Choose a reason for hiding this comment

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

out of curiosity, any idea how long average startup time is? I'm not sure what the typical range is

Copy link
Member Author

Choose a reason for hiding this comment

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

It's typically really fast (less than 1 second). I put in 3 seconds and it's pretty arbitrary but I don't want it to wait indefinitely. I'm open to changing it to whatever timeout value that you think is more reasonable.

Copy link
Contributor

Choose a reason for hiding this comment

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

3s SGTM

@fredyw fredyw force-pushed the wait_on_terminate branch from fc37924 to d41a296 Compare May 22, 2024 20:12
@fredyw
Copy link
Member Author

fredyw commented May 22, 2024

/retest

@fredyw fredyw enabled auto-merge (squash) May 22, 2024 20:32
@fredyw fredyw merged commit e2613ca into envoyproxy:main May 22, 2024
35 checks passed
@fredyw fredyw deleted the wait_on_terminate branch May 22, 2024 21:02
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