Hot-Patch EMQX at Runtime
Starting from 4.3, EMQX supports an easier (comparing to 4.2) hot-patch mechanism. Hot-patch is an ad-hoc patch mechanism comparing to Hot Upgrade. For certain urgent issues, a hot-patch can be applied before the fix is included in a (future) official release.
NOTE
It's recommended to upgrade to the offical release which included the patched fixes. The patched modules should be deleted before upgrading.
Steps to Patch
- Get the list of modules to be updated from EMQX support team. For example:
emqx.beam emqx_rule_engine.beam- Copy the files to
data/patchesdirectory
bash
cp /path/to/patch/emqx.beam data/patches cp /path/to/patch/emqx_rule_engine.beam data/patchesThe exact path to the data/patches directory depends on configuration and installation. Typically, it is:
- Where the environment variable
EMQX_NODE__DATA_DIRpoints to - Where the
node.data_dirconfig key points to inemqx.conf /opt/emqx/datawhen running in docker (typically a mounted volume)<install-path>/datawhen installed from zip package extraction/var/lib/emqx/when installed from RPM or DEB packages
- Load new files at runtime:
bash
$ emqx eval 'c:l(emqx).' {module,emqx} $ emqx eval 'c:l(emqx_rule_engine).' {module,emqx_rule_engine}Rollback the Patched Modules
In case the patch does not work as expected, or if one wish to go back to the state before patching, below are the steps to rollback.
- Delete the patched modules from the
data/patchesdirectory
bash
$ mv data/patches/emqx.beam /tmp/ $ mv data/patches/emqx_rule_engine.beam /tmp/- reload the beam files:
bash
$ emqx eval 'c:l(emqx).' {module,emqx} $ emqx eval 'c:l(emqx_rule_engine).' {module,emqx_rule_engine}