-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Introduced StateTrackingHandler. StateTrackingHandler is a troubleshooting Handler that helps to identify those cases where the Handler/Request/Response APIs are used improperly. In particular, it tracks the events described in StateTrackingHandler.Listener, such as the Handler callback not completed, or blocking demand callback, or a write callback not completed, etc. It also provides dump() capabilities, so the current requests and their state is dumped to help troubleshooting. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
- Loading branch information
Showing
18 changed files
with
1,958 additions
and
13 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...mentation/src/main/asciidoc/operations-guide/modules/module-state-tracking.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
[[og-module-state-tracking]] | ||
===== Module `state-tracking` | ||
|
||
The `state-tracking` Jetty module inserts the `StateTrackingHandler` at the beginning of the Handler chain. | ||
|
||
`StateTrackingHandler` is a xref:og-troubleshooting[troubleshooting] `Handler` that tracks usages of `Handler`/`Request`/`Response` asynchronous APIs, and logs at warning level invalid usages of the APIs that may lead to blockages, deadlocks, or missing completion of ``Callback``s. | ||
|
||
This module can be enabled to troubleshoot web applications that do not behave as expected, for example: | ||
|
||
* That consume a lot of threads (possibly because they block). | ||
* That do not send responses (or send only partial responses) to clients. | ||
* That timeout when apparently they have received or have sent all data. | ||
|
||
The module properties are: | ||
|
||
---- | ||
include::{jetty-home}/modules/state-tracking.mod[tags=documentation] | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...rc/main/asciidoc/operations-guide/troubleshooting/troubleshooting-handlers.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
[[og-troubleshooting-handlers]] | ||
==== Troubleshooting Handlers | ||
|
||
[[og-troubleshooting-handlers-state-tracking]] | ||
===== `StateTrackingHandler` | ||
|
||
Jetty's `StateTrackingHandler` (described in xref:og-module-state-tracking[this module]) can be used to troubleshoot problems in web applications. | ||
|
||
`StateTrackingHandler` tracks the usages of `Handler`/`Request`/`Response` asynchronous APIs by web applications, emitting events (logged at warning level) when an invalid usage of the APIs is detected. | ||
|
||
In conjunction with xref:og-troubleshooting-dump[dumping the Jetty component tree], it dumps the state of current requests, detailing whether they have reads or writes that are pending, whether callbacks have been completed, along with thread stack traces (including virtual threads) of operations that have been started but not completed, or are stuck in blocking code. | ||
|
||
You need to enable the `state-tracking` Jetty module, and configure it to track what you are interested in tracking (for more details, see the link:{javadoc-url}/org/eclipse/jetty/server/handler/StateTrackingHandler.html[javadocs]). | ||
|
||
// TODO: add a section about DebugHandler. |
Binary file added
BIN
+262 KB
...ty-documentation/src/main/asciidoc/programming-guide/images/jmc-server-dump.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
jetty-core/jetty-server/src/main/config/etc/jetty-state-tracking.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd"> | ||
|
||
<Configure id="Server" class="org.eclipse.jetty.server.Server"> | ||
<Call name="insertHandler"> | ||
<Arg> | ||
<New class="org.eclipse.jetty.server.handler.StateTrackingHandler"> | ||
<Set name="handlerCallbackTimeout" property="jetty.stateTracking.handlerCallbackTimeout" /> | ||
<Set name="completeHandlerCallbackAtTimeout" property="jetty.stateTracking.completeHandlerCallbackAtTimeout" /> | ||
<Set name="demandCallbackTimeout" property="jetty.stateTracking.demandCallbackTimeout" /> | ||
<Set name="writeTimeout" property="jetty.stateTracking.writeTimeout" /> | ||
<Set name="writeCallbackTimeout" property="jetty.stateTracking.writeCallbackTimeout" /> | ||
</New> | ||
</Arg> | ||
</Call> | ||
</Configure> |
39 changes: 39 additions & 0 deletions
39
jetty-core/jetty-server/src/main/config/modules/state-tracking.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[description] | ||
Enables the StateTrackingHandler as the outermost Handler, to track | ||
the state of various Handler/Request/Response asynchronous APIs. | ||
|
||
[tags] | ||
server | ||
debug | ||
|
||
[depends] | ||
server | ||
|
||
[before] | ||
cross-origin | ||
graceful | ||
gzip | ||
secure-redirect | ||
statistics | ||
thread-limit | ||
|
||
[xml] | ||
etc/jetty-state-tracking.xml | ||
|
||
[ini-template] | ||
# tag::documentation[] | ||
## The timeout in ms for the completion of the handle() callback. | ||
# jetty.stateTracking.handlerCallbackTimeout=0 | ||
|
||
## Whether the handle() callback is completed in case of timeout. | ||
# jetty.stateTracking.completeHandlerCallbackAtTimeout=false | ||
|
||
## The timeout in ms for the execution of the demand callback. | ||
# jetty.stateTracking.demandCallbackTimeout=0 | ||
|
||
## The timeout in ms for the execution of a response write. | ||
# jetty.stateTracking.writeTimeout=0 | ||
|
||
## The timeout in ms for the execution of the response write callback. | ||
# jetty.stateTracking.writeCallbackTimeout=0 | ||
# end::documentation[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.