Skip to content

Commit b4f03d4

Browse files
sawenzelclaude
andcommitted
Pin reproducer CCDB queries to the original job's run time
Reproducers resolved CCDB against the present, so any object re-uploaded since the job ran silently changed the outcome -- e.g. FT0/Calib/EventsPerBc, whose late arrival flips o2-steer-colcontexttool to the non-uniform sampler and gives a different collision context at the same fixed seed. Inject ALICEO2_CCDB_CONDITION_NOT_AFTER, which BasicCCDBManager picks up, so it covers the anchoring stage as well as the workflow tasks. Only pin when the moment is actually known: $2 if given, else "now" when run inside the job itself (the anchorMC.sh path). Otherwise skip and say so -- a wrong pin is worse than none. Skipped too if the JDL already sets it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 1845629 commit b4f03d4

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

GRID/utils/getReproducerScript.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
#!/bin/bash
22
ALIEN_PID=$1
33

4+
# Epoch-ms the generated reproducer will pin its CCDB queries to (see the
5+
# INJECTION block below for why). This MUST be the moment the *original* job
6+
# ran; "now" is only the same thing when this script runs inside that very job.
7+
#
8+
# $2 given -> use it verbatim (the escape hatch for
9+
# regenerating an old job's reproducer)
10+
# running inside the job -> now == the job's start time, correct
11+
# otherwise -> unknown; do NOT guess, skip the pinning
12+
#
13+
# The last case matters: silently pinning to the wrong moment is worse than not
14+
# pinning at all, because it looks authoritative while reconstructing a CCDB
15+
# view that never existed for this job.
16+
NOT_AFTER=$2
17+
if [ -z "${NOT_AFTER}" ]; then
18+
if [ -n "${ALIEN_PROC_ID}" ] && [ "${ALIEN_PROC_ID}" = "${ALIEN_PID}" ]; then
19+
NOT_AFTER=$(date +%s%3N)
20+
else
21+
echo "[getReproducerScript] Not running inside job ${ALIEN_PID} and no start"
22+
echo "[getReproducerScript] time given, so CCDB will NOT be pinned: the"
23+
echo "[getReproducerScript] reproducer will use present-day conditions."
24+
echo "[getReproducerScript] Re-run as: $0 ${ALIEN_PID} <job-start-epoch-ms>"
25+
fi
26+
fi
27+
428
if [ ${JALIEN_TOKEN_CERT} ]; then
529
TOKENCERT=${JALIEN_TOKEN_CERT}
630
TOKENKEY=${JALIEN_TOKEN_KEY}
@@ -24,10 +48,33 @@ curl 'https://alimonitor.cern.ch/users/jobenv.jsp?pid='${ALIEN_PID}
2448
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36' \
2549
--insecure --cert ${TOKENCERT} --key ${TOKENKEY} -o ${SCRIPT}
2650

51+
# If the JDL already declares a CCDB time-machine timestamp, the job pinned
52+
# itself and that value is restored further down by the MonaLisa env block (and
53+
# consumed by anchorMC.sh). Injecting our own would fight it, and the JDL's is
54+
# the authoritative one, so stand down.
55+
CCDB_PIN_BLOCK=""
56+
if grep -q "ALIEN_JDL_CCDB_CONDITION_NOT_AFTER" "${SCRIPT}"; then
57+
echo "[getReproducerScript] JDL already sets CCDB_CONDITION_NOT_AFTER; keeping it."
58+
elif [ -n "${NOT_AFTER}" ]; then
59+
# Pin every CCDB query to the time the ORIGINAL job ran ("time machine").
60+
# Without this the reproducer resolves each object to whatever is newest in
61+
# CCDB *today*, so any re-upload since the job ran silently changes the
62+
# result -- including the collision context, which is otherwise fully
63+
# deterministic given the fixed seed (cf. O2-7093). This reconstructs the
64+
# job's CCDB view rather than sharing a declared one, because production jobs
65+
# are themselves normally unpinned (o2dpg_sim_workflow.py defaults
66+
# --condition-not-after to year 2077).
67+
# Unset ALICEO2_CCDB_CONDITION_NOT_AFTER before running to get present-day
68+
# conditions instead.
69+
CCDB_PIN_BLOCK="export ALICEO2_CCDB_CONDITION_NOT_AFTER=\${ALICEO2_CCDB_CONDITION_NOT_AFTER:-${NOT_AFTER}}"
70+
echo "[getReproducerScript] Pinning reproducer CCDB queries to ${NOT_AFTER}."
71+
fi
72+
2773
# Define the Apptainer injection block which makes sure
2874
# that the job script is automatically executed in apptainer
2975
INJECTION='
3076
export ALIEN_PID=#ALIEN_PID#
77+
#CCDB_PIN_BLOCK#
3178
# Check if the script is running inside an Apptainer (Singularity) container
3279
if [ -z "$APPTAINER_NAME" ] && [ -z "$SINGULARITY_NAME" ]; then
3380
# Relaunch this script inside the container
@@ -77,4 +124,9 @@ sed -i "/cd alien-job-$ALIEN_PID/d" "$SCRIPT"
77124
# replace the PID
78125
sed -i "s/#ALIEN_PID#/${ALIEN_PID}/g" "$SCRIPT"
79126

127+
# substitute the CCDB pinning placeholder (dropping the line entirely when we
128+
# decided not to pin -- see above)
129+
awk -v blk="$CCDB_PIN_BLOCK" '$0=="#CCDB_PIN_BLOCK#"{ if (blk!="") print blk; next } 1' \
130+
"$SCRIPT" > tmpfile && mv tmpfile "$SCRIPT"
131+
80132
chmod +x "${SCRIPT}"

0 commit comments

Comments
 (0)