logseq / logseq

A privacy-first, open-source platform for knowledge management and collaboration. Download link: http://github.com/logseq/logseq/releases. roadmap: http://trello.com/b/8txSM12G/roadmap
https://logseq.com
GNU Affero General Public License v3.0
32.02k stars 1.87k forks source link

Logseq does not save block changes to disk - and Sqlite DB is an inconsistent state #10985

Open floriandrescher opened 7 months ago

floriandrescher commented 7 months ago

Search first

What Happened?

I noticed when I added new blocks to an existing page that the changes were not saved to disk. But the changes are persistent in Logseq even when I close and open the application.

I did some more digging and found the changes were saved in 2 tables of the Sqlite database (with the id of my page being 6062): select from blocks where page = 6062; select from blocks_fts_content where c2 = 6062;

The output from these selects show the page as its is rendered in the Logseq app - when I open that page.

I also looked into the pages table and found there the version as it is currently on disk (but not showing in the Logseq app)! select * from pages where id=6062;

When I go the beginning of the block with the new edits and press enter the new text disappears and the old text from disk shows up.

Reproduce the Bug

  1. Go to the block which is not in-sync with what is on disk image
  2. Enter a couple of new lines and position the cursor at the front of the block: image
  3. Press return image The previously entered text disappears and the content which is on disk appears!

Expected Behavior

The page in the Logseq app is always in sync which what is on disk.

Screenshots

No response

Desktop or Mobile Platform Information

App Version: 0.9.18 Git Revision: 6eb82e8 Platform: Mozilla/5.0 (X11 Linux x86_64) AppleWebKit/537.36 (KHTML like Gecko) Logseq/0.9.18 Chrome/112.0.5615.204 Electron/24.6.3 Safari/537.36 Language: en-US Plugins: logseq-dev-theme (v1.26.17), logseq-journals-calendar (v0.10.10), logseq-tabs (v1.19.4), logseq-tocgen (v2.13.0), logseq-todo-plugin (v1.20.2)

Additional Context

Before pressing Enter: sqlite3 .config/Logseq/search/logseq_localhome_user_data_rs "select * from blocks where page = 6062;" | wc -l 26 sqlite3 .config/Logseq/search/logseq_localhome_user_data_rs "select from blocks_fts_content where c2 = 6062;" | wc -l 26 sqlite3 .config/Logseq/search/logseq_local__home_user_data_rs "select from pages where id=6062;" | wc -l 22

After pressing enter: sqlite3 .config/Logseq/search/logseq_localhome_user_data_rs "select * from blocks where page = 6062;" | wc -l 26 sqlite3 .config/Logseq/search/logseq_localhome_user_data_rs "select from blocks_fts_content where c2 = 6062;" | wc -l 26 sqlite3 .config/Logseq/search/logseq_local__home_user_data_rs "select from pages where id=6062;" | wc -l 21

Are you willing to submit a PR? If you know how to fix the bug.

andelf commented 7 months ago

SQLite DB is used for the search index, the actual graph db is stored in datascript.

floriandrescher commented 7 months ago

SQLite DB is used for the search index, the actual graph db is stored in datascript.

I am not familiar with datascript. Any advice how to debug the issue there?

andelf commented 7 months ago

How about the Developer Console? Are there any error logs?

floriandrescher commented 7 months ago

No error message in the Developer Console but when I press return I get: instrument.js:191 ({:left {:block/uuid #uuid "653d4621-2a13-44e7-a441-b437e76ee6a3", :block/journal? false, :block/left {:db/id 6063}, :block/refs [{:db/id 6072}], :block/format :markdown, :block/content "curl ipinfo.io #my-everyday-linux", :db/id 6068, :block/path-refs [{:db/id 6062} {:db/id 6072}], :block/parent {:db/id 6063}, :block/page {:db/id 6062}}, :duplicates ({:db/id 11653, :block/content "Windows version", :block/file {:db/id 11655}} {:db/id 13424, :block/content ""})})

When I undo the return I get: instrument.js:191 ({:left {:block/uuid #uuid "653d4621-2a13-44e7-a441-b437e76ee6a3", :block/journal? false, :block/left {:db/id 6063}, :block/refs [{:db/id 6072}], :block/format :markdown, :block/content "curl ipinfo.io #my-everyday-linux", :db/id 6068, :block/path-refs [{:db/id 6062} {:db/id 6072}], :block/parent {:db/id 6063}, :block/page {:db/id 6062}}, :duplicates ({:db/id 11536, :block/content "Windows version (press return to reveal text)"} {:db/id 11653, :block/content "Windows version", :block/file {:db/id 11655}})})

So it seems the is a duplicate entry in datascript.

github-actions[bot] commented 1 month ago

Hi There! šŸ‘‹

We haven't seen any activity on this issue in a while :sleeping:, and we just wanted to make sure that it's still relevant. If you're still experiencing this issue, you might find it helpful to update to the latest version of Logseq. The latest version includes bug fixes and new features that may help to resolve this issue, and you can download it from our website. If updating to the latest version doesn't help, please let us know by adding a comment šŸ’¬. We're here to help!

If the issue has been resolved or is no longer relevant, that's great news! šŸŽ‰ We'll go ahead and close this issue to keep our backlog organized. Please note that this issue will be closed automatically in 20 days if there is no further activity. If you need more time to resolve the issue or provide more information, please just let us know by adding a comment.

Access additional Logseq šŸš€ resources:

Thanks for your contributions to Logseq! If you have any other issues or feature requests, please don't hesitate to let us know. We always welcome pull requests too!