giuspen / cherrytree

cherrytree
https://www.giuspen.net/cherrytree/
Other
3.38k stars 461 forks source link

missing node properties #2367

Open sylvainfaivre opened 12 months ago

sylvainfaivre commented 12 months ago

CherryTree 1.0.2 Ubuntu 23.04

When opening a ctb file, I got the following error :

[2023-10-09 11:04:29.623] [ ] [error] CtDocSqliteStorage: missing node properties for id 554

Analyzing the contents of the sqlite file, I see :

INSERT INTO children VALUES(554,496,11);

But no line with 554 id in the node table. So I edited the sqlite contents to drop this line in the children table, then the file loads OK.

I have a feeling that this might be related to another bug I have sometimes : after renaming a node, when saving the file, CherryTree sometimes gives an error indicating a duplicate Node ID (sorry I don't remember the exact wording for the error message). Looking at the sqlite contents, I see that my node 553 is mislabeled (the title doesn't match the contents). I think that I might have renamed the node before saving, and maybe I got the duplicate error message (I'm not sure because it was a few days ago and it happens often). So both errors might be linked, even though it's the first time I get the missing node properties error. Does this make sense to you ?

By the way, I see that my node table has 382 records, with the biggest node_id being 557, so I guess ids are not reused when a node is deleted. But I wonder how a new relationship could be inserted in the children table for an id that doesn't exist in the node table ? I checked with an older backup for this file : nodes 555, 556 and 557 were present while node 554 was absent, so it was deleted before the line referencing it was added in the children table.

sylvainfaivre commented 12 months ago

Update :

I just found out that one note was missing. In fact, it was not shown in the app, but present in the database. This note was recorded in the children table as a child of the deleted note :

INSERT INTO children VALUES(555,554,1);

So I carefully edited the table to make note 555 a child of note 496 (which was the parent of missing note 554), and now note 555 is back in the app !

giuspen commented 12 months ago

Hi @sylvainfaivre have you just upgraded to 1.0.2 and found this issue or it's definitely something that was caused from this running version? Recent versions, before rotating the backups, are checking the integrity of the db in a background task, so it's surprising to me that a bad database was rotated. In the integrity check the whole hierarchy is parsed same as loading the tree. It's also surprising that just renaming nodes you got duplicate IDs as only creating new nodes or importing nodes allocates new IDs. If you can help me with a sequence of operations that cause at least with high probability the issue I will give it a try. If you have test data you can share with me also privately even better

sylvainfaivre commented 11 months ago

Hi, I keep the CherryTree package updated through the http://ppa.launchpad.net/giuspen/ppa/ubuntu/ repo, and I can see in the logs that the 1.0.2 release was installed before I experienced this bug, although I only suspend the computer at night, so maybe an older CherryTree binary was running (I don't close it and reopen it after package upgrades).

I will try reproducing the bug with a smaller file. If I don't succeed, I can send you the file I had problems with. How can I reach you privately ?