Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e38d8d6

Browse files
committedAug 1, 2024
Fix race condition when recreating subs
Signed-off-by: Neil Twigg <neil@nats.io>
1 parent ee5a474 commit e38d8d6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎server/raft.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,14 @@ func (n *raft) recreateInternalSubsLocked() error {
553553
acc := n.s.accountNRGAllowed.Load()
554554
if acc {
555555
// Check whether the specific account has account NRG enabled.
556-
if a, _ := n.s.lookupAccount(n.accName); a != nil && a.js != nil {
557-
acc = a.js.accountNRG.Load()
556+
if a, _ := n.s.lookupAccount(n.accName); a != nil {
557+
a.mu.RLock()
558+
ajs := a.js
559+
a.mu.RUnlock()
560+
// Check whether the specific account has JetStream enabled.
561+
if ajs != nil {
562+
acc = ajs.accountNRG.Load()
563+
}
558564
}
559565
}
560566
if acc {

0 commit comments

Comments
 (0)
Please sign in to comment.