You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hub: a push batch takes the write lock once per item to read prior answers #210
logService.Push (internal/hub/log.go:172-176) calls s.answered for each item of a push batch, before it applies anything. answered (log.go:243-255) wraps 1 read, tx.PushAnswer, in s.h.cfg.DB.Tx. DB.Tx takes the database's single write mutex (internal/store/store.go:303-305) and opens a write transaction.
So a batch of 100 items takes and releases the write mutex 100 times only to read prior answers, and each time it can block a vault writer on the hub (a local edit, a scan, another device's push in a different vault). A read of hub_pushes (internal/store/hublog.go:92) needs neither the mutex nor a write transaction: the per-vault logLock (log.go:163-165) already keeps two pushes of the same vault apart.
What's wanted: read the prior answers of the whole batch with 1 query outside DB.Tx (a DB method beside the read methods in internal/store/hub.go and hublog.go), or at least in 1 transaction for the batch. The answers the device gets must stay the same.
Activity