Skip to content

Commit

Permalink
CCDB fix: fetch headers to RequestContext when reading snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
shahor02 committed Nov 28, 2023
1 parent f63f7a1 commit aaa1300
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CCDB/include/CCDB/CcdbApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::string> headers,
long timestamp, std::map<std::string, std::string>& headers,
std::string& snapshotpath, o2::pmr::vector<char>& 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;
Expand Down
7 changes: 4 additions & 3 deletions CCDB/src/CcdbApi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::string> headers,
long timestamp, std::map<std::string, std::string>& headers,
std::string& snapshotpath, o2::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const
{
if (createSnapshot) { // create named semaphore
Expand All @@ -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
Expand Down

0 comments on commit aaa1300

Please sign in to comment.