Skip to content

Make the lru.LRU in remoteauth.go thread-safe and remove the external mutex#11589

Merged
iain-macdonald merged 1 commit intomasterfrom
im/5f5ddd4815f
Mar 13, 2026
Merged

Make the lru.LRU in remoteauth.go thread-safe and remove the external mutex#11589
iain-macdonald merged 1 commit intomasterfrom
im/5f5ddd4815f

Conversation

@iain-macdonald
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 13, 2026 18:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the enterprise remote authenticator’s JWT cache to rely on server/util/lru’s built-in thread-safety instead of maintaining a separate mutex in remoteauth.go.

Changes:

  • Construct the JWT LRU cache with ThreadSafe: true.
  • Remove the sync.RWMutex from RemoteAuthenticator and delete the associated lock/unlock calls around cache access.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

SizeFn: func(v string) int64 { return 1 },
MaxSize: jwtCacheSize,
SizeFn: func(v string) int64 { return 1 },
ThreadSafe: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

hah, this had a race before. LRU.Get modifies the data structure, so it can't use RLock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice, glad we fixed it :-)

@iain-macdonald iain-macdonald requested a review from vanja-p March 13, 2026 19:20
@iain-macdonald iain-macdonald merged commit 0392090 into master Mar 13, 2026
16 checks passed
@iain-macdonald iain-macdonald deleted the im/5f5ddd4815f branch March 13, 2026 19:31
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

Successfully merging this pull request may close these issues.

3 participants