@@ -1054,14 +1054,21 @@ private void wipeCluster() throws Exception {
1054
1054
1055
1055
private void waitForClusterUpdates () throws Exception {
1056
1056
logger .info ("Waiting for all cluster updates up to this moment to be processed" );
1057
+
1057
1058
try {
1058
1059
assertOK (adminClient ().performRequest (new Request ("GET" , "_cluster/health?wait_for_events=languid" )));
1059
1060
} catch (ResponseException e ) {
1060
1061
if (e .getResponse ().getStatusLine ().getStatusCode () == HttpStatus .SC_REQUEST_TIMEOUT ) {
1062
+ StringBuilder logMessage = new StringBuilder ("Timed out waiting for cluster updates to be processed." );
1061
1063
final var pendingTasks = getPendingClusterStateTasks ();
1062
1064
if (pendingTasks != null ) {
1063
- logger .error ("Timed out waiting for cluster updates to be processed, {}" , pendingTasks );
1065
+ logMessage .append ('\n' ).append (pendingTasks );
1066
+ }
1067
+ final var hotThreads = getHotThreads ();
1068
+ if (hotThreads != null ) {
1069
+ logMessage .append ("\n Hot threads: " ).append (hotThreads );
1064
1070
}
1071
+ logger .error (logMessage .toString ());
1065
1072
}
1066
1073
throw e ;
1067
1074
}
@@ -1071,8 +1078,8 @@ private static String getPendingClusterStateTasks() {
1071
1078
try {
1072
1079
Response response = adminClient ().performRequest (new Request ("GET" , "/_cluster/pending_tasks" ));
1073
1080
List <?> tasks = (List <?>) entityAsMap (response ).get ("tasks" );
1074
- if (false == tasks .isEmpty ()) {
1075
- StringBuilder message = new StringBuilder ("there are still running tasks:" );
1081
+ if (tasks .isEmpty () == false ) {
1082
+ StringBuilder message = new StringBuilder ("There are still running tasks:" );
1076
1083
for (Object task : tasks ) {
1077
1084
message .append ('\n' ).append (task .toString ());
1078
1085
}
@@ -1084,6 +1091,18 @@ private static String getPendingClusterStateTasks() {
1084
1091
return null ;
1085
1092
}
1086
1093
1094
+ private String getHotThreads () {
1095
+ try {
1096
+ Response response = adminClient ().performRequest (
1097
+ new Request ("GET" , "/_nodes/hot_threads?ignore_idle_threads=false&threads=9999" )
1098
+ );
1099
+ return EntityUtils .toString (response .getEntity ());
1100
+ } catch (IOException e ) {
1101
+ logger .error ("Failed to retrieve hot threads in the cluster during cleanup" , e );
1102
+ }
1103
+ return null ;
1104
+ }
1105
+
1087
1106
/**
1088
1107
* This method checks whether ILM policies or templates get recreated after they have been deleted. If so, we are probably deleting
1089
1108
* them unnecessarily, potentially causing test performance problems. This could happen for example if someone adds a new standard ILM
0 commit comments