mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Only attempt to flush queue if the underlying worker pool is not finished (#18593)
* Only attempt to flush queue if the underlying worker pool is not finished There is a possible race whereby a worker pool could be cancelled but yet the underlying queue is not empty. This will lead to flush-all cycling because it cannot empty the pool. Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: Gusted <williamzijl7@hotmail.com>
This commit is contained in:
		| @@ -84,6 +84,8 @@ type ManagedPool interface { | ||||
| 	BoostWorkers() int | ||||
| 	// SetPoolSettings sets the user updatable settings for the pool | ||||
| 	SetPoolSettings(maxNumberOfWorkers, boostWorkers int, timeout time.Duration) | ||||
| 	// Done returns a channel that will be closed when the Pool's baseCtx is closed | ||||
| 	Done() <-chan struct{} | ||||
| } | ||||
|  | ||||
| // ManagedQueueList implements the sort.Interface | ||||
| @@ -211,6 +213,15 @@ func (m *Manager) FlushAll(baseCtx context.Context, timeout time.Duration) error | ||||
| 					continue | ||||
| 				} | ||||
| 			} | ||||
| 			if pool, ok := mq.Managed.(ManagedPool); ok { | ||||
| 				// No point into flushing pools when their base's ctx is already done. | ||||
| 				select { | ||||
| 				case <-pool.Done(): | ||||
| 					wg.Done() | ||||
| 					continue | ||||
| 				default: | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			allEmpty = false | ||||
| 			if flushable, ok := mq.Managed.(Flushable); ok { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user