Perform a hard reset of RT in KX Sensors¶
This page explains how to perform a hard reset of RT, which clears all RT log and state data across every node in the cluster.
This procedure causes data loss
A hard reset deletes RT's logs and Raft state, along with the stream-processor checkpoints and watermarks that depend on them. Messages that subscribers haven't yet consumed are lost, and replay history is discarded. Treat it as a last resort, back up everything the procedure deletes, and where possible contact KX to carry it out with you — KX normally performs this procedure on a customer's behalf.
Before you begin¶
The procedure operates on four directories. Resolve each one from your own systemParams.yaml rather than assuming the defaults, since these are commonly relocated onto dedicated volumes.
| Parameter | Description | Default |
|---|---|---|
emsLogDir |
Directory for EMS logs, substituted in place of ${EMSLOGDIR}. Holds RT's sequencer logs, Raft state, and session files. |
${KXS_ROOT}/ems/${NODE} |
opDataDir |
Process-specific operational data directory, substituted in place of ${OPDATA}. Holds stream-processor checkpoints and, by default, watermarks. |
${KXS_ROOT}/opdata_${NODE}/${INST} |
idbDir |
Root of the on-disk IDB. | ${KXS_ROOT}/db/idb |
wmDir |
Watermark directory. Deployments sometimes move this outside opDataDir. |
${OPDATA}/wm |
Use the hard reset script¶
KX Sensors includes a script, hardReset.sh, that performs the manual procedure on every node for you. It's installed in ${KXS_ROOT}/packages/kxs-core/src/scripts/Linux/dr/, alongside the disaster recovery scripts, which also call it.
Run the script on one node, as the KX Sensors user, with the KX Sensors environment sourced. It runs the steps on the other nodes over passwordless SSH.
./hardReset.sh [-n <node>]
| Syntax | hardReset.sh [-n <node>] |
|---|---|
| Flags | -n <node>Resets only the specified node. If you omit it, the script resets every node. -h, --helpPrints the usage. |
The script:
- Stops the system.
- On each node, asks whether to back up each directory before it deletes the directory's contents, and copies it to a backup directory that you choose.
- Deletes the RT data in
emsLogDir, and the checkpoints and watermarks of every process, whereveropDataDir,chkpDir, andwmDirplace them. - Resets the position stored in
IdbStatus. - Blocks the system and restarts it, so that DBW can catch up before the nodes serve queries or become failover candidates.
The script prompts for each backup, so run it interactively, and capture its output to a file, for example ./hardReset.sh 2>&1 | tee hard-reset.log.
Perform the reset manually¶
Perform every step on each node in the cluster.
-
Stop all nodes.
kxsctl stop system -
Back up the contents of
emsLogDir. Everything deleted below lives under the directories listed above, so take copies before you continue. -
Delete the full contents of
emsLogDir. -
Delete the stream-processor checkpoints and watermarks under
opDataDir. Each process has its own subdirectory holding achkpfolder and awmfolder; remove both from every process. The watermarks SM uses to subscribe to theemsintstream,eoxandseq, are among those removed here.root@kxsa:~/kxs/opdata_A# ls -ld */chkp */wm drwxr-xr-x. 2 root root 71 May 8 14:03 kxsMDL_A/chkp drwxr-xr-x. 2 root root 30 May 8 14:03 kxsMDL_A/wm drwxr-xr-x. 2 root root 80 May 8 14:03 kxsSDL_A1/chkp drwxr-xr-x. 2 root root 30 May 8 14:03 kxsSDL_A1/wm drwxr-xr-x. 2 root root 80 May 8 14:03 kxsSDL_A2/chkp drwxr-xr-x. 2 root root 30 May 8 14:03 kxsSDL_A2/wm root@kxsa:~/kxs/opdata_A# rm -rf */chkp */wm -
If
wmDirhas been changed from its default of${OPDATA}/wm, delete that directory as well. The previous step only reaches watermarks stored underopDataDir, so a relocatedwmDirsurvives it.For example, where
wmDiris set to/root/kxs/db/wm:root@kxsa:~# rm -rf /root/kxs/db/wm -
Reset the position stored in
IdbStatus. Run the following from a maintenance console. This sets the position to null, which the system treats as zero.{p set update pos:0N from get p:` sv .cfgp.idbDir,`data,x}each`IdbStatus.0`IdbStatus.1 -
Start the system, or continue with the upgrade that required the reset.
kxsctl start system
Note
Clearing the watermarks and resetting the IdbStatus position are manual steps. KX intends to provide a supported mechanism for both in a future release.
Next steps¶
- Move RT from Docker to the host
- RT log files
- Disaster recovery — the scripted recovery after losing two of three nodes, which includes a hard reset.
- About RT