Skip to content

Commit b3e2faa

Browse files
committed
Merge branch 'dev' into stable-sync
2 parents 5681b79 + 550033f commit b3e2faa

File tree

1,298 files changed

+48436
-17871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,298 files changed

+48436
-17871
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Apply requested async label
3+
4+
'on':
5+
issue_comment:
6+
types:
7+
- created
8+
- edited
9+
10+
permissions: {}
11+
12+
jobs:
13+
apply_async_labels:
14+
name: Apply requested async label
15+
uses: alisw/ali-bot/.github/workflows/async-auto-label.yml@master
16+
permissions:
17+
pull-requests: write # to update labels
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Collect and print async labels
3+
4+
'on':
5+
pull_request_target:
6+
types:
7+
- opened
8+
- reopened
9+
branches:
10+
- dev
11+
12+
permissions: {}
13+
14+
jobs:
15+
list_async_labels:
16+
name: Collect and print async labels
17+
uses: alisw/ali-bot/.github/workflows/async-list-label.yml@master
18+
permissions:
19+
pull-requests: write # to update labels
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Security approval
3+
4+
'on':
5+
pull_request_review:
6+
types:
7+
- edited
8+
- submitted
9+
10+
permissions: {}
11+
12+
jobs:
13+
clean:
14+
name: Security approval
15+
uses: alisw/ali-bot/.github/workflows/pr-security-approval.yml@master
16+
permissions:
17+
pull-requests: read # to get last commit for PR
18+
statuses: write # for set-github-status

.github/workflows/reports.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v3
21-
- name: Set up Python 3.7
22-
uses: actions/setup-python@v1
21+
- name: Set up Python 3.10
22+
uses: actions/setup-python@v5
2323
with:
24-
python-version: 3.7
24+
python-version: '3.10'
2525
- uses: actions/cache@v2
2626
name: Configure pip caching
2727
with:
@@ -81,7 +81,7 @@ jobs:
8181
run: |
8282
set -x
8383
mkdir -p doc/data
84-
# We create new files once per month, mostly so that
84+
# We create new files once per month, mostly so that
8585
# we can keep the query results small. It does not
8686
# matter if we get results from different months,
8787
# as what matters is how we merge them.
@@ -96,7 +96,6 @@ jobs:
9696
# being published
9797
LAST_RELEASE="${{ github.event.inputs.LAST_RELEASE_DATE }}"
9898
MERGED_AFTER=${LAST_RELEASE:-$(date -v -14d +%Y-%m-%d)}
99-
10099
# Here we convert all the json files to per subsystem
101100
# logs, using the MERGED_AFTER date to further filter them.
102101
# Notice we can have duplicates in each file,
@@ -106,7 +105,7 @@ jobs:
106105
for f in doc/data/*_prs.json; do
107106
for x in Algorithm Analysis Common DataFormats Detectors EventVisualisation Examples Framework Generators Steer Testing Utilities; do
108107
cat $f | jq ".repository.pullRequests.edges[].node | select(.files.edges[].node.path | test(\"$x\")) | del(.files) | select(.state == \"MERGED\" and .mergedAt >= \"${MERGED_AFTER}\")" > /tmp/${x}_prs.json
109-
if [ ! X`jq -s length /tmp/${x}_prs.json` = X0 ]; then
108+
if [ ! X`jq -s length /tmp/${x}_prs.json` = X0 ]; then
110109
cat /tmp/${x}_prs.json | jq -r '"- [#\(.number)](https://github.com/AliceO2Group/AliceO2/pull/\(.number)) \(.mergedAt | split("T")[0]): \(.title) by [@\(.author.login)](https://github.com/\(.author.login))"' | sort -u >> /tmp/${x}_prs.md
111110
fi
112111
done

CCDB/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ o2_add_executable(upload
4545
SOURCES src/UploadTool.cxx
4646
PUBLIC_LINK_LIBRARIES O2::CCDB)
4747

48+
o2_add_executable(cleansemaphores
49+
COMPONENT_NAME ccdb
50+
SOURCES src/CleanCCDBSemaphores.cxx
51+
PUBLIC_LINK_LIBRARIES O2::CCDB)
52+
4853
o2_add_executable(downloadccdbfile
4954
COMPONENT_NAME ccdb
5055
SOURCES src/DownloadCCDBFile.cxx

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "CCDB/CcdbApi.h"
1919
#include "CCDB/CCDBTimeStampUtils.h"
2020
#include "CommonUtils/NameConf.h"
21+
#include "Framework/DataTakingContext.h"
22+
#include "Framework/DefaultsHelpers.h"
2123
#include <string>
2224
#include <chrono>
2325
#include <map>
@@ -48,10 +50,19 @@ class CCDBManagerInstance
4850
std::string uuid;
4951
long startvalidity = 0;
5052
long endvalidity = -1;
53+
long cacheValidFrom = 0; // time for which the object was cached
54+
long cacheValidUntil = -1; // object is guaranteed to be valid till this time (modulo new updates)
55+
size_t minSize = -1ULL;
56+
size_t maxSize = 0;
5157
int queries = 0;
5258
int fetches = 0;
5359
int failures = 0;
54-
bool isValid(long ts) { return ts < endvalidity && ts > startvalidity; }
60+
bool isValid(long ts) { return ts < endvalidity && ts >= startvalidity; }
61+
bool isCacheValid(long ts)
62+
{
63+
LOGP(debug, "isCacheValid : {} : {} : {} --> {}", cacheValidFrom, ts, cacheValidUntil, ts < cacheValidUntil && ts >= cacheValidFrom);
64+
return ts < cacheValidUntil && ts >= cacheValidFrom;
65+
}
5566
void clear()
5667
{
5768
noCleanupPtr = nullptr;
@@ -68,6 +79,7 @@ class CCDBManagerInstance
6879
CCDBManagerInstance(std::string const& path) : mCCDBAccessor{}
6980
{
7081
mCCDBAccessor.init(path);
82+
mDeplMode = o2::framework::DefaultsHelpers::deploymentMode();
7183
}
7284
/// set a URL to query from
7385
void setURL(const std::string& url);
@@ -99,6 +111,9 @@ class CCDBManagerInstance
99111
return getForTimeStamp<T>(path, timestamp);
100112
}
101113

114+
/// detect online processing modes (i.e. CCDB objects may be updated in the lifetime of the manager)
115+
bool isOnline() const { return mDeplMode == o2::framework::DeploymentMode::OnlineAUX || mDeplMode == o2::framework::DeploymentMode::OnlineDDS || mDeplMode == o2::framework::DeploymentMode::OnlineECS; }
116+
102117
/// retrieve an object of type T from CCDB as stored under path; will use the timestamp member
103118
template <typename T>
104119
T* get(std::string const& path)
@@ -132,7 +147,7 @@ class CCDBManagerInstance
132147
if (!isCachingEnabled()) {
133148
return false;
134149
}
135-
return mCache[path].isValid(timestamp);
150+
return (mCheckObjValidityEnabled && mCache[path].isValid(timestamp)) || mCache[path].isCacheValid(timestamp); // use stricter check
136151
}
137152

138153
/// check if checks of object validity before CCDB query is enabled
@@ -165,17 +180,19 @@ class CCDBManagerInstance
165180
void setFatalWhenNull(bool b) { mFatalWhenNull = b; }
166181

167182
/// A convenience function for MC to fetch
168-
/// valid start and end timestamps given an ALICE run number.
169-
/// On error it fatals (if fatal == true) or else returns the pair -1, -1.
170-
std::pair<int64_t, int64_t> getRunDuration(int runnumber, bool fatal = true) const;
171-
172-
/// A convenience function for MC to fetch
173-
/// valid start and end timestamps given an ALICE run number.
183+
/// valid start and end timestamps for recorded TF data given an ALICE run number.
184+
/// In absence of STF/ETF fields in the RCT with fall back to CTP SOX/EOX then to
185+
/// ECS SOR/EOR.
174186
/// On error it fatals (if fatal == true) or else returns the pair -1, -1.
187+
std::pair<int64_t, int64_t> getRunDuration(int runnumber, bool fatal = true);
175188
static std::pair<int64_t, int64_t> getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal = true);
176189

177190
std::string getSummaryString() const;
178191

192+
size_t getFetchedSize() const { return mFetchedSize; }
193+
194+
void report(bool longrep = false);
195+
179196
void endOfStream();
180197

181198
private:
@@ -190,14 +207,15 @@ class CCDBManagerInstance
190207
bool mCanDefault = false; // whether default is ok --> useful for testing purposes done standalone/isolation
191208
bool mCachingEnabled = true; // whether caching is enabled
192209
bool mCheckObjValidityEnabled = false; // wether the validity of cached object is checked before proceeding to a CCDB API query
210+
bool mFatalWhenNull = true; // if nullptr blob replies should be treated as fatal (can be set by user)
193211
long mCreatedNotAfter = 0; // upper limit for object creation timestamp (TimeMachine mode) - If-Not-After HTTP header
194212
long mCreatedNotBefore = 0; // lower limit for object creation timestamp (TimeMachine mode) - If-Not-Before HTTP header
195213
long mTimerMS = 0; // timer for queries
196-
bool mFatalWhenNull = true; // if nullptr blob replies should be treated as fatal (can be set by user)
214+
size_t mFetchedSize = 0; // total fetched size
197215
int mQueries = 0; // total number of object queries
198216
int mFetches = 0; // total number of succesful fetches from CCDB
199217
int mFailures = 0; // total number of failed fetches
200-
218+
o2::framework::DeploymentMode mDeplMode; // O2 deployment mode
201219
ClassDefNV(CCDBManagerInstance, 1);
202220
};
203221

@@ -218,11 +236,16 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
218236
mFailures++;
219237
} else {
220238
mFetches++;
239+
auto sh = mHeaders.find("fileSize");
240+
if (sh != mHeaders.end()) {
241+
size_t s = atol(sh->second.c_str());
242+
mFetchedSize += s;
243+
}
221244
}
222245
} else {
223246
auto& cached = mCache[path];
224-
if (mCheckObjValidityEnabled && cached.isValid(timestamp)) {
225-
cached.queries++;
247+
cached.queries++;
248+
if ((!isOnline() && cached.isCacheValid(timestamp)) || (mCheckObjValidityEnabled && cached.isValid(timestamp))) {
226249
return reinterpret_cast<T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr.get());
227250
}
228251
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, cached.uuid,
@@ -238,17 +261,41 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
238261
cached.objPtr.reset(ptr);
239262
}
240263
cached.uuid = mHeaders["ETag"];
241-
try { // this conversion can throw, better to catch immediately
242-
cached.startvalidity = std::stol(mHeaders["Valid-From"]);
243-
cached.endvalidity = std::stol(mHeaders["Valid-Until"]);
264+
265+
try {
266+
if (mHeaders.find("Valid-From") != mHeaders.end()) {
267+
cached.startvalidity = std::stol(mHeaders["Valid-From"]);
268+
} else {
269+
// if meta-information missing assume infinit validity
270+
// (should happen only for locally created objects)
271+
cached.startvalidity = 0;
272+
}
273+
if (mHeaders.find("Valid-Until") != mHeaders.end()) {
274+
cached.endvalidity = std::stol(mHeaders["Valid-Until"]);
275+
} else {
276+
cached.endvalidity = std::numeric_limits<long>::max();
277+
}
278+
cached.cacheValidFrom = timestamp;
244279
} catch (std::exception const& e) {
245280
reportFatal("Failed to read validity from CCDB response (Valid-From : " + mHeaders["Valid-From"] + std::string(" Valid-Until: ") + mHeaders["Valid-Until"] + std::string(")"));
246281
}
282+
auto sh = mHeaders.find("fileSize");
283+
if (sh != mHeaders.end()) {
284+
size_t s = atol(sh->second.c_str());
285+
mFetchedSize += s;
286+
cached.minSize = std::min(s, cached.minSize);
287+
cached.maxSize = std::max(s, cached.minSize);
288+
}
247289
} else if (mHeaders.count("Error")) { // in case of errors the pointer is 0 and headers["Error"] should be set
248290
cached.failures++;
249291
cached.clear(); // in case of any error clear cache for this object
250-
} else { // the old object is valid
251-
ptr = reinterpret_cast<T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr.get());
292+
}
293+
// the old object is valid, fetch cache end of validity
294+
ptr = reinterpret_cast<T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr.get());
295+
if (mHeaders.find("Cache-Valid-Until") != mHeaders.end()) {
296+
cached.cacheValidUntil = std::stol(mHeaders["Cache-Valid-Until"]);
297+
} else {
298+
cached.cacheValidUntil = -1;
252299
}
253300
mHeaders.clear();
254301
mMetaData.clear();

CCDB/include/CCDB/CCDBDownloader.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ typedef struct DownloaderRequestData {
5252
HeaderObjectPair_t hoPair;
5353
std::map<std::string, std::string>* headers;
5454
std::string userAgent;
55+
curl_slist* optionsList;
5556

5657
std::function<bool(std::string)> localContentCallback;
5758
} DownloaderRequestData;
@@ -296,6 +297,7 @@ class CCDBDownloader
296297
int hostInd;
297298
int locInd;
298299
DownloaderRequestData* requestData;
300+
curl_slist** options;
299301
} PerformData;
300302
#endif
301303

@@ -421,6 +423,6 @@ typedef struct DataForClosingSocket {
421423
curl_socket_t socket;
422424
} DataForClosingSocket;
423425

424-
} // namespace o2
426+
} // namespace o2::ccdb
425427

426428
#endif // O2_CCDB_CCDBDOWNLOADER_H

CCDB/include/CCDB/CcdbApi.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,14 @@ class CcdbApi //: public DatabaseInterface
375375
void getFromSnapshot(bool createSnapshot, std::string const& path,
376376
long timestamp, std::map<std::string, std::string>& headers,
377377
std::string& snapshotpath, o2::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const;
378-
void releaseNamedSemaphore(boost::interprocess::named_semaphore* sem, std::string path) const;
379-
boost::interprocess::named_semaphore* createNamedSempahore(std::string path) const;
378+
void releaseNamedSemaphore(boost::interprocess::named_semaphore* sem, std::string const& path) const;
379+
boost::interprocess::named_semaphore* createNamedSemaphore(std::string const& path) const;
380+
static std::string determineSemaphoreName(std::string const& basedir, std::string const& objectpath);
381+
// queries and optionally removes a named semaphore from the system
382+
// returns true when successful (either found or found + removed)
383+
static bool removeSemaphore(std::string const& name, bool remove = false);
384+
static void removeLeakingSemaphores(std::string const& basedir, bool remove = false);
385+
380386
void loadFileToMemory(o2::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders = nullptr) const;
381387
void loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& path,
382388
std::map<std::string, std::string> const& metadata, long timestamp,
@@ -542,7 +548,7 @@ class CcdbApi //: public DatabaseInterface
542548
* @param tcl The TClass object describing the serialized type
543549
* @return raw pointer to created object
544550
*/
545-
void* downloadFilesystemContent(std::string const& fullUrl, std::type_info const& tinfo) const;
551+
void* downloadFilesystemContent(std::string const& fullUrl, std::type_info const& tinfo, std::map<string, string>* headers) const;
546552

547553
// initialize the TGrid (Alien connection)
548554
bool initTGrid() const;

0 commit comments

Comments
 (0)