8000 Show running thread in async registry by jvolmer · Pull Request #21776 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Show running thread in async registry #21776

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

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

jvolmer
Copy link
Contributor
@jvolmer jvolmer commented May 19, 2025

Arangod crashed after requesting the async registry, due to a bug: When reading the registry, every promise inside it requests the thread name of its owning thread in order to print that name. The problem is that this owning thread does not need to exist any more although the promise still exists, e.g. because the promise was suspended (so is currently not running at all) or resumed on another thread. So when requesting the thread name of a thread that does not exist any more, we crash.
Actually, the owning thread is not interesting for the user, the user just wants to see on which thread the promise is currently running (if it is running). Therefore, this PR adds a running_thread member to the promise and updates it when a state change occurs: if the state is running, then the promise has a running thread, otherwise the promise has no running thread.
The PR also updates the pretty printers of the async registry.

@jvolmer jvolmer self-assigned this May 19, 2025
@cla-bot cla-bot bot added the cla-signed label May 19, 2025
Copy link
Member
@neunhoef neunhoef left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -36,8 +36,7 @@ struct ThreadId {
};
template<typename Inspector>
auto inspect(Inspector& f, ThreadId& x) {
return f.object(x).fields(f.field("LWPID", x.kernel_id),
f.field("name", x.name()));
return f.object(x).fields(f.field("LWPID", x.kernel_id));
Copy link
Member

Choose a reason for hiding this comment

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

Is there a situation where having the posix_id in addition to kernel_id might be helpful to know while we don't have the name?

Copy link
Contributor Author
@jvolmer jvolmer May 20, 2025

Choose a reason for hiding this comment

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

As far as I understood, the posix id does not provide more information, but it can act as a handle to do more stuff with it via the posix API, e.g. get the thread name yourself. The lwpid is just a low level thread id of the kernel. So perhaps it can be useful to additionally have the posix id as well. I'll add it back.

Copy link
Member

Choose a reason for hiding this comment

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

It's fine by me without it, it really was an open question. The cases I can think of I'd like to see the LWPID, and can't think of something where I'd need the posix_id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0