From cb1651e387aea8267d627db05612cdb2b20ad521 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Tue, 11 Nov 2025 18:09:08 +0100 Subject: [PATCH] DPL: properly handle excess of offers --- .../Core/src/ComputingQuotaEvaluator.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Framework/Core/src/ComputingQuotaEvaluator.cxx b/Framework/Core/src/ComputingQuotaEvaluator.cxx index aa566ccb4d549..85a5e6be467a7 100644 --- a/Framework/Core/src/ComputingQuotaEvaluator.cxx +++ b/Framework/Core/src/ComputingQuotaEvaluator.cxx @@ -247,6 +247,7 @@ void ComputingQuotaEvaluator::updateOffers(std::vector& pen { O2_SIGNPOST_ID_GENERATE(oid, quota); O2_SIGNPOST_START(quota, oid, "updateOffers", "Starting to processe received offers"); + int lastValid = -1; for (size_t oi = 0; oi < mOffers.size(); oi++) { auto& storeOffer = mOffers[oi]; auto& info = mInfos[oi]; @@ -256,6 +257,9 @@ void ComputingQuotaEvaluator::updateOffers(std::vector& pen } if (storeOffer.valid == true) { O2_SIGNPOST_EVENT_EMIT(quota, oid, "updateOffers", "Skipping update of offer %zu because it's still valid", oi); + // In general we want to fill an invalid offer. If we do not find any + // we add to the last valid offer we found. + lastValid = oi; continue; } info.received = now; @@ -266,7 +270,20 @@ void ComputingQuotaEvaluator::updateOffers(std::vector& pen storeOffer.valid = true; pending.pop_back(); } - O2_SIGNPOST_END_WITH_ERROR(quota, oid, "updateOffers", "Some of the pending offers were not treated"); + if (lastValid == -1) { + O2_SIGNPOST_END_WITH_ERROR(quota, oid, "updateOffers", "ComputingQuotaOffer losts. This should never happen."); + return; + } + auto& lastValidOffer = mOffers[lastValid]; + for (auto& stillPending : pending) { + lastValidOffer.cpu += stillPending.cpu; + lastValidOffer.memory += stillPending.memory; + lastValidOffer.sharedMemory += stillPending.sharedMemory; + lastValidOffer.timeslices += stillPending.timeslices; + lastValidOffer.runtime = std::max(lastValidOffer.runtime, stillPending.runtime); + } + pending.clear(); + O2_SIGNPOST_END(quota, oid, "updateOffers", "Remaining offers cohalesced to %d", lastValid); } void ComputingQuotaEvaluator::handleExpired(std::function expirator)