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

sql,changefeedccl: miscellaneous cleanup of server shutdown #125357

Merged
merged 3 commits into from
Jun 12, 2024

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Jun 7, 2024

stats: refresh stats cache entries in async tasks

Previously, we would use "vanilla" goroutines when refreshing stats entries (triggered by the rangefeed), but this has a downside of not respecting the stopper signal to shutdown. That could cause the "short-living monitors are not stopped" assertion to fire on the server shutdown in tests. This commit prevents that by using the stopper to start async tasks for the entry refresh (which has additional benefits like recovering from panics).

Fixes: #125329.

sql: use async task for plan hook goroutine

This commit is similar in spirit as the previous one and replaces usage of the "vanilla" goroutine with an async task connected to the stopper for the hookFn plan node. This allows us to synchronize the server shutdown and cancellation of the hook task.

Fixes: #125139.

changefeedccl: create separate root changefeed memory monitor

This commit introduces a "root" changefeed memory monitor that will be the parent for all CDC DistSQL flows. The primary motivation behind this change is to disconnect the CDC flow from the planner's monitor (which is "txn" monitor of the connection that started the changefeed). This is needed since that connection can be closed before the CDC flow is cleaned up which triggers the "short-living non-stopped monitor" assertion. An additional benefit of this change is improved observability since we can now easily track the memory usage across all changefeeds.

Release note: None

Previously, we would use "vanilla" goroutines when refreshing stats
entries (triggered by the rangefeed), but this has a downside of not
respecting the stopper signal to shutdown. That could cause the
"short-living monitors are not stopped" assertion to fire on the server
shutdown in tests. This commit prevents that by using the stopper to
start async tasks for the entry refresh (which has additional benefits
like recovering from panics).

Release note: None
This commit is similar in spirit as the previous one and replaces usage
of the "vanilla" goroutine with an async task connected to the stopper
for the hookFn plan node. This allows us to synchronize the server
shutdown and cancellation of the hook task.

Release note: None
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich yuzefovich force-pushed the fix-assertion branch 2 times, most recently from 2c8d00a to cfb3731 Compare June 7, 2024 23:43
This commit introduces a "root" changefeed memory monitor that will be
the parent for all CDC DistSQL flows. The primary motivation behind
this change is to disconnect the CDC flow from the planner's monitor
(which is "txn" monitor of the connection that started the changefeed).
This is needed since that connection can be closed _before_ the CDC flow
is cleaned up which triggers the "short-living non-stopped monitor"
assertion. An additional benefit of this change is improved
observability since we can now easily track the memory usage across all
changefeeds.

Release note: None
@yuzefovich yuzefovich marked this pull request as ready for review June 8, 2024 05:07
@yuzefovich yuzefovich requested review from a team as code owners June 8, 2024 05:07
@yuzefovich yuzefovich requested review from msbutler and removed request for a team and msbutler June 8, 2024 05:07
Copy link
Collaborator

@rharding6373 rharding6373 left a comment

Choose a reason for hiding this comment

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

:lgtm: Thanks Yahor!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @michae2)

@yuzefovich
Copy link
Member Author

TFTR!

bors r+

@craig craig bot merged commit f5e65c5 into cockroachdb:master Jun 12, 2024
22 checks passed
@yuzefovich yuzefovich deleted the fix-assertion branch June 12, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants