Does a persistent context store guarantee recovery of Node-RED flow state after an abrupt restart?
0 reputation · 29 May 2022, 05:59 UTC
0 reputation · 29 May 2022, 05:59 UTC
Node-RED's default context store keeps flow and global context in process memory, so values generally survive redeployment of individual flows but are lost on a full runtime restart. Pluggable context stores configured in settings.js can write context to disk, shifting that durability boundary. However, many file-based or database-backed stores buffer writes, which means an abrupt process termination may still lose the most recent updates even when persistence is enabled.
The practical question is whether an operator can treat a configured persistent store as a transactional guarantee for flow state. Because exact plugin names and configuration keys are version-sensitive, and because there is no automatic synchronization between memory and persistent backends, the behavior after a hard kill or power loss is not always obvious. A graceful shutdown may flush buffers, but the timing and completeness of that flush depend on the specific store implementation.
Does a persistent context store guarantee that flow and global values set immediately before an abrupt restart are available afterward, or is a graceful shutdown required to avoid losing buffered updates?
35775 reputation · 29 May 2022, 17:14 UTC
Configuring a pluggable context store in settings.js moves flow and global state out of process memory, but it does not turn that state into a transactional, crash-proof record. An abrupt termination can still lose the most recent updates if the store buffers writes.
Confirmed. Node-RED's default context store is memory-resident; values are lost on a full runtime restart. When a persistent store is configured, Node-RED delegates context operations to that module, which may write to disk or an external database. A graceful shutdown typically triggers the store's close or flush path.
Likely explanation. Many persistent stores use asynchronous write-behind caching or rely on OS-level buffering. An abrupt process termination—such as SIGKILL, an unhandled crash, or power loss—can discard any update still sitting in that buffer. Whether the last write survives depends on the specific plugin's flush policy and the underlying storage layer, not on the mere presence of a persistent store.
settings.js and set a known value from a function node.kill -9 <pid> on Linux) and check whether the value survives.kill -9 preserves.Which context store module are you using (for example, a file-based store, SQLite, Redis, or another backend), and which Node-RED version? That determines whether you need to add explicit checkpointing, increase flush frequency, or accept the durability limit.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.