Common problems when debugging Deephaven
This guide covers two Deephaven-specific reasons Groovy code doesn't behave as you expect under a debugger: breakpoints in Groovy scripts that are never hit, and table operations that evaluate lazily. Neither is caused by your debugger setup.
The examples use IntelliJ IDEA connected to Docker-run Deephaven, but these problems apply to any debugger attached to the server.
Setup for the examples
The examples below use an Application Mode script loaded at server startup. Inside your Docker debug project (the one containing docker-compose.yml), create the following structure:
debug-demo.app:
debug-demo.groovy:
The script builds the same column twice: tLazy with updateView and tEager with select.
Note
Query strings can call a function you define in your script only when it is a closure assigned to a top-level variable without def, as addOne = { long x -> x + 1 } is above. That assignment puts the closure in the Query Scope, the set of variables query strings can use. Query strings can't call:
- A method defined with
def name(...) { ... }. - A closure stored in a variable declared with
def.
Add -Ddeephaven.application.dir=/data/app.d to START_OPTS in your docker-compose.yml. The volumes entry mounts your project's data directory at /data in the container, so data/app.d is /data/app.d there:
Note
The 127.0.0.1: prefix on each port publishes it only on your own machine. This matters because, with this configuration, anyone who can reach either port has full access to the server:
- The
-DAuthHandlers=io.deephaven.auth.AnonymousAuthenticationHandlersetting turns on anonymous authentication, so any client that reaches port10000can run code without a password. - Any client that reaches port
5005can attach a debugger to the server's JVM.
Inside the container, the debug agent still listens on all interfaces (address=*:5005), so that Docker can forward the port to it.
Stop the running container (Ctrl+C in its terminal), then run docker compose up again from the directory containing docker-compose.yml. Compose recreates the container with the new START_OPTS, and the script loads at startup. docker compose restart doesn't pick up changes to docker-compose.yml.
Breakpoints in Groovy scripts are not hit
You've set a breakpoint in a Groovy script, whether loaded with Application Mode or entered in the Deephaven console. IntelliJ is connected, but execution runs through the breakpoint without pausing.
Deephaven compiles Groovy code dynamically before evaluating it, whether the code comes from an Application Mode script or the console. IntelliJ can't match the compiled class to your .groovy file, so it doesn't pause at your breakpoints. Two changes cause the mismatch:
- Line numbers: Deephaven prepends a
package io.deephaven.dynamic;declaration, which shifts every line in the compiled class down by one. - Class name: The compiled class gets a generated name, not your file's name. The name ends in a counter that increases with every script the session runs, including Deephaven's startup scripts, so your numbers will differ:
- An Application Mode script is named after its file path, with every character that isn't a letter or digit replaced by
_. For example,/data/app.d/./debug-demo.groovybecomesio.deephaven.dynamic._data_app_d___debug_demo_groovy_6. - Console code is named
Script_plus the counter, for exampleio.deephaven.dynamic.Script_7.
- An Application Mode script is named after its file path, with every character that isn't a letter or digit replaced by
As a workaround, use println to trace execution. The output appears in the server log. For a source build, that's the terminal where you ran ./gradlew server-jetty-app:run -Pgroovy. For Docker, it's the container logs, which you can follow with docker compose logs:
Update debug-demo.groovy to add trace output:
When the server starts and loads the script, the log shows [DEBUG] lines from addOne for tEager. For why tLazy produces none, see Lazy evaluation of some table operations.
To step through the Deephaven Java code your script calls, set breakpoints in Deephaven's Java source instead. See Use the IntelliJ debugger for Docker-run Deephaven, or Use the IntelliJ debugger for built-from-source Deephaven.
Lazy evaluation of some table operations
Some Deephaven table operations, including view, updateView, and lazyUpdate, use lazy evaluation. Deephaven doesn't compute a column's values until something reads them, such as a downstream operation or opening the table in the Deephaven web IDE.
Until then, the closure that the column's formula calls never runs. A println trace in it prints nothing, and the debugger doesn't stop at a breakpoint in the Deephaven Java code that evaluates the column.
The last two lines of debug-demo.groovy build the same column both ways:
tLazyusesupdateView, so Deephaven doesn't calladdOnefor it when the script loads. The trace prints nothing until something reads theYcolumn oftLazy.tEagerusesselect, which evaluates all expressions immediately and stores the results. With theprintlntrace from Breakpoints in Groovy scripts are not hit, the logs show 20 lines of output when the script loads, two for each of its 10 rows.
To force evaluation for debugging purposes, use select in place of updateView.