Vinzent03 / obsidian-git

Integrate Git version control with automatic backup and other advanced features in Obsidian.md
MIT License
6.78k stars 289 forks source link

[Bug]: Namespace issues causing files to appear as empty in Android potentially causing dataloss #794

Open EDLLT opened 5 days ago

EDLLT commented 5 days ago

Describe the bug

When using Obsidian Git plugin on Android, certain files exhibit a filesystem metadata inconsistency after performing git operations across large commit differences.

Specific symptoms:

  1. Files appear empty when checked with ls -la or file commands (showing 0 bytes)
  2. However, the actual file contents are present and accessible using cat command(using termux/adb)
  3. The affected files appear to be random and vary between operations
  4. This issue seems to occur more frequently with:
    • Larger git history
    • Larger gaps between commit checkouts
    • When pulling many changes after a hard reset to an older commit

Relevant errors

No direct error messages are shown, but filesystem inspection reveals:

$ ls -la LM\ Studio.md 
-rw-rw----. 1 root everybody 0 Oct 26 16:02 'LM Studio.md'
$ file LM\ Studio.md 
LM Studio.md: empty
$ cat LM\ Studio.md 
[Shows actual file contents]

Steps to reproduce

  1. Have a git repository with a large commit history in Obsidian on Android
  2. Using Termux git, perform a hard reset to a much older commit
  3. Using the Obsidian git plugin, pull to get back to the latest commit
  4. Inspect files using terminal commands (via Termux or ADB)
  5. Some files will show the metadata inconsistency described above

Expected Behavior

Additional context

Operating system

Android (Issue was reproduced on my Xiaomi Pad 6 and Samsung device)

Installation Method

None

Plugin version

2.27.0

EDLLT commented 1 day ago
~/.../Obsidian_TestVault/AI $ ls -la LM\ Studio.md 
-rw-rw----. 1 root everybody 0 Oct 26 16:02 'LM Studio.md'
~/.../Obsidian_TestVault/AI $ file LM\ Studio.md 
LM Studio.md: empty
~/.../Obsidian_TestVault/AI $ cat LM\ Studio.md 
In an ideal case extreme case, the maximum gpu offload layers is 28
26 GPU offload layers for stable usage(higher than that, the model might crash)

## Memory Leak
When you fail to load an LLM model within LM Studio, it still takes up vram. This in return causes you to not be able to fully load the model within the GPU.
The solution is to close LM Studio and run it successfully the first time whilst checking `nvidia-smi`

## Cuda vs Vulkan
You can load up your models in LM Studio using either Cuda or vulkan. Since we have an nvidia GPU, using Cuda is preferable and faster(we need to make sure we have [[Nvidia#^108bb3|Cuda installed]])

In here, this is the termux output(similar results when using adb) My guess is that this is a namespace issue as I had faced very similar issues in the past when I had root.

The interesting thing is that this does not occur to all files, but rather, it occurs randomly(and the larger the commit history, the more likely it'd happen)

TL;DR: The android system sees the file as empty(and expectedly, git), but using cat proves otherwise. This is probably being caused by the way isomorphic git is writing and updating files

EDLLT commented 1 day ago

Okay, after thinking about it for a while, perhaps it's being caused by multiple writes to the same file when checking out from a large commit history size to the current file. Maybe there are multiple writes that are happening to the same file which causes a race condition somehow?

EDLLT commented 1 day ago

@Vinzent03 Hey, I am not sure whether if this is considered to be an Obsidian plugin issue or if it's an Obsidian issue with their Adapter and Vault APIs. Should I open an issue in Obsidian's forums instead?