Using Arthas for Hot Updating dble: A Step‑by‑Step Guide
This article explains how to install and use the Arthas Java diagnostic tool to perform hot‑code updates in the dble middleware, covering environment preparation, decompiling classes, modifying source, recompiling with memory‑compile, and applying the changes via both interactive and non‑interactive commands.
The author, a member of the dble development team, compares two tools for hot‑updating small dble versions—Arthas and JRebel—concluding that Arthas is more effective for modifying static classes and proceeds to demonstrate its usage.
Prerequisites
JRE used by dble
A running dble instance version 3.20.10.0
Arthas Installation
Download the latest release from the official GitHub page (e.g., version 3.4.5) and unzip it:
$ cd /opt/arthas
$ wget https://github.com/alibaba/arthas/releases/download/arthas-all-3.4.5/arthas-bin.zip
$ unzip arthas-bin.zipOther installation methods are documented at the Arthas website.
Running Arthas
Start the interactive console by attaching to the dble process ID:
$ java -jar arthas-boot.jar <dble_pid>For example, to modify a log message generated when an unsupported SQL statement is encountered, the following steps are performed inside the Arthas console.
Decompile with jad
$ jad --source-only com.actiontech.dble.server.ServerQueryHandler > /tmp/ServerQueryHandler.javaThe relevant snippet from the decompiled file shows the log statement:
case 254: {
LOGGER.info("Unsupported statement:" + sql);
this.service.writeErrMessage(1149, "Unsupported statement");
return;
}Find Class Loader with sc
$ sc -d com.actiontech.dble.server.ServerQueryHandler | grep classLoaderHash
classLoaderHash 18b4aac2Modify Source and Recompile with mc
After editing the decompiled file (e.g., changing the log text), recompile the class in memory:
case 254: {
LOGGER.info("Unsupported statement test test test test test:" + sql);
this.service.writeErrMessage(1149, "Unsupported statement");
return;
}Use the hash obtained from sc as the -c argument:
$ mc -c 18b4aac2 /tmp/ServerQueryHandler.javaApply the Change with redefine
$ redefine /tmp/com/actiontech/dble/server/ServerQueryHandler.class
redefine success, size: 1, classes:
com.actiontech.dble.server.ServerQueryHandlerThe updated class now produces the modified log output, as shown in the accompanying screenshots.
Non‑Interactive Execution
The same redefine command can be run without entering the Arthas console, enabling script automation:
$ java -jar arthas-boot.jar <dble_pid> -c "redefine /tmp/com/actiontech/dble/server/ServerQueryHandler.class" > /dev/nullThis approach simplifies batch updates and integration into deployment pipelines.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.