From aaa1300e8af76340e9929daa164010b2704a5c09 Mon Sep 17 00:00:00 2001 From: shahoian Date: Tue, 28 Nov 2023 02:52:02 +0100 Subject: [PATCH] CCDB fix: fetch headers to RequestContext when reading snapshot --- CCDB/include/CCDB/CcdbApi.h | 2 +- CCDB/src/CcdbApi.cxx | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CCDB/include/CCDB/CcdbApi.h b/CCDB/include/CCDB/CcdbApi.h index 5a04b00f340cf..a23b1a80130af 100644 --- a/CCDB/include/CCDB/CcdbApi.h +++ b/CCDB/include/CCDB/CcdbApi.h @@ -373,7 +373,7 @@ class CcdbApi //: public DatabaseInterface void scheduleDownload(RequestContext& requestContext, size_t* requestCounter) const; void getFromSnapshot(bool createSnapshot, std::string const& path, - long timestamp, std::map headers, + long timestamp, std::map& headers, std::string& snapshotpath, o2::pmr::vector& dest, int& fromSnapshot, std::string const& etag) const; void releaseNamedSemaphore(boost::interprocess::named_semaphore* sem, std::string path) const; boost::interprocess::named_semaphore* createNamedSempahore(std::string path) const; diff --git a/CCDB/src/CcdbApi.cxx b/CCDB/src/CcdbApi.cxx index cc10effec1c6e..e21b94a0d7ef4 100644 --- a/CCDB/src/CcdbApi.cxx +++ b/CCDB/src/CcdbApi.cxx @@ -1571,7 +1571,7 @@ void CcdbApi::releaseNamedSemaphore(boost::interprocess::named_semaphore* sem, s } void CcdbApi::getFromSnapshot(bool createSnapshot, std::string const& path, - long timestamp, std::map headers, + long timestamp, std::map& headers, std::string& snapshotpath, o2::pmr::vector& dest, int& fromSnapshot, std::string const& etag) const { if (createSnapshot) { // create named semaphore @@ -1581,9 +1581,10 @@ void CcdbApi::getFromSnapshot(bool createSnapshot, std::string const& path, logStream << "CCDB-access[" << getpid() << "] of " << mUniqueAgentID << " to " << path << " timestamp " << timestamp << " for load to memory\n"; } } - if (mInSnapshotMode) { // file must be there, otherwise a fatal will be produced; - loadFileToMemory(dest, getSnapshotFile(mSnapshotTopPath, path), &headers); + if (etag.empty()) { + loadFileToMemory(dest, getSnapshotFile(mSnapshotTopPath, path), &headers); + } fromSnapshot = 1; } else if (mPreferSnapshotCache && std::filesystem::exists(snapshotpath)) { // if file is available, use it, otherwise cache it below from the server. Do this only when etag is empty since otherwise the object was already fetched and cached