@@ -147,6 +147,10 @@ void CcdbApi::init(std::string const& host)
147147 // In addition, we can monitor exactly which objects are fetched and what is their content.
148148 // One can also distribute so obtained caches to sites without network access.
149149 //
150+ // THE INFORMATION BELOW IS TEMPORARILY WRONG: the functionality of checking the validity if IGNORE_VALIDITYCHECK_OF_CCDB_LOCALCACHE
151+ // is NOT set is broken. At the moment the code is modified to behave as if the IGNORE_VALIDITYCHECK_OF_CCDB_LOCALCACHE is always set
152+ // whenever the ALICEO2_CCDB_LOCALCACHE is defined.
153+ //
150154 // When used with the DPL CCDB fetcher (i.e. loadFileToMemory is called), in order to prefer the available snapshot w/o its validity
151155 // check an extra variable IGNORE_VALIDITYCHECK_OF_CCDB_LOCALCACHE must be defined, otherwhise the object will be fetched from the
152156 // server after the validity check and new snapshot will be created if needed
@@ -161,7 +165,7 @@ void CcdbApi::init(std::string const& host)
161165 }
162166 snapshotReport = fmt::format (" (cache snapshots to dir={}" , mSnapshotCachePath );
163167 }
164- if (getenv (" IGNORE_VALIDITYCHECK_OF_CCDB_LOCALCACHE" )) {
168+ if (cachedir) { // || getenv("IGNORE_VALIDITYCHECK_OF_CCDB_LOCALCACHE")) {
165169 mPreferSnapshotCache = true ;
166170 if (mSnapshotCachePath .empty ()) {
167171 LOGP (fatal, " IGNORE_VALIDITYCHECK_OF_CCDB_LOCALCACHE is defined but the ALICEO2_CCDB_LOCALCACHE is not" );
@@ -252,6 +256,10 @@ int CcdbApi::storeAsTFile_impl(const void* obj, std::type_info const& tinfo, std
252256 std::vector<char >::size_type maxSize) const
253257{
254258 // We need the TClass for this type; will verify if dictionary exists
259+ if (!obj) {
260+ LOGP (error, " nullptr is provided for object {}/{}/{}" , path, startValidityTimestamp, endValidityTimestamp);
261+ return -1 ;
262+ }
255263 CcdbObjectInfo info;
256264 auto img = createObjectImage (obj, tinfo, &info);
257265 return storeAsBinaryFile (img->data (), img->size (), info.getFileName (), info.getObjectType (),
@@ -372,6 +380,10 @@ int CcdbApi::storeAsTFile(const TObject* rootObject, std::string const& path, st
372380 long startValidityTimestamp, long endValidityTimestamp, std::vector<char >::size_type maxSize) const
373381{
374382 // Prepare file
383+ if (!rootObject) {
384+ LOGP (error, " nullptr is provided for object {}/{}/{}" , path, startValidityTimestamp, endValidityTimestamp);
385+ return -1 ;
386+ }
375387 CcdbObjectInfo info;
376388 auto img = createObjectImage (rootObject, &info);
377389 return storeAsBinaryFile (img->data (), img->size (), info.getFileName (), info.getObjectType (), path, metadata, startValidityTimestamp, endValidityTimestamp, maxSize);
@@ -1486,12 +1498,6 @@ void CcdbApi::scheduleDownload(RequestContext& requestContext, size_t* requestCo
14861498 auto data = new DownloaderRequestData (); // Deleted in transferFinished of CCDBDownloader.cxx
14871499 data->hoPair .object = &requestContext.dest ;
14881500
1489- auto signalError = [&chunk = requestContext.dest , &errorflag = data->errorflag ]() {
1490- chunk.clear ();
1491- chunk.reserve (1 );
1492- errorflag = true ;
1493- };
1494-
14951501 std::function<bool (std::string)> localContentCallback = [this , &requestContext](std::string url) {
14961502 return this ->loadLocalContentToMemory (requestContext.dest , url);
14971503 };
@@ -1533,6 +1539,7 @@ void CcdbApi::scheduleDownload(RequestContext& requestContext, size_t* requestCo
15331539 data->path = requestContext.path ;
15341540 data->timestamp = requestContext.timestamp ;
15351541 data->localContentCallback = localContentCallback;
1542+ data->userAgent = mUniqueAgentID ;
15361543
15371544 curl_easy_setopt (curl_handle, CURLOPT_URL, fullUrl.c_str ());
15381545 initCurlOptionsForRetrieve (curl_handle, (void *)(&data->hoPair ), writeCallback, false );
@@ -1570,7 +1577,7 @@ void CcdbApi::releaseNamedSemaphore(boost::interprocess::named_semaphore* sem, s
15701577}
15711578
15721579void CcdbApi::getFromSnapshot (bool createSnapshot, std::string const & path,
1573- long timestamp, std::map<std::string, std::string> headers,
1580+ long timestamp, std::map<std::string, std::string>& headers,
15741581 std::string& snapshotpath, o2::pmr::vector<char >& dest, int & fromSnapshot, std::string const & etag) const
15751582{
15761583 if (createSnapshot) { // create named semaphore
@@ -1580,9 +1587,10 @@ void CcdbApi::getFromSnapshot(bool createSnapshot, std::string const& path,
15801587 logStream << " CCDB-access[" << getpid () << " ] of " << mUniqueAgentID << " to " << path << " timestamp " << timestamp << " for load to memory\n " ;
15811588 }
15821589 }
1583-
15841590 if (mInSnapshotMode ) { // file must be there, otherwise a fatal will be produced;
1585- loadFileToMemory (dest, getSnapshotFile (mSnapshotTopPath , path), &headers);
1591+ if (etag.empty ()) {
1592+ loadFileToMemory (dest, getSnapshotFile (mSnapshotTopPath , path), &headers);
1593+ }
15861594 fromSnapshot = 1 ;
15871595 } else if (mPreferSnapshotCache && std::filesystem::exists (snapshotpath)) {
15881596 // 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
@@ -1671,8 +1679,6 @@ void CcdbApi::vectoredLoadFileToMemory(std::vector<RequestContext>& requestConte
16711679 // navigateSourcesAndLoadFile either retrieves file from snapshot immediately, or schedules it to be downloaded when mDownloader->runLoop is ran at a later time
16721680 auto & requestContext = requestContexts.at (i);
16731681 navigateSourcesAndLoadFile (requestContext, fromSnapshots.at (i), &requestCounter);
1674- logReading (requestContext.path , requestContext.timestamp , &requestContext.headers ,
1675- fmt::format (" {}{}" , requestContext.considerSnapshot ? " load to memory" : " retrieve" , fromSnapshots.at (i) ? " from snapshot" : " " ));
16761682 }
16771683
16781684 // Download the rest
@@ -1683,12 +1689,12 @@ void CcdbApi::vectoredLoadFileToMemory(std::vector<RequestContext>& requestConte
16831689 // Save snapshots
16841690 for (int i = 0 ; i < requestContexts.size (); i++) {
16851691 auto & requestContext = requestContexts.at (i);
1692+ logReading (requestContext.path , requestContext.timestamp , &requestContext.headers ,
1693+ fmt::format (" {}{}" , requestContext.considerSnapshot ? " load to memory" : " retrieve" , fromSnapshots.at (i) ? " from snapshot" : " " ));
16861694 if (!requestContext.dest .empty ()) {
16871695 if (requestContext.considerSnapshot && fromSnapshots.at (i) != 2 ) {
16881696 saveSnapshot (requestContext);
16891697 }
1690- } else {
1691- LOG (warning) << " Did not receive content for " << requestContext.path << " \n " ; // Temporarily demoted to warning, since it floods the infologger
16921698 }
16931699 }
16941700}
0 commit comments