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

wasm: remove the shutdown callback in lifetime_notifier #36688

Merged
merged 6 commits into from
Nov 5, 2024

Conversation

botengyao
Copy link
Member

@botengyao botengyao commented Oct 18, 2024

Commit Message: wasm: remove the shutdown callback in lifetime_notifier
Additional Description:
Risk Level: low
Testing: unit test
Docs Changes:
Release Notes:
Fixes: #35882

Signed-off-by: Boteng Yao <boteng@google.com>
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: #36688 was opened by botengyao.

see: more, trace.

@botengyao botengyao changed the title wasm: fix the issue that shutdown callback is not registered to lifetime_notifier wasm: fix that shutdown callback is not registered to lifetime_notifier Oct 18, 2024
@botengyao botengyao marked this pull request as ready for review October 18, 2024 02:26
@botengyao botengyao requested a review from kyessenov as a code owner October 18, 2024 02:26
@botengyao
Copy link
Member Author

/assign @mpwarres

@botengyao
Copy link
Member Author

cc @yanavlasov

@botengyao
Copy link
Member Author

/wait

for CI

Signed-off-by: Boteng Yao <boteng@google.com>
…time_issue

Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
server_shutdown_post_cb_ = std::move(post_cb);
}
});
shutdown_handler_ = lifecycle_notifier.registerCallback(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really understand this code - can you explain briefly? Why is "this" held twice directly and via weak? Why is it posting the completion to its own dispatcher without doing any work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Taking a deeper look, I don't have a full history for why this server_shutdown_post_cb_ is needed. The previous shutdown logic is 100% no-op since it is never registered. Weak here is going to check if this object is still alive, and then the callback can be executed. The original implementation is posting the completion_cb in the destructor leading to issues which I think the root cause is: since it is latching the completion_cb, the cb_guard will never be executed, so that the server will not shutdown until it is timeout, and then further cause other segment issues.

My current version also has a issue to bypass some callbacks by posting completion_cb which is (dispatcher_.exit()) directly. Based on the above analysis, I tend to remove the whole shutdown registration code block since it is never used, WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the reason was to prolong Wasm lifetime but I agree - it's difficult to understand now why.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, it seems like the only purpose is to make sure that the Wasm instance is deleted before proceeding with shutdown, but was no-op before. Removing it SGTM as well.

Signed-off-by: Boteng Yao <boteng@google.com>
@botengyao botengyao changed the title wasm: fix that shutdown callback is not registered to lifetime_notifier wasm: remove the shutdown callback in lifetime_notifier Oct 29, 2024
Signed-off-by: Boteng Yao <boteng@google.com>
@botengyao
Copy link
Member Author

/retest

@botengyao
Copy link
Member Author

/assign @yanavlasov

for final pass, thanks!

@botengyao
Copy link
Member Author

ping @yanavlasov, thanks!

@yanavlasov yanavlasov merged commit b982f30 into envoyproxy:main Nov 5, 2024
20 checks passed
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.

Lifecycle bug in WASM filter
4 participants