Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

From time to time debugging a live Flink cluster may be a good choice to understand an issue, or simply to get a go line by line and get a better feeling of how a running Flink system works.

To do so, the Java platform allows developer to attach a debugger to a running JVM.

Editing the startup script

The JVM you wish to attach the debugger to has to be started with a certain set of parameters for the remote debugging capability to be enabled.

In particular, you should edit the startup script you use (either bin/yarn-session.sh for YARN or bin/flink-daemon.sh for the standalone scheduler) adding the following parameters to the java command:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

The command specifies to open the 5005 port (make sure your firewall poses no problem) and to suspend the process until a debugger is attached to the process. If you wish to allow remote debugging without having to attach a debugger before startup, simply set suspend=n.

Attach a remote debugger with IntelliJ IDEA

IntelliJ IDEA has a built-in debugger that is compatible with Java's remote debugging specification.

To use it you just have to edit the running configurations (Run > Edit configurations...) and add a new configuration (clicking the + sign on the upper left corner of the dialog) with the "Remote" template. You're free to name this configuration any way you want (perhaps the remote host and port you're connecting to can be a sensible name to use).

To attach to the process you now have to specify (in the "Settings" pane) the remote address and port on which the JVM will be listening for the remote debugger. Running this configuration will attach IntelliJ IDEA to the running JVM (and possibly unsuspend it if you specified suspend=y).

Attach a remote debugger with Eclipse

TODO