GitRoot

craft your forge, build your project, grow your community freely
 1---
 2id: "7ab5"
 3priority: 95
 4sprint: ""
 5assignee: null
 6status: triage
 7kind: issue
 8---
 9
10# Today lock are badly managed
11
12Today every call to `repository.Open()` return a repository and then caller can `RLock` or `WLock` but sometimes it's too late.
13
14To bypass that, I made a `cacheLock` which permit to freeze all cal to reposotory during an operation (creation for example). But no other code can run during a cacheLock because they will not acquire cacheLock.
15
16## Suggestion
17
18I think wee need to decouple:
19
20- a repository in read without FS (no worketree) => most use case + mountinf worktree is time consuming and it is done every time today
21- a repository in will write with FS => second most use case should let read pass
22- repository in write => no other can do anything
23
24When a repository write, others open repository need to know that and reload (invalid cache?) of current worktree.
25
26All of this lock state should be managed outside of a repo by the manager. Like that it not impact the way repository works.