Closed Byron closed 1 month ago
A question is pending, asking if cargo
works on btrfs
- if so, we could use the cargo
locking implementation for better portability.
CC @ndom91, who even might have btrfs
on his machine.
@Byron you can throw me a code or snippets for me to run on btrfs
.
Thanks a lot for offering to test new versions, and for sharing that cargo
works for you which means that its file-locks work.
I investigated this and it seems the best choice here, and what cargo
does, is to ignore errors on filesystems that don't support.it.
Once the PR is merged, there is a nightly for you to test.
Yeah no btrfs here unfortunately. More of a ZFS guy 😅
Side note, I ran into a support request today where someone had their tfstate
terraform state file commited and we kept failing in list_virrual_branches
due to not being able to get a lock either. And therefore the UI wasn't loading at all. Is this related perhaps?
ZFS is great, too :).
Then I think we'd have to try to get #4900 merged so @azzamsa can try a nightly.
On the side note, list_virrual_branches
doesn't get a file-based lock, just an in-memory one which will also block until it's ready. So it should never fail. However, the issue itself seems familiar though - do you have link with more context?
@Byron haha good ol' virrual
branches :joy:
Anyway, it was a support request that came in on the report thing to Intercom, but here's the relevant log lines:
|2024-09-11T01:34:06.569000+0200 INFO handle: crates\gitbutler-watcher\src\handler.rs:57: close time.busy=879s time.idle=14.8µs event=ProjectFileChange(29efdf81-fac4-4860-ab5c-912d15494846, projects\cdktf\terraform.proxy.tfstate) │
│2024-09-11T01:34:06.609000+0200 INFO handle:recalculate_everything:calculate_virtual_branches: crates\gitbutler-watcher\src\handler.rs:93: close time.busy=24.6s time.idle=5.50µs event=ProjectFileChange(29efdf81-fac4-4860-ab5c-912d15494846, projects\cdktf\terrafor│
│2024-09-11T01:34:06.609000+0200 INFO handle:recalculate_everything: crates\gitbutler-watcher\src\handler.rs:129: close time.busy=878s time.idle=3.50µs event=ProjectFileChange(29efdf81-fac4-4860-ab5c-912d15494846, projects\cdktf\terraform.proxy.tfstate) paths=1 │
│2024-09-11T01:34:06.609000+0200 ERROR handle: crates\gitbutler-watcher\src\handler.rs:57: error=failed to list virtual branches │
│ │
│Caused by: │
│ 0: failed to diff workdir │
│ 1: failed to read descriptor: The process cannot access the file because another process has locked a portion of the file. │
│ ; class=Os (2) event=ProjectFileChange(29efdf81-fac4-4860-ab5c-912d15494846, projects\cdktf\terraform.proxy.tfstate)
Right, maybe that issue you referred to was indeed caused by a very early failure due to unreadable files when trying to check for changes, which seems unrelated to this particular issue with unsupported file locks that are acquired once per project.
I am reopening it to wait after @azzamsa could validate the issue is truly resolved. A nightly version with the fix is already available. Thanks again for your help with this.
I'm not totally caught up here, but I do just want to mention that the Flatpak is a community maintained packaging format. Also Flatpak comes with many sandbox-ing mechanisms that might block access to things such as the project / repository directory, see for example: https://docs.flatpak.org/en/latest/sandbox-permissions.html
Thanks for sharing! This might mean that using a different distribution channel might possibly allow file-locking features to be used as well, which would help preventing the opening of multiple GitButler windows for the same project.
@Byron worked like a charm!
It doesn't seem to be always possible to use the
flock
crate successfully, and right now this makes the application fail entirely as an exclusive lock can't be acquired.Since the error code is known, and the locking is just there to prevent multi-window operation which isn't advisable, but also not immediately a problem, one could make the lock optional in this specific case.
Alternatively, we could use the
cargo
crate and rely on a possibly unstable version of a locking function that probably is more portable. After all, Cargo probably works there.Discussed in https://github.com/gitbutlerapp/gitbutler/discussions/4851