mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-28 13:44:03 +00:00
ci: enforce recovery object counts and require WAL samples in crash scrapes
A restart cell may set min_objects; it records the objects indexed at the kill and fails with exit 7 after its measurement when fewer were left. A crash scrape counts only when it holds the WAL sample its phase needs, and request totals keep only the S3 scheme. Signed-off-by: jeremyhi <fengjiachun@gmail.com>
This commit is contained in:
@@ -74,9 +74,13 @@ scrape_metrics() {
|
||||
}
|
||||
|
||||
# A crash cycle cannot repeat a scrape once its server is killed, so it retries.
|
||||
# The named WAL sample must be in the scrape, or it does not count.
|
||||
scrape_retry() {
|
||||
local attempt
|
||||
for attempt in 1 2 3; do scrape_metrics && return 0; sleep 1; done
|
||||
local required=$1 attempt
|
||||
for attempt in 1 2 3; do
|
||||
scrape_metrics && grep -q "^greptime_logstore_object_store_wal_$required " "$dir/metrics$phase.prom" && return 0
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -121,6 +125,8 @@ restart() {
|
||||
local table count started deadline
|
||||
table=$(jq -er .table "$dir/greptimedb-1/load-result.json")
|
||||
scrape_metrics || { echo "$id: metrics scrape failed" >&2; exit 4; }
|
||||
# The objects recovery has to read are those still indexed at the kill.
|
||||
indexed_before_kill=$(awk '/^greptime_logstore_object_store_wal_indexed_objects / {print $2}' "$dir/metrics.prom")
|
||||
stop_server kill
|
||||
phase=-restart started=$(now)
|
||||
start_server
|
||||
@@ -134,6 +140,9 @@ restart() {
|
||||
done
|
||||
restart_query_seconds=$(elapsed "$started") restart_count=$count
|
||||
[[ "$count" == "$(jq .rows <<< "$spec")" ]] || { echo "$id: $count rows after restart" >&2; exit 5; }
|
||||
# The restart was measured, but on fewer objects than the cell asked for.
|
||||
awk -v n="${indexed_before_kill:-0}" -v min="$(jq -r '.min_objects // 0' <<< "$spec")" 'BEGIN {exit !(n >= min)}' \
|
||||
|| { echo "$id: ${indexed_before_kill:-no} objects indexed at the kill, fewer than min_objects" >&2; exit 7; }
|
||||
}
|
||||
|
||||
# Pins the WAL with one row in a second table before the writers start, if asked,
|
||||
@@ -172,7 +181,7 @@ crash_cycles() {
|
||||
for ((cycle = 1; cycle <= cycles; cycle++)); do
|
||||
cdir="$dir/cycle-$cycle" complete=true; mkdir -p "$cdir"
|
||||
# The counters of this server process before its writers start are the cycle's baseline.
|
||||
phase=-start-$cycle; scrape_retry || complete=false
|
||||
phase=-start-$cycle; scrape_retry indexed_objects || complete=false
|
||||
load_start=$(now_ns)
|
||||
python3 "$here/oswal-s3-bench-crash.py" write --dir "$cdir" --url "$sql_url" \
|
||||
--writers "$writers" --first-seq "$next" --rows "$rows" &
|
||||
@@ -180,7 +189,7 @@ crash_cycles() {
|
||||
if jq -e .pin <<< "$spec" >/dev/null; then sample_objects & spid=$!; fi
|
||||
delay=$(awk -v a="$kill_min" -v b="$kill_max" 'BEGIN {srand(); printf "%.3f", a + rand() * (b - a)}')
|
||||
sleep "$delay"
|
||||
phase=-cycle-$cycle; scrape_retry || complete=false
|
||||
phase=-cycle-$cycle; scrape_retry indexed_objects || complete=false
|
||||
before=$(now_ns); docker kill --signal KILL "$cid" >/dev/null; after=$(now_ns)
|
||||
wait "$wpid"
|
||||
if [[ -n "$spid" ]]; then kill "$spid" 2>/dev/null || true; wait "$spid" 2>/dev/null || true; spid=; fi
|
||||
@@ -193,7 +202,7 @@ crash_cycles() {
|
||||
sleep 0.2
|
||||
done
|
||||
query_s=$(elapsed "$started")
|
||||
scrape_retry || complete=false
|
||||
scrape_retry recovery_seconds_count || complete=false
|
||||
pin_count=null
|
||||
if jq -e .pin <<< "$spec" >/dev/null; then
|
||||
pin_count=$(sql "SELECT count(*) FROM pin" | jq -er '.output[0].records.rows[0][0]')
|
||||
@@ -230,6 +239,7 @@ finish() {
|
||||
--arg load_seconds "$load_seconds" --argjson exit_code "$rc" --argjson scraped "$metrics_scraped" \
|
||||
--argjson restart_scraped "$restart_scraped" --arg restart_seconds "$restart_seconds" \
|
||||
--arg restart_query_seconds "$restart_query_seconds" --arg restart_count "$restart_count" \
|
||||
--arg indexed_before_kill "$indexed_before_kill" \
|
||||
--arg server_cpu_seconds "$server_cpu_seconds" --arg host_cpu_busy "$host_cpu_busy" --arg host_cpus "$(nproc 2>/dev/null)" \
|
||||
'$spec + {wal_device: $device, version: $version, exit_code: $exit_code, metrics_scraped: $scraped,
|
||||
load_wall_seconds: ($load_seconds | tonumber? // null),
|
||||
@@ -237,7 +247,8 @@ finish() {
|
||||
host_cpu_busy: ($host_cpu_busy | tonumber? // null), host_cpus: ($host_cpus | tonumber? // null),
|
||||
restart_scraped: $restart_scraped, restart_seconds: ($restart_seconds | tonumber? // null),
|
||||
restart_query_seconds: ($restart_query_seconds | tonumber? // null),
|
||||
restart_count: ($restart_count | tonumber? // null)}' > "$dir/cell.json"
|
||||
restart_count: ($restart_count | tonumber? // null),
|
||||
indexed_before_kill: ($indexed_before_kill | tonumber? // null)}' > "$dir/cell.json"
|
||||
exit "$rc"
|
||||
}
|
||||
|
||||
@@ -248,6 +259,7 @@ cell() {
|
||||
: "${RUN_PREFIX:?}" "${WAL_ROOT:?}" "${S3_BUCKET:?}" "${S3_REGION:?}" "${AWS_ACCESS_KEY_ID:?}" "${AWS_SECRET_ACCESS_KEY:?}"
|
||||
spec=$1 cid= wal_dir= home_dir= version= load_seconds= metrics_scraped=false id= phase=
|
||||
restart_scraped=false restart_seconds= restart_query_seconds= restart_count= server_cpu_seconds= host_cpu_busy=
|
||||
indexed_before_kill=
|
||||
local concurrency setting started cpu_before host_before host_after
|
||||
id=$(jq -r .id <<< "$spec"); concurrency=$(jq -r .concurrency <<< "$spec")
|
||||
dir="$RESULTS/cells/$id" name="$OWNER-$id"
|
||||
|
||||
@@ -32,14 +32,15 @@ SAMPLE = re.compile(r'([a-zA-Z_:][a-zA-Z0-9_:]*)(?:\{([^}]*)\})?\s+(\S+)')
|
||||
|
||||
|
||||
def parse_metrics(text: str) -> dict:
|
||||
"""Map each unlabeled sample to its value, each histogram to its buckets, and the
|
||||
object store requests (data files and WAL together) to their count per operation."""
|
||||
"""Map each unlabeled sample to its value, each histogram to its buckets, and the S3
|
||||
requests (data files and WAL together) to their count per operation; the local cache
|
||||
stores report through the same layer under another scheme and are left out."""
|
||||
samples, buckets, requests = {}, {}, {}
|
||||
for line in text.splitlines():
|
||||
match = SAMPLE.fullmatch(line.strip())
|
||||
if match and match.group(1) == "opendal_operation_duration_seconds_count":
|
||||
operation = re.search(r'operation="([^"]+)"', match.group(2) or "")
|
||||
if operation:
|
||||
if operation and re.search(r'scheme="s3"', match.group(2) or ""):
|
||||
requests[operation.group(1)] = requests.get(operation.group(1), 0) + float(match.group(3))
|
||||
continue
|
||||
if not match or not match.group(1).startswith(PREFIX):
|
||||
@@ -153,6 +154,7 @@ def load_cell(path: Path, spec: dict | None = None) -> dict:
|
||||
"recovery_seconds": restarted["samples"].get("recovery_seconds_sum") if count == 1 else None,
|
||||
"recovered_objects": restarted["samples"].get("recovered_objects_total")
|
||||
if cell.get("restart_scraped") else None,
|
||||
"indexed_before_kill": cell.get("indexed_before_kill"), "min_objects": cell.get("min_objects", 0),
|
||||
}
|
||||
# The counters register on their first event, so a scrape of an object store WAL
|
||||
# that created objects omits the ones that never moved: those are zero, not unknown.
|
||||
@@ -296,13 +298,16 @@ def render(run: dict, rows: list, pairs: list) -> str:
|
||||
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 "
|
||||
lines += ["", "| Cell | Overrides | Objects created | Indexed at kill | Restart to /health s | Restart to count s "
|
||||
"| Recovery s | Recovered objects | Rows after restart |",
|
||||
"| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: |"]
|
||||
"| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |"]
|
||||
for r in restarts:
|
||||
x = r["restart"]
|
||||
short = x["min_objects"] and (x["indexed_before_kill"] or 0) < x["min_objects"]
|
||||
lines.append(" | ".join([
|
||||
f"| {r['id']}", overrides(r["env"]), fmt(r["created_objects_total"]), fmt(x["wall_seconds"], 2),
|
||||
f"| {label(r)}", overrides(r["env"]), fmt(r["created_objects_total"]),
|
||||
fmt(x["indexed_before_kill"]) + (f" (under {x['min_objects']:,})" if short else ""),
|
||||
fmt(x["wall_seconds"], 2),
|
||||
fmt(x["query_seconds"], 2), fmt(x["recovery_seconds"], 3), fmt(x["recovered_objects"]),
|
||||
f"{fmt(x['rows'])} |"]))
|
||||
lines += ["", "| Group | Concurrency | Ratio | Swept value | Per round | Geometric mean |",
|
||||
|
||||
@@ -168,7 +168,12 @@ def group_cells(group: dict, smoke: bool) -> list:
|
||||
if mode == "load":
|
||||
if not 0 <= idle <= 600:
|
||||
raise ValueError(f"group {name!r}: idle_seconds must be in 0..600")
|
||||
common |= {"rows": rows, "data_profile": DATA_PROFILES.get(rows, "custom")}
|
||||
# The objects a restart cell must leave indexed at its kill; a smoke run is too small for any.
|
||||
min_objects = int(group.get("min_objects", 0))
|
||||
if min_objects < 0 or (min_objects and not restart):
|
||||
raise ValueError(f"group {name!r}: min_objects needs restart and must not be negative")
|
||||
common |= {"rows": rows, "data_profile": DATA_PROFILES.get(rows, "custom"),
|
||||
"min_objects": 0 if smoke else min_objects}
|
||||
else:
|
||||
cycles = int(group.get("cycles", 5))
|
||||
kill_after = [int(v) for v in group.get("kill_after", [3, 10])]
|
||||
@@ -207,7 +212,7 @@ def parse_groups(text: str, defaults: dict) -> list:
|
||||
groups = json.loads(text)
|
||||
if not isinstance(groups, list) or not groups or not all(isinstance(g, dict) for g in groups):
|
||||
raise ValueError("groups must be a non-empty JSON list of objects")
|
||||
known = set(defaults) | {"name", "mode", "idle_seconds", "cycles", "kill_after", "pin"}
|
||||
known = set(defaults) | {"name", "mode", "idle_seconds", "cycles", "kill_after", "pin", "min_objects"}
|
||||
names = [g.get("name") for g in groups]
|
||||
for group, name in zip(groups, names):
|
||||
if not isinstance(name, str) or not GROUP_NAME.fullmatch(name):
|
||||
|
||||
Reference in New Issue
Block a user