Skip to content

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, --help
Prints the usage.

The script:

  1. Stops the system.
  2. 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.
  3. Deletes the RT data in emsLogDir, and the checkpoints and watermarks of every process, wherever opDataDir, chkpDir, and wmDir place them.
  4. Resets the position stored in IdbStatus.
  5. 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.

  1. Stop all nodes.

    kxsctl stop system
    
  2. Back up the contents of emsLogDir. Everything deleted below lives under the directories listed above, so take copies before you continue.

  3. Delete the full contents of emsLogDir.

  4. Delete the stream-processor checkpoints and watermarks under opDataDir. Each process has its own subdirectory holding a chkp folder and a wm folder; remove both from every process. The watermarks SM uses to subscribe to the emsint stream, eox and seq, 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
    
  5. If wmDir has been changed from its default of ${OPDATA}/wm, delete that directory as well. The previous step only reaches watermarks stored under opDataDir, so a relocated wmDir survives it.

    For example, where wmDir is set to /root/kxs/db/wm:

    root@kxsa:~# rm -rf /root/kxs/db/wm
    
  6. 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
    
  7. 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