mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-11 15:51:07 +03:00
fix(server): force setStar transaction to start as IMMEDIATE
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
4ff8ea96bf
commit
b6cc32a436
@ -6,6 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/navidrome/navidrome/core/scrobbler"
|
"github.com/navidrome/navidrome/core/scrobbler"
|
||||||
"github.com/navidrome/navidrome/log"
|
"github.com/navidrome/navidrome/log"
|
||||||
"github.com/navidrome/navidrome/model"
|
"github.com/navidrome/navidrome/model"
|
||||||
@ -113,6 +114,14 @@ func (api *Router) setStar(ctx context.Context, star bool, ids ...string) error
|
|||||||
}
|
}
|
||||||
event := &events.RefreshResource{}
|
event := &events.RefreshResource{}
|
||||||
err := api.ds.WithTx(func(tx model.DataStore) error {
|
err := api.ds.WithTx(func(tx model.DataStore) error {
|
||||||
|
// Workaround to force the transaction to be upgraded to immediate mode to avoid deadlocks
|
||||||
|
// See https://berthub.eu/articles/posts/a-brief-post-on-sqlite3-database-locked-despite-timeout/
|
||||||
|
tmpID := uuid.NewString()
|
||||||
|
_ = tx.Property(ctx).Put("tmp_"+tmpID, "")
|
||||||
|
defer func() {
|
||||||
|
_ = tx.Property(ctx).Delete("tmp_" + tmpID)
|
||||||
|
}()
|
||||||
|
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
exist, err := tx.Album(ctx).Exists(id)
|
exist, err := tx.Album(ctx).Exists(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user