mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +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:
@@ -350,7 +350,7 @@ func (c Cache) ScrapeID(ctx context.Context, scraperID string, id int, ty Scrape
|
||||
|
||||
func (c Cache) getScene(ctx context.Context, sceneID int) (*models.Scene, error) {
|
||||
var ret *models.Scene
|
||||
if err := txn.WithTxn(ctx, c.txnManager, func(ctx context.Context) error {
|
||||
if err := txn.WithReadTxn(ctx, c.txnManager, func(ctx context.Context) error {
|
||||
var err error
|
||||
ret, err = c.repository.SceneFinder.Find(ctx, sceneID)
|
||||
return err
|
||||
@@ -362,7 +362,7 @@ func (c Cache) getScene(ctx context.Context, sceneID int) (*models.Scene, error)
|
||||
|
||||
func (c Cache) getGallery(ctx context.Context, galleryID int) (*models.Gallery, error) {
|
||||
var ret *models.Gallery
|
||||
if err := txn.WithTxn(ctx, c.txnManager, func(ctx context.Context) error {
|
||||
if err := txn.WithReadTxn(ctx, c.txnManager, func(ctx context.Context) error {
|
||||
var err error
|
||||
ret, err = c.repository.GalleryFinder.Find(ctx, galleryID)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user