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

Print thread dump on specific signals #27

Merged
merged 3 commits into from
Oct 21, 2024

Conversation

Bouncheck
Copy link
Contributor

@Bouncheck Bouncheck commented Oct 21, 2024

Adds a signal handler that will print thread dump to standard output on
the following signals: SIGABRT, SIGTERM, SIGINT.
Does not work for SIGKILL or other abrupt shutdowns.

Addresses #28

@Bouncheck Bouncheck force-pushed the thread-dump-on-shutdown branch from 5d1911d to 5fe921d Compare October 21, 2024 13:23
@@ -93,11 +95,12 @@ public static final class Options extends GroupedOptions
final OptionSimple hdrOutputFile = new OptionSimple("hdrfile=", ".*", null, "Log to a file", false);
final OptionSimple interval = new OptionSimple("interval=", "[0-9]+(ms|s|)", "1s", "Log progress every <value> seconds or milliseconds", false);
final OptionSimple level = new OptionSimple("level=", "(minimal|normal|verbose)", "normal", "Logging level (minimal, normal or verbose)", false);
final OptionSimple printThreadDumpOnShutdown = new OptionSimple("print-thread-dump-on-shutdown", "", null, "Print local thread dump to the standard output on shutdown (normal, SIGTERM, SIGINT, SIGABRT).", false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I will require additional code on dtest side to understand whethere given c-s support this option or not.
It would be better to just do that by default, but only if c-s was terminated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reworked to a version without new option.

Comment on lines +33 to +34
import sun.misc.Signal;
import sun.misc.SignalHandler;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are the sun.misc.* inside the internal parts of JDK and shouldn't be accessed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but outside of shutdown hooks I don't know of a way to do this. If it ever gets removed I assume there will be something else for signal handling and in that case this change should be easy to port or ditch altogether since it does not go too deep.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are right, there is no other way to get to the Unix signals, and handle specific signal through Java Public APIs

@@ -88,6 +94,14 @@ private static int run(String[] arguments)
return 1;
}

if (settings.log.printThreadDumpOnShutdown) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
System.out.println("Shutdown thread dump:");
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should not print thread dump when it terminates in a regular way, only when it is terminated by signal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

Adds a signal handler that will print thread dump to standard output on
the following signals: SIGABRT, SIGTERM, SIGINT.
@Bouncheck Bouncheck force-pushed the thread-dump-on-shutdown branch from 5fe921d to 67f8796 Compare October 21, 2024 14:28
@Bouncheck
Copy link
Contributor Author

Removed shutdown hook. Switched to solution with only signal handler. Now no config options are needed and thread dump will be printed only on three mentioned signals.

@Bouncheck Bouncheck changed the title Add thread dump on shutdown Print thread dump on specific signals Oct 21, 2024
@CodeLieutenant CodeLieutenant added the enhancement New feature or request label Oct 21, 2024
CodeLieutenant and others added 2 commits October 21, 2024 17:02
Co-authored-by: Dmitry Kropachev <dmitry.kropachev@gmail.com>
@CodeLieutenant CodeLieutenant merged commit 1f432b8 into scylladb:master Oct 21, 2024
2 checks passed
CodeLieutenant added a commit to CodeLieutenant/scylla-cluster-tests that referenced this pull request Nov 21, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
CodeLieutenant added a commit to CodeLieutenant/scylla-cluster-tests that referenced this pull request Nov 21, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
CodeLieutenant added a commit to CodeLieutenant/scylla-cluster-tests that referenced this pull request Nov 23, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
CodeLieutenant added a commit to CodeLieutenant/scylla-cluster-tests that referenced this pull request Nov 23, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 26, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
mergify bot pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 26, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)

# Conflicts:
#	defaults/docker_images/cassandra-stress/values_cassandra-stress.yaml
mergify bot pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 26, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)

# Conflicts:
#	defaults/docker_images/cassandra-stress/values_cassandra-stress.yaml
mergify bot pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 26, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
mergify bot pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 26, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)

# Conflicts:
#	defaults/docker_images/cassandra-stress/values_cassandra-stress.yaml
mergify bot pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 26, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
mergify bot pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 26, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
mergify bot pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 26, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 27, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 27, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 27, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 27, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 28, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 28, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 28, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 28, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Nov 28, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)

# Conflicts:
#	defaults/docker_images/cassandra-stress/values_cassandra-stress.yaml
fruch pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request Dec 1, 2024
Main reason for version change:

Using cassandra-stress 3.17 to mittigate
- Switch to ReplicaOrdering.RANDOM for select LBPs
  [32](scylladb/cassandra-stress#32)

Other Noticable Changes since the last version used in SCT:

- Add support for hostname verification
  [31](scylladb/cassandra-stress#31)
- Print thread dump on specific signals
  [27](scylladb/cassandra-stress#27)
- Replace uninterruptible wait
  [26](scylladb/cassandra-stress#26)
- Make it use DCAwareRoundRobinPolicy unless rack is provided
  [21](scylladb/cassandra-stress#21)
- feature(docker): adding support for dependabot
  [19](scylladb/cassandra-stress#19)

Signed-off-by: Dusan Malusev <dusan.malusev@scylladb.com>
(cherry picked from commit 02997a6)

# Conflicts:
#	defaults/docker_images/cassandra-stress/values_cassandra-stress.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants