Persistence is updated when making changes to the restored message
martdi opened this issue · 1 comments
You can reproduce the issue with the following simple flow.
[{"id":"f0172f83.431df","type":"persist in","z":"9b7058671cd894c1","name":"myPersistence","storageNode":"42dd5cc5.694f1c","x":500,"y":880,"wires":[]},{"id":"3aa581f3.d377be","type":"inject","z":"9b7058671cd894c1","name":"name1","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Rhett Nowed","payloadType":"str","x":190,"y":920,"wires":[["f0172f83.431df","2bba8123.3c3a16"]]},{"id":"2bba8123.3c3a16","type":"debug","z":"9b7058671cd894c1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":490,"y":920,"wires":[]},{"id":"faeb0c89d6a66b32","type":"persist out","z":"9b7058671cd894c1","name":"myPersistence","storageNode":"42dd5cc5.694f1c","x":220,"y":980,"wires":[["a8bb0657e73b90ba"]]},{"id":"993d06e061deadf6","type":"debug","z":"9b7058671cd894c1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1010,"y":980,"wires":[]},{"id":"a8bb0657e73b90ba","type":"change","z":"9b7058671cd894c1","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$join($reverse($split(payload, "")))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":980,"wires":[["993d06e061deadf6"]]},{"id":"b248e089c192291d","type":"comment","z":"9b7058671cd894c1","name":"Will set Rehtt Nowed into the persistence2.json file","info":"","x":790,"y":880,"wires":[]},{"id":"061b342963f7c4d4","type":"comment","z":"9b7058671cd894c1","name":"1. Simple jsonata string reverse on the message that happens when persistence is restored","info":"","x":730,"y":1020,"wires":[]},{"id":"8d26b6fff4c8a5ba","type":"comment","z":"9b7058671cd894c1","name":"2. Try pressing the restore button a few times","info":"","x":590,"y":1060,"wires":[]},{"id":"bc4adbe855440266","type":"comment","z":"9b7058671cd894c1","name":"3. You will get, in alternance: dewoN ttehR and Rhett Nowed","info":"","x":640,"y":1100,"wires":[]},{"id":"794937a91bd8348d","type":"comment","z":"9b7058671cd894c1","name":"4. while it should always be dewoN ttehR since we haven't persisted the reversed value","info":"","x":720,"y":1140,"wires":[]},{"id":"7ab73c21284c5a37","type":"comment","z":"9b7058671cd894c1","name":"5. The contents of the json file get modified as well, so it's not just an in-memory issue","info":"","x":720,"y":1180,"wires":[]},{"id":"42dd5cc5.694f1c","type":"persist-store","filename":"persistance2.json","interval":"10"}]
I can confirm this issue as well and I think it's worse than we see on the surface. It seems that something has changed in persistence in Node-Red as it's not just modifying the one but all. I have p1 and p2. I store data in p1. I then put p1 into p2 using its persist in node. Now they are both the same, p1 and p2. I use change to set values in p2. I use persist out on p1 and it's ALSO changed.
In short it seems using change on a persistent node is a very bad idea.