localFileSystem data cleared
setting.js contextStorage: { default: "memory", memory: {module: 'memory'}, file: { module: 'localfilesystem', config: { //dir: "~/.node-red", //base: "context", //cache: true, flushInterval: 5 } } }
After power failure, there is a certain probability that the context storage file data will be emptied with a length of 0. What causes this problem? Is the operation of clearing data occurred during power failure or during NR startup?
- [ ] Node-RED version: v1.0.4
- [ ] Node.js version: v12.16.1
- [ ] npm version: v6.13.4
- [ ] Platform/OS: OpenWrt v19.0.7
- [ ] Browser:
- [ ] running in Docker:
Hi @tanjie9012 ,
that sounds very strange. The context LocalFileSystem module takes care not to corrupt its files. It writes updates to a temporary file and then does a rename to move the temporary file over the proper file as a final step. That should ensure we never leave the proper file in a bad state.
The fact you are using Docker may be of interest.... what docker image are you using and how is it configure to store user data?
I have seen this many times running on Windows on an NTFS disk. Is it possible that the write to the temp file is not committed to disk, but the delete/rename "overtake" it in the queue somehow? The file system operations behind delete and rename are more complex. The annoying thing is that it stops NR from starting. As it can affect a random file, you then have to scan through all the context files looking for the one with zero length, delete it, and restart NR.
Hi, we discover the same issue running NR on Windows. We set to flush the context variables to the local file system. In case the PC is shut down immediately, e.g. due to power loss, at next startup, NR terminates with "Error loading context store".
Our workaround is to create a backup of the context directory (when needed and when the PC is running properly) and restore this backup on each startup of NR, to ensure NR starts. However, this limits the possible use of storing to disc considerably.
We would be looking forward to a solution which avoids creating these invalid context files. (We haven't found what could be exactly the problem in the source code of NR) Another approach would be to programmatically create a backup of the context folder (like for the flows) and restore this backup if starting NR fails for the abovementioned error. Or, if this doesn't help, start NR with cleared context directory. Not starting at all is a critical issue thinking of automated operation.
Best regards Stefan
Node-RED version: v1.0.4 Node.js version: v10.16.3 npm version: Platform/OS: Win10 x64 Browser: running in Docker: no
Same issue here on Windows. Power loss cause the global context file to be cleared.
Same issue here on Windows. Power loss cause the global context file to be cleared.
@marcusekeenan this issue is almost 2 years old & many things have changed since node-red v1.0.4
You will need to detail your node/node-red version, how you have set up persistent storage in your settings file and any other relevant info (like running in docker, or as a home assistant pluggin, running as a service etc etc etc)