Skip to content
This repository has been archived by the owner on Jul 16, 2019. It is now read-only.

Commit

Permalink
Fix: Two concurrent transactions are a dead-lock
Browse files Browse the repository at this point in the history
Signed-off-by: Knut Ahlers <knut@ahlers.me>
  • Loading branch information
Luzifer committed Nov 22, 2018
1 parent 044ec99 commit 0ffbe62
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ func (b backend) getFeedKey(feedName string) (crypto.PublicKey, error) {
func (b backend) getFeedLastUpdate(feedName string) (time.Time, error) {
t := time.Now() // Fallback: Assume last update was now

err := b.db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucketIfNotExists(dateBucket)
if err != nil {
return err
err := b.db.View(func(tx *bolt.Tx) error {
b := tx.Bucket(dateBucket)
if b == nil {
return nil // The bucket is not yet there, just use current time
}

var err error

k := []byte(feedName)
v := b.Get(k)

Expand Down

0 comments on commit 0ffbe62

Please sign in to comment.