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

SIGINFO prints thread backtraces #1320

Merged
merged 1 commit into from Sep 12, 2019
Merged

SIGINFO prints thread backtraces #1320

merged 1 commit into from Sep 12, 2019

Conversation

nateberkopec
Copy link
Member

@nateberkopec nateberkopec commented Jun 3, 2017

Closes #1041

I'm open to suggestions for other signals. SIGINFO is only present on *BSD.

Todo:

  • Figure out how to fan out the SIGINFO from the parent to child processes (currently have to send it to each child
  • Tests in single/cluster that SIGINFO prints threads

@olleolleolle
Copy link
Contributor

@nateberkopec For comparison to other gems. The sidekiq gem uses the TTIN signal to print threads' backtraces.

@nateberkopec
Copy link
Member Author

@olleolleolle Unfortunately we already use TTIN to increase worker count :(

@olleolleolle
Copy link
Contributor

Is the use-case this awesome:

Hit Ctrl-T in your *BSD terminal to print thread backtraces

(This is a super-neat feature.)

@olleolleolle
Copy link
Contributor

(Also, could you rebase this on top of current master? The build is green on master.)

@nateberkopec
Copy link
Member Author

Maybe I can do both SIGINFO and a pumactl command. On prod/Linux you can use the pumactl command, on dev you can just ctrl-t or SIGINFO.

@harmdewit
Copy link
Contributor

I just wanted to mention that this PR helped me a lot with finding an infinite loop in the middle of a request, thanks!

@nateberkopec
Copy link
Member Author

@harmdewit Did you just use it as-is? Haven't looked at this in years but if it "just works" there's no reason not to merge.

@harmdewit
Copy link
Contributor

Yes, I copied and pasted the changes to my locally bundled gem and then did a kill -SIGINFO <pid> which gave the stacktrace which a normal Ctrl-c didn't.

Copy link
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

LGTM!

@nateberkopec
Copy link
Member Author

I'm OK with shipping this w/o fanout from parent to child but I really need to write a test.

@@ -952,4 +947,11 @@ def test_request_body_wait_chunked

assert request_body_wait >= 1000
end

def test_siginfo_prints_thread_traces
Copy link
Member Author

Choose a reason for hiding this comment

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

need to fix this test name as this particular test has nothing to do with the signal

@nateberkopec nateberkopec removed the waiting-for-changes Waiting on changes from the requestor label Sep 11, 2019
@nateberkopec
Copy link
Member Author

Needs some polish/cleanup and then an issue for future feature ideas (fanout from master, pumactl command).

Super basic server test

Add tests for single/cluster

Cleanup
@nateberkopec nateberkopec merged commit e96e798 into master Sep 12, 2019
@nateberkopec nateberkopec deleted the siginfo branch March 14, 2020 21:52
stanhu added a commit to stanhu/puma that referenced this pull request Mar 22, 2020
puma#1320 added support for using SIGINFO,
but this is only available on BSD-based systems. SIGPROF is on Linux.
stanhu added a commit to stanhu/puma that referenced this pull request Mar 22, 2020
puma#1320 added support for using SIGINFO,
but this is only available on BSD-based systems. SIGPROF is on Linux.

This is useful for debugging infinite loops or slow performance.
stanhu added a commit to stanhu/puma that referenced this pull request Mar 22, 2020
puma#1320 added support for using SIGINFO,
but this is only available on BSD-based systems. SIGPROF is on Linux.

This is useful for debugging infinite loops or slow performance.
stanhu added a commit to stanhu/puma that referenced this pull request Mar 22, 2020
puma#1320 added support for using SIGINFO,
but this is only available on BSD-based systems. SIGPROF is on Linux.

This is useful for debugging infinite loops or slow performance.
stanhu added a commit to stanhu/puma that referenced this pull request Mar 24, 2020
puma#1320 added support for using SIGINFO,
but this is only available on BSD-based systems. SIGWINCH is on Linux.

This is useful for debugging infinite loops or slow performance.
nateberkopec pushed a commit that referenced this pull request Mar 24, 2020
#1320 added support for using SIGINFO,
but this is only available on BSD-based systems. SIGWINCH is on Linux.

This is useful for debugging infinite loops or slow performance.
@fschwahn
Copy link
Contributor

fschwahn commented Dec 6, 2021

FYI: This is really cool, but missing from docs/signals.md so a bit hard to discover (I only stumbled upon it here when I was actively looking for such a feature).

@dentarg
Copy link
Member

dentarg commented Dec 6, 2021

@fschwahn good catch, want to contribute a PR adding it to the docs?

fschwahn added a commit to fschwahn/puma that referenced this pull request Dec 6, 2021
fschwahn added a commit to fschwahn/puma that referenced this pull request Dec 6, 2021
This was added in puma#1320 but was missing from documentation.
@fschwahn
Copy link
Contributor

fschwahn commented Dec 6, 2021

#2762

dentarg pushed a commit that referenced this pull request Dec 6, 2021
The feature was added in #1320 but was missing from documentation.
JuanitoFatas pushed a commit to JuanitoFatas/puma that referenced this pull request Sep 9, 2022
The feature was added in puma#1320 but was missing from documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debugging signal handler
5 participants