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

don't hang on panic in Run() #2792

Merged
merged 1 commit into from
May 21, 2024
Merged

Conversation

umanwizard
Copy link
Contributor

Right now we just hang forever waiting on this wg if we panic anywhere under Run, so the panic will never be reported, the process will never be restarted, etc.

To fix this, re-raise the panic and don't call wg.Wait() if we're panicking.

@umanwizard umanwizard requested a review from a team as a code owner May 16, 2024 14:51
@gnurizen
Copy link
Contributor

I don't get it, why wouldn't the panic blow right passed the Wait()? Is there another recover involved?

@brancz brancz merged commit c16f1e7 into parca-dev:main May 21, 2024
11 of 12 checks passed
@umanwizard
Copy link
Contributor Author

@gnurizen Defers do still run when unwinding the stack for a panic.

@gnurizen
Copy link
Contributor

Ah that makes sense, I would have looked at fixing it by removing the defer, calling Wait in a defer seems questionable.

@gnurizen
Copy link
Contributor

Actually what we should probably be doing is passing a new derived context to all the CPU sub-goroutines and we should cancel that before we call wait, ie:

    ctx,cancel = context.WithCancel(ctx)
    var wg sync.WaitGroup
    defer cancel()
    defer wg.Wait()
    ...

Then we should only wait until the other go-routines get the cancel signal and return.

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.

None yet

3 participants