Obsidian Sync: updates from one device overwritten by another

Ah yes, I see the bug report, and thank you!

There isn’t much we can do on Obsidian’s side unfortunately, but it should be fairly easy to fix it from the plugin’s perspective.

Most of the time, plugins are encouraged to read-process-write as quickly as possible to avoid conflicts. Reading and then waiting for user input is definitely before finally writing is definitely troublesome.

If a plugin requires user input, but must also read the file beforehand, we recommend reading again after user input just to verify the file hasn’t changed, and show a notice if the file has changed (or cancel the action) to avoid overwriting.

1 Like

I’ve been noticing this behavior as well, primarily with my Daily note, which I start on my desktop usually, and then later in the day may add something from my phone.

I have the Daily notes plugin setup with a Template, and the setting to “Open daily note on startup” enabled.

I believe what’s happening is that my phone starts Obsidian up, and goes to open the Daily note. It doesn’t seem like the Sync has happened (or completed) yet, so it creates a new file using the defined Template. Sync then runs and sees a more recent version of the Daily note file, and uploads that, overwriting the version from my desktop.

I can mitigate for myself for the time being by not using the “Open daily note on startup” option for the time being.

So repo steps for me at least (happens every time):

  1. Make sure Daily note hasn’t been created yet on either device
  2. Have Daily notes plugin setup with “Template” set and “Open daily note on startup” turned on for both Desktop and Phone
  3. Open Obsidian only on Desktop, so that Daily Note is created
  4. Make edits to Daily note (and ensure it Syncs)
  5. Open Obsidian on phone
  6. Edits are overwritten with newly created Daily note from phone with Template

Sync Log

Desktop:

2022-03-04 16:22 - Connecting to server
2022-03-04 16:22 - Connection successful. Detecting changes...
2022-03-04 16:22 - Uploading file Journal/2022-03-04.md
2022-03-04 16:22 - Upload complete Journal/2022-03-04.md
2022-03-04 16:22 - Server pushed [MARS] Journal/2022-03-04.md
2022-03-04 16:22 - Fully synced
2022-03-04 16:22 - Uploading file Journal/2022-03-04.md
2022-03-04 16:22 - Upload complete Journal/2022-03-04.md
2022-03-04 16:22 - Server pushed [MARS] Journal/2022-03-04.md
2022-03-04 16:22 - Fully synced
2022-03-04 16:22 - Server pushed [Pixel 3] Journal/2022-03-04.md
2022-03-04 16:22 - Downloading file Journal/2022-03-04.md
2022-03-04 16:22 - Downloading complete Journal/2022-03-04.md
2022-03-04 16:22 - Accepted Journal/2022-03-04.md
2022-03-04 16:22 - Fully synced

Phone:

2022-03-04 16:22 - Connecting to server
2022-03-04 16:22 - Connection successful. Detecting changes...
2022-03-04 16:22 - Server pushed [MARS] Journal/2022-03-04.md
2022-03-04 16:22 - Merging conflicted file Journal/2022-03-04.md
2022-03-04 16:22 - Accepted Journal/2022-03-04.md
2022-03-04 16:22 - Uploading file Journal/2022-03-04.md
2022-03-04 16:22 - Upload complete Journal/2022-03-04.md
2022-03-04 16:22 - Server pushed [Pixel 3] Journal/2022-03-04.md
2022-03-04 16:22 - Fully synced

I can see that a merge is happening, but maybe because the file is considered to be newly created (and so all edits are “newer”), it uses that as the source of truth?

Obsidian Desktop v0.13.23
Obsidian Mobile (Android): v1.1.0

3 Likes

that’s a different issue and will be fixed in 0.13.26 and 1.1.1

2 Likes