mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 10:37:56 +00:00 
			
		
		
		
	Speculative fix for a panic that might arise during raft teardown (#18704)
This commit is contained in:
		
							
								
								
									
										3
									
								
								changelog/18704.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								changelog/18704.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | ```release-note:bug | ||||||
|  | storage/raft: Fix race with follower heartbeat tracker during teardown. | ||||||
|  | ``` | ||||||
| @@ -551,6 +551,13 @@ func (b *RaftBackend) startFollowerHeartbeatTracker() { | |||||||
| 	} | 	} | ||||||
| 	for range tickerCh { | 	for range tickerCh { | ||||||
| 		b.l.RLock() | 		b.l.RLock() | ||||||
|  | 		if b.raft == nil { | ||||||
|  | 			// We could be racing with teardown, which will stop the ticker | ||||||
|  | 			// but that doesn't guarantee that we won't reach this line with a nil | ||||||
|  | 			// b.raft. | ||||||
|  | 			b.l.RUnlock() | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
| 		b.followerStates.l.RLock() | 		b.followerStates.l.RLock() | ||||||
| 		myAppliedIndex := b.raft.AppliedIndex() | 		myAppliedIndex := b.raft.AppliedIndex() | ||||||
| 		for peerID, state := range b.followerStates.followers { | 		for peerID, state := range b.followerStates.followers { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nick Cabatoff
					Nick Cabatoff