mirror of
				https://github.com/minio/minio.git
				synced 2025-11-04 02:01:05 +01:00 
			
		
		
		
	fix: retries and failed message counter (#20401)
This commit is contained in:
		
							parent
							
								
									9d5cdaa2e3
								
							
						
					
					
						commit
						3f39da48ea
					
				@ -222,15 +222,12 @@ func (h *Target) initMemoryStore(ctx context.Context) (err error) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (h *Target) send(ctx context.Context, payload []byte, payloadCount int, payloadType string, timeout time.Duration) (err error) {
 | 
			
		||||
	h.failedMessages.Add(int64(payloadCount))
 | 
			
		||||
 | 
			
		||||
	defer func() {
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			if xnet.IsNetworkOrHostDown(err, false) {
 | 
			
		||||
				h.status.Store(statusOffline)
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			h.failedMessages.Add(-int64(payloadCount))
 | 
			
		||||
			h.status.Store(statusOnline)
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
@ -260,6 +257,7 @@ func (h *Target) send(ctx context.Context, payload []byte, payloadCount int, pay
 | 
			
		||||
 | 
			
		||||
	resp, err := h.client.Do(req)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		h.failedMessages.Add(int64(payloadCount))
 | 
			
		||||
		return fmt.Errorf("%s returned '%w', please check your endpoint configuration", h.Endpoint(), err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -270,8 +268,10 @@ func (h *Target) send(ctx context.Context, payload []byte, payloadCount int, pay
 | 
			
		||||
		// accepted HTTP status codes.
 | 
			
		||||
		return nil
 | 
			
		||||
	} else if resp.StatusCode == http.StatusForbidden {
 | 
			
		||||
		h.failedMessages.Add(int64(payloadCount))
 | 
			
		||||
		return fmt.Errorf("%s returned '%s', please check if your auth token is correctly set", h.Endpoint(), resp.Status)
 | 
			
		||||
	}
 | 
			
		||||
	h.failedMessages.Add(int64(payloadCount))
 | 
			
		||||
	return fmt.Errorf("%s returned '%s', please check your endpoint configuration", h.Endpoint(), resp.Status)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -345,6 +345,7 @@ func (h *Target) startQueueProcessor(ctx context.Context, mainWorker bool) {
 | 
			
		||||
 | 
			
		||||
	newTicker := time.NewTicker(time.Second)
 | 
			
		||||
	isTick := false
 | 
			
		||||
	var count int
 | 
			
		||||
 | 
			
		||||
	for {
 | 
			
		||||
		isTick = false
 | 
			
		||||
@ -360,7 +361,6 @@ func (h *Target) startQueueProcessor(ctx context.Context, mainWorker bool) {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var count int
 | 
			
		||||
		if !isTick {
 | 
			
		||||
			h.totalMessages.Add(1)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user