mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +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:
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
type TxnManager struct{}
|
||||
|
||||
func (*TxnManager) Begin(ctx context.Context) (context.Context, error) {
|
||||
func (*TxnManager) Begin(ctx context.Context, exclusive bool) (context.Context, error) {
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ func (*TxnManager) Rollback(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*TxnManager) Complete(ctx context.Context) {
|
||||
}
|
||||
|
||||
func (*TxnManager) AddPostCommitHook(ctx context.Context, hook txn.TxnFunc) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
"github.com/stashapp/stash/pkg/txn"
|
||||
)
|
||||
@@ -29,7 +27,3 @@ type Repository struct {
|
||||
Tag TagReaderWriter
|
||||
SavedFilter SavedFilterReaderWriter
|
||||
}
|
||||
|
||||
func (r *Repository) WithTxn(ctx context.Context, fn txn.TxnFunc) error {
|
||||
return txn.WithTxn(ctx, r, fn)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user