ci: record failed pinned samples as missing

A periodic scrape that fails or lacks the indexed object count is written as a missing sample instead of zero objects, the summary counts missing samples, and a sampler that already exited no longer aborts the crash cycle.

Signed-off-by: jeremyhi <fengjiachun@gmail.com>
This commit is contained in:
jeremyhi
2026-10-13 08:56:21 +08:00
parent 55eac3a4a1
commit 30f179cf9d
3 changed files with 40 additions and 15 deletions
+12 -4
View File
@@ -139,12 +139,20 @@ restart() {
# Pins the WAL with one row in a second table before the writers start, if asked,
# and samples the object counts every 30 s while they run.
sample_objects() {
while sleep 30; do
curl --noproxy '*' -fsS --max-time 10 http://127.0.0.1:4000/metrics 2>/dev/null | awk -v t="$(date +%s)" '
set +e
local body
while sleep "${OSWAL_SAMPLE_SECONDS:-30}"; do
# A failed scrape is a missing sample, never zero objects.
if ! body=$(curl --noproxy '*' -fsS --max-time 10 http://127.0.0.1:4000/metrics 2>/dev/null) \
|| ! grep -q '^greptime_logstore_object_store_wal_indexed_objects ' <<< "$body"; then
echo "$(date +%s) missing" >> "$dir/objects.tsv"
continue
fi
awk -v t="$(date +%s)" '
/^greptime_logstore_object_store_wal_indexed_objects / {i = $2}
/^greptime_logstore_object_store_wal_deleted_objects_total / {d = $2}
/^greptime_logstore_object_store_wal_created_objects_total / {c = $2}
END {print t, i + 0, d + 0, c + 0}' >> "$dir/objects.tsv"
END {print t, i + 0, d + 0, c + 0}' <<< "$body" >> "$dir/objects.tsv"
done
}
@@ -175,7 +183,7 @@ crash_cycles() {
phase=-cycle-$cycle; scrape_retry || complete=false
before=$(now_ns); docker kill --signal KILL "$cid" >/dev/null; after=$(now_ns)
wait "$wpid"
[[ -z "$spid" ]] || { kill "$spid" 2>/dev/null; wait "$spid" 2>/dev/null || true; spid=; }
if [[ -n "$spid" ]]; then kill "$spid" 2>/dev/null || true; wait "$spid" 2>/dev/null || true; spid=; fi
stop_server killed
phase=-restart-$cycle started=$(now)
start_server
+9 -6
View File
@@ -172,8 +172,10 @@ def load_cell(path: Path, spec: dict | None = None) -> dict:
if row["mode"] == "crash":
row["cycles"] = crash_cycles(path, cell.get("wal", {}))
if (path / "objects.tsv").exists():
row["objects_samples"] = [[int(float(v)) for v in line.split()]
for line in (path / "objects.tsv").read_text().splitlines() if line.strip()]
# A sample is time, indexed, deleted, created; a failed scrape is time and "missing".
row["objects_samples"] = [[int(float(line.split()[0]))] + (
[None] * 3 if line.split()[1:] == ["missing"] else [int(float(v)) for v in line.split()[1:]])
for line in (path / "objects.tsv").read_text().splitlines() if line.strip()]
return row
@@ -285,12 +287,13 @@ def render(run: dict, rows: list, pairs: list) -> str:
operations(c["requests"]), operations(c["restart_requests"])]) + " |")
pinned = [r for r in crashes if r.get("objects_samples")]
if pinned:
lines += ["", "| Cell | Indexed objects every 30 s | Deleted objects at the end | Created objects at the end |",
"| --- | --- | ---: | ---: |"]
lines += ["", "| Cell | Indexed objects every 30 s | Missing samples | Deleted objects at the end "
"| Created objects at the end |", "| --- | --- | ---: | ---: | ---: |"]
for r in pinned:
samples = r["objects_samples"]
lines.append(f"| {r['id']} | {', '.join(str(s[1]) for s in samples)} | {samples[-1][2]:,} "
f"| {samples[-1][3]:,} |")
last = next((s for s in reversed(samples) if s[1] is not None), [None] * 4)
lines.append(f"| {r['id']} | {', '.join('missing' if s[1] is None else str(s[1]) for s in samples)} "
f"| {sum(s[1] is None for s in samples)} | {fmt(last[2])} | {fmt(last[3])} |")
restarts = [r for r in rows if "restart" in r]
if restarts:
lines += ["", "| Cell | Overrides | Objects created | Restart to /health s | Restart to count s "