mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Fix database locked errors (#3153)
* Make read-only operations use WithReadTxn * Allow one database write thread * Add unit test for concurrent transactions * Perform some actions after commit to release txn * Suppress some errors from cancelled context
This commit is contained in:
@@ -929,18 +929,15 @@ func Test_imageQueryBuilder_Destroy(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
runWithRollbackTxn(t, tt.name, func(t *testing.T, ctx context.Context) {
|
||||
assert := assert.New(t)
|
||||
withRollbackTxn(func(ctx context.Context) error {
|
||||
if err := qb.Destroy(ctx, tt.id); (err != nil) != tt.wantErr {
|
||||
t.Errorf("imageQueryBuilder.Destroy() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
if err := qb.Destroy(ctx, tt.id); (err != nil) != tt.wantErr {
|
||||
t.Errorf("imageQueryBuilder.Destroy() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
|
||||
// ensure cannot be found
|
||||
i, err := qb.Find(ctx, tt.id)
|
||||
// ensure cannot be found
|
||||
i, err := qb.Find(ctx, tt.id)
|
||||
|
||||
assert.NotNil(err)
|
||||
assert.Nil(i)
|
||||
return nil
|
||||
})
|
||||
assert.NotNil(err)
|
||||
assert.Nil(i)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user