boltstore
boltstore copied to clipboard
hang in load()
In using this at scale I see a hang in load() around line 90. I'm now testing a version that puts Update() after View():
func (s *Store) load(session *sessions.Session) (bool, error) {
// exists represents whether a session data exists or not.
var exists, expired bool
id := []byte(session.ID)
err := s.db.View(func(tx *bolt.Tx) error {
bucket := tx.Bucket(s.config.DBOptions.BucketName)
// Get the session data.
data := bucket.Get(id)
if data == nil {
return nil
}
sessionData, err := shared.Session(data)
if err != nil {
return err
}
// Check the expiration of the session data.
if shared.Expired(sessionData) {
expired = true
}
exists = true
dec := gob.NewDecoder(bytes.NewBuffer(sessionData.Values))
return dec.Decode(&session.Values)
})
if expired {
err := s.db.Update(func(txu *bolt.Tx) error {
return txu.Bucket(s.config.DBOptions.BucketName).Delete(id)
})
return false, err
}
return exists, err
}