diff --git a/objectstore/RetrieveQueue.cpp b/objectstore/RetrieveQueue.cpp index 5f19a47d0f96e087785c7bcc58072e82cf444f51..14f94447b80dc89e031d4ebcf5e7a5bae842953c 100644 --- a/objectstore/RetrieveQueue.cpp +++ b/objectstore/RetrieveQueue.cpp @@ -459,6 +459,13 @@ void RetrieveQueue::addJobsAndCommit(std::list<JobToAdd> & jobsToAdd, AgentRefer maxDriveAllowedMap.incCount(j.policy.maxDrivesAllowed); priorityMap.incCount(j.policy.retrievePriority); minRetrieveRequestAgeMap.incCount(j.policy.retrieveMinRequestAge); + // oldestjobcreationtime is initialized to 0 when + if (m_payload.oldestjobcreationtime()) { + if ((uint64_t)j.startTime < m_payload.oldestjobcreationtime()) + m_payload.set_oldestjobcreationtime(j.startTime); + } else { + m_payload.set_oldestjobcreationtime(j.startTime); + } } // ... update the shard pointer auto shardSummary = rqs.getJobsSummary(); diff --git a/objectstore/RetrieveQueueTest.cpp b/objectstore/RetrieveQueueTest.cpp index 24b4ac1ecf97d1b056bb9dd52501701f86e5faf7..1701acda04966ef85d176e3cfba0e0c36dc1f92f 100644 --- a/objectstore/RetrieveQueueTest.cpp +++ b/objectstore/RetrieveQueueTest.cpp @@ -76,6 +76,8 @@ TEST(ObjectStore, RetrieveQueueShardingAndOrderingTest) { jta.retrieveRequestAddress = address.str(); jobsToAdd.push_back(jta); } + // By construction, first job has lowest start time. + auto minStartTime=jobsToAdd.front().startTime; std::string retrieveQueueAddress = agentRef.nextId("RetrieveQueue"); { // Try to create the retrieve queue @@ -119,6 +121,7 @@ TEST(ObjectStore, RetrieveQueueShardingAndOrderingTest) { ASSERT_NO_THROW(rq.fetch()); // Pop jobs while we can. They should come out in fseq order as there is // no interleaved push and pop. + ASSERT_EQ(minStartTime, rq.getJobsSummary().oldestJobStartTime); uint64_t nextExpectedFseq=0; while (rq.getJobsSummary().files) { auto candidateJobs = rq.getCandidateList(std::numeric_limits<uint64_t>::max(), 50, std::set<std::string>());