mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: fix deadlock in dbfake and incorrect lock types (#7218)
I manually went through every single dbfake function and ensured it has the correct lock type depending on whether it writes or only reads. There were a surprising amount of methods that had the wrong lock type (Lock when only reading, or RLock when writing (!!!)). This also manually fixes every method that acquires a RLock and then calls a method that also acquires it's own RLock to use noLock methods instead. You cannot rely on acquiring a RLock twice in the same goroutine as RWMutex prioritizes any waiting Lock calls. I tried writing a ruleguard rule for this but because of limitations in ruleguard it doesn't seem possible.
This commit is contained in:
@ -68,7 +68,7 @@ func TestFilterError(t *testing.T) {
|
||||
|
||||
auth := &MockAuthorizer{
|
||||
AuthorizeFunc: func(ctx context.Context, subject Subject, action Action, object Object) error {
|
||||
// Authorize func always returns nil, unless the context is cancelled.
|
||||
// Authorize func always returns nil, unless the context is canceled.
|
||||
return ctx.Err()
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user