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

Improper use of Raft::metrics() can block the RaftCore async task and underlying OS thread #1238

Closed
2 of 6 tasks
SteveLauC opened this issue Aug 30, 2024 · 1 comment · Fixed by #1240
Closed
2 of 6 tasks
Assignees

Comments

@SteveLauC
Copy link
Collaborator

What kind of doc do you ask for?

  • Code comments.
  • Architecture design.
  • Algorithm explanation.
  • Guide.
  • Examples.

Describe the information you want

Document that:

When your AsyncRuntime::Watch uses tokio::watch, you use Raft::metrics()/server_metrics()/data_metrics() interface and hold the acquired Watch::Ref instance in an improper way, this can block the RaftCore async task as well as the underlying OS thread. If you are using a single-threaded runtime, like Monoio, everything is blocked now.

Root cause: tokio::watch uses synchronous RwLock, Watch::Ref contains a read guard, and the first thing that the RaftCore async task does is flush_metrics(), which needs to acquire the write guard, if there is a Watch::Ref instance exists, flush_metrics() will wait, thus it blocks the RaftCore async task and the underlying OS thread.

Describe the status of the current doc

  • Is there any doc yet?:
    Currently we don't have any doc on this.

  • What other information should be added?
    I guess no.

  • I'll open a pull request for it:)

Copy link

👋 Thanks for opening this issue!

Get help or engage by:

  • /help : to print help messages.
  • /assignme : to assign this issue to you.

@drmingdrmer drmingdrmer self-assigned this Sep 1, 2024
drmingdrmer added a commit to drmingdrmer/openraft that referenced this issue Sep 1, 2024
Add comprehensive documentation for the `Watch` trait and its associated traits
in the `AsyncRuntime` module. This improves code clarity and helps developers
understand the purpose and usage and behavior of these traits.

- Fix: databendlabs#1238
drmingdrmer added a commit to drmingdrmer/openraft that referenced this issue Sep 1, 2024
Add comprehensive documentation for the `Watch` trait and its associated traits
in the `AsyncRuntime` module. This improves code clarity and helps developers
understand the purpose and usage and behavior of these traits.

- Fix: databendlabs#1238
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 a pull request may close this issue.

2 participants