mirror of
				https://github.com/etcd-io/etcd.git
				synced 2024-09-27 06:25:44 +00:00 
			
		
		
		
	mvcc: fix deadlock bug
This commit is contained in:
		
							parent
							
								
									f1eca4e1fa
								
							
						
					
					
						commit
						aa75e90ac8
					
				| @ -163,14 +163,18 @@ func NewStore(lg *zap.Logger, b backend.Backend, le lease.Lessor, ig ConsistentI | |||||||
| 
 | 
 | ||||||
| func (s *store) compactBarrier(ctx context.Context, ch chan struct{}) { | func (s *store) compactBarrier(ctx context.Context, ch chan struct{}) { | ||||||
| 	if ctx == nil || ctx.Err() != nil { | 	if ctx == nil || ctx.Err() != nil { | ||||||
| 		s.mu.Lock() |  | ||||||
| 		select { | 		select { | ||||||
| 		case <-s.stopc: | 		case <-s.stopc: | ||||||
| 		default: | 		default: | ||||||
|  | 			// fix deadlock in mvcc,for more information, please refer to pr 11817. | ||||||
|  | 			// s.stopc is only updated in restore operation, which is called by apply | ||||||
|  | 			// snapshot call, compaction and apply snapshot requests are serialized by | ||||||
|  | 			// raft, and do not happen at the same time. | ||||||
|  | 			s.mu.Lock() | ||||||
| 			f := func(ctx context.Context) { s.compactBarrier(ctx, ch) } | 			f := func(ctx context.Context) { s.compactBarrier(ctx, ch) } | ||||||
| 			s.fifoSched.Schedule(f) | 			s.fifoSched.Schedule(f) | ||||||
| 		} |  | ||||||
| 			s.mu.Unlock() | 			s.mu.Unlock() | ||||||
|  | 		} | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	close(ch) | 	close(ch) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 tangcong
						tangcong