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
30.26k stars 1.77k forks source link

Pages in my graph are replacing their content randomly with a content from a single block in my journal #6834

Closed Barondane closed 1 year ago

Barondane commented 1 year ago

What happened?

I opened logseq today and called my /template. There was none. I go to check the [[templates]] pages and it was replaced with content from a random block “Block x” that was in my journal from 09-23. I reverted the template page using git successfully. I refreshed and reindexed the app and closed it.

I reopened the app few hours later and a popup says content was modified on desk and asks to select between two options: On desk on left side or on logseq on the right side. The [[page y]] was not modified by me today. I should always select the unencrypted content. So, I selected it but it was not the correct content. It was content from the “block x” !

“Block x” when created was the first backlink to [[page Y]]. I do not see a relationship between [[templates]] and “block x”. I just deleted the references to [[page y]] in “block x” hoping it will stop interfering with my pages.

“Block x” does not have special content or codes. It has references to two dates 09/25 and 10/08. It has also two TODOS. It used to have a reference to [[page y]].

Reproduce the Bug

Not able to repreduce

Expected Behavior

No response

Screenshots

1 2 3

Desktop Platform Information

My graph is saved locally on Mac. It is encrypted. Logseq version is 0.8.7. No plugins. MacOS 12.6. M1. Nothing should modify files on desk. I did not even open any of them out of Logseq.

Mobile Platform Information

No response

Additional Context

I refreshed and reindexed my graph few times during this process. One thing I changed recently was graph date format. I then reindexed. Every thing was fine except one thing: Recent date pages were populating in my pages and graph. Some of them are empty and some have linked references.

Now every time I refresh Logseq it says [[page y]] content was modified and have me chose even if I am in app and did not make any changes.

cnrpman commented 1 year ago

No much clue with the given information.

I guess it's related to your change on the date format. Should be helpful if you can provide: 1) the name of the templates 2) the page that include the blocks 3) the first line (block title) of the block 4) the date format you are using. Also I want to confirm if there's no any sync service setup on your graph directory.

Barondane commented 1 year ago

Sorry probably my writing was not clear.

  1. The page name is "Templates". I created it and put three tempates there. Names: day summary, sleep, daily errands .
  2. The block was in Journals. It was created in 09/23.
  3. The first line of the block is "Put together some [[Page y]].
  4. Markdown No sync services and never were for this graph. I just enabled Git auto commits from the app settings.

Thanks for your help

Barondane commented 1 year ago

Update:

I was able to repoduce the bug (s) partially.

I created a new graph locally. Encrypted it. Added some content and dates. Changed date format to EEEE, yyyy/MM/dd.

Result:

  1. Multiple pages populated based on journals entries that are assosiated with dates. See graph screen shot.
  2. Encryption issues. Logseq detects diffrences between what's on desk vs what's in app.

My guess is these are two different bugs. Main bug was not reproduced so far. However, it may need some time to reproduce because it did not happen once I changed the date format initially. It took two days.

Screen Shot 2022-09-28 at 5 01 18 PM Screen Shot 2022-09-28 at 5 11 00 PM
cnrpman commented 1 year ago

Thanks for the check. Sounds to be a joint issue of the specific date format setting + encryption.

Barondane commented 1 year ago

Update: All content in graph got erased (Hopefully not).

I opened my main graph today. It gave me the usual error (Discrepancy in one page between Logseq and on desk). I chose unencrypted version. I refreshed the app and everything was gone. I refreshed second time and nothing came up. I reindexed and entered my password and it’s still empty. I cleared Logseq cash and linked my graph and entered password and it’s empty.

File explorer does show my pages and shows backups too. I copied my Logseq folder into another location on my desk(do not want to corrupt the orignial by decryption ). I decrypted it with Logseq encrypt UI. Pages have no content.

I am looking into Age now might decrypt the files with it.

Barondane commented 1 year ago

Update: Decrypted the files with age and no luck. All are empty. So, something must have triggered updating all files when I refreshed before content erased.

I am investigating some possible causes for what happened and I might have something related to disk permissions.

I just discovered that Logseq does not have permission to access the folder that graph was in. It never asked for permission. At the same time, permission is granted to Logseq for other folders that have other graphs. I do not recall if I was asked to permit or the system automatically permitted. I can confirm though that Logseq can still R/W the folder with lost content.

Possibly, this is an OSX specific bug related to disk permissions.

cnrpman commented 1 year ago

@Barondane Thanks! It's an important finding.

cnrpman commented 1 year ago

Humm, I created a graph with wrong permission setup to check the behavior. There's UX response on permission error on macOS 12.4 (both with & w/o Encryption)

image image
Barondane commented 1 year ago

Update: I created a new graph and was using Logseq on a daily basis. Multiple pages replaced their content with other pages arbitrarily. There was no relation between any of the pages. These acting pages were not accessed the moment or the day that their content was replaced.

The one common thing I did every time this occurred was refreshing Logseq and then it renders the page discrepancy message and asks me to choose between the two options. One encrypted and another one I can read but it’s from a different page. I choose the one that is readable regardless. Git versions for the lost original pages are not accessible. I can access only new commits with unrelated content.

Since that graph was lost I created a little local automation to back up Logseq graph. Luckily, I was able to recover every lost page with this new graph this way.

Could this too be related to this issue?

Barondane commented 1 year ago

Humm, I created a graph with wrong permission setup to check the behavior. There's UX response on permission error on macOS 12.4 (both with & w/o Encryption)

image image

Yes, I looked into it and do not think it's related to permissions any more.

cnrpman commented 1 year ago

Anyway, some cause make Logseq failed to persist data to the file system, without permission error

Barondane commented 1 year ago

Does Logseq logs errors and instances locally? If yes where should I look and debug?

Barondane commented 1 year ago

This is an error I got recently. I do not know if it's relevant.

Screen Shot 2022-10-01 at 6 33 30 PM
Barondane commented 1 year ago

@tiensonqin as per email

cnrpman commented 1 year ago

@Barondane Some logs stored in ~/Library/Logs/Logseq For the others they are only available in the Console of Devtools

Barondane commented 1 year ago

@cnrpman I emailed you some logs yesterday. If you could check your mailboxes

cnrpman commented 1 year ago

@Barondane Have you sent the logs to junyi@logseq.com ? What's your email address? I may do a double check.

Barondane commented 1 year ago

Sent it to junyidu.cn@gmail.com

cnrpman commented 1 year ago

@Barondane Sorry I can't find your email even in the spam box. Can you resend it to junyi@logseq.com ?

Barondane commented 1 year ago

@cnrpman Done, please let me know if you do not receive it.

cnrpman commented 1 year ago

Received.

Can you provide logs as https://github.com/logseq/logseq/issues/6834#issuecomment-1279719807 requested? (upon the error happening) The sys log doesn't tell much info

cnrpman commented 1 year ago

What's the meaning of

I did a logseq refresh before saving it

cnrpman commented 1 year ago

I can't make a whole view on the case.

Sounds like some internal race condition when the encryption is enabled. The cmd+r "Refresh" should always be avoid as it will make internal state into a mess, since Logseq is a multi-window program.

Barondane commented 1 year ago

What's the meaning of

I did a logseq refresh before saving it

It took me a minute to know this was in reference to the email. I meant before exporting logs...

Barondane commented 1 year ago

I can't make a whole view on the case.

Sounds like some internal race condition when the encryption is enabled. The cmd+r "Refresh" should always be avoid as it will make internal state into a mess, since Logseq is a multi-window program.

Very plausible. Will keep this post updated in case of any new development.

Thanks @cnrpman

ahpatel commented 1 year ago

I run into this occasionally as well, with encryption on. Generally, it appears to be a conflict between encryption and the refresh function. But, I aslo cannot consistently recreate the scenario yet.

The workaround/fix when the diff modal pops up is to just "Select this" for the "on disk" (i.e., readable text) side. Logseq then seems to re-encrypt the file so there won't be plain text if you open up the corresponding .md file.

I will continue to monitor to see if I can find a repeatable pattern and possible cause.

cnrpman commented 1 year ago

Logseq Encryption is deprecated due to it's experimental & immature state. https://discuss.logseq.com/t/deprecation-of-on-disk-encryption/12334