Don't use transactions when direct db access is enough

For read-only action transactions are not necessary and they risk to deadlock
if multiple go-routines try to read the database.
This commit is contained in:
Lorenzo Bolla
2021-08-24 11:15:39 +02:00
parent fd83c1a5bf
commit 2fa3adee1d
4 changed files with 17 additions and 18 deletions
+1 -7
View File
@@ -898,13 +898,7 @@ func (collection *RemoteRepoCollection) Len() int {
// Drop removes remote repo from collection
func (collection *RemoteRepoCollection) Drop(repo *RemoteRepo) error {
transaction, err := collection.db.OpenTransaction()
if err != nil {
return err
}
defer transaction.Discard()
if _, err = transaction.Get(repo.Key()); err != nil {
if _, err := collection.db.Get(repo.Key()); err != nil {
if err == database.ErrNotFound {
return errors.New("repo not found")
}