Skip to content

Conversation

@pete-woods
Copy link
Contributor

@pete-woods pete-woods commented Apr 9, 2024

  • I have a custom store that wants to read domain-specific values out of the session (to maintain a table associating users with sessions, so they can be listed and deleted efficiently).
  • At present stores cannot access the session data, as this causes a deadlock on the sync.Mutex.
  • I've tried to carefully go through each accessor of the mutex and convert those that perform only read operations to RWLocks.
  • I'd expect this is also a small general performance improvement in any situation where you're reading from the session data concurrently.
  • I've had this in production for some time now with no issues.

@pete-woods pete-woods changed the title Rw mutex Use rwmutex in sessionData to allow concurrent readers Apr 9, 2024
@pete-woods pete-woods changed the title Use rwmutex in sessionData to allow concurrent readers Use sync.RWMutex in sessionData to allow concurrent readers Apr 9, 2024
@pete-woods pete-woods marked this pull request as ready for review April 9, 2024 11:32

sd.mu.Lock()
defer sd.mu.Unlock()
sd.mu.RLock()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pete-woods I'm not sure that we an use RLock in the Commit function --- sd is written to in this line:

scs/data.go

Line 101 in 9b07998

if sd.token, err = generateToken(); err != nil {
.

Copy link
Contributor Author

@pete-woods pete-woods Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - will have a look. We've been relying on a version of this in production for a while that lets a custom session store read the session info from the context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants