From a9dcc8e2c94f768c1b2ddf4fd4e1e9057b086678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Skocze=C5=84?= Date: Thu, 6 Nov 2025 12:00:37 +0000 Subject: [PATCH] Fix sending OnFinish to in-flight async API calls in scheduler --- pkg/scheduler/backend/api_dispatcher/call_queue.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/scheduler/backend/api_dispatcher/call_queue.go b/pkg/scheduler/backend/api_dispatcher/call_queue.go index 14c1719234c..6b4fb96e0bf 100644 --- a/pkg/scheduler/backend/api_dispatcher/call_queue.go +++ b/pkg/scheduler/backend/api_dispatcher/call_queue.go @@ -122,12 +122,14 @@ func (cq *callQueue) merge(oldAPICall, apiCall *queuedAPICall) error { return err } if oldAPICall.CallType() != apiCall.CallType() { + if cq.inFlightEntities.Has(oldAPICall.UID()) { + // Old API call is in-flight. The new call needs to wait for the old one to finish. + return nil + } // API call types don't match, so we overwrite the old one. // Update the pending calls metric if the old call is not in-flight. - if !cq.inFlightEntities.Has(oldAPICall.UID()) { - metrics.AsyncAPIPendingCalls.WithLabelValues(string(oldAPICall.CallType())).Dec() - metrics.AsyncAPIPendingCalls.WithLabelValues(string(apiCall.CallType())).Inc() - } + metrics.AsyncAPIPendingCalls.WithLabelValues(string(oldAPICall.CallType())).Dec() + metrics.AsyncAPIPendingCalls.WithLabelValues(string(apiCall.CallType())).Inc() oldAPICall.sendOnFinish(fmt.Errorf("a more relevant call was enqueued for this object: %w", fwk.ErrCallOverwritten)) return nil }