Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hang in load() #6

Open
falanjones opened this issue Nov 3, 2016 · 0 comments
Open

hang in load() #6

falanjones opened this issue Nov 3, 2016 · 0 comments

Comments

@falanjones
Copy link

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant