mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-07-24 09:02:59 +00:00
* test: add FUSE database load/durability/perf benchmark Runs MySQL (InnoDB) and SQLite with ~1GB datadirs on a SeaweedFS FUSE mount. Two parts: - durability: normal shutdown, kill -9, and crash-during-write all keep every fsync-committed row (verified by integrity check + row count + contiguous prefix + per-row CRC). - performance: FUSE vs the same local disk. fsync/commit latency is the dominant cost (~0.13ms -> ~1.18ms), so small transactions run ~9-12x slower while bulk loads and warm reads stay close. Harness is path-independent (runtime under $SEAWEED_BENCH_WORK) and only touches its own processes on non-default ports. * test/benchmark/fuse_db: portable to Linux + crash-safe progress - export MYSQL_BIN; mysql_bench.py falls back to PATH when unset - unmount via fusermount/fusermount3 (non-root Linux), then umount/diskutil - atomic progress write (tmp+fsync+rename); treat empty progress file as 0 - reuse a single PRNG in the perf probe so RNG init doesn't skew timings * test/benchmark/fuse_db: validate inputs, add subprocess timeout - mysql_bench.py: 1800s timeout on mysql CLI calls; reject db names that aren't plain identifiers (interpolated into SQL) - sqlite_gen.py / sqlite_verify.py: allowlist journal/synchronous modes and the verify mode so a typo can't silently weaken durability or relax checks - run_mysql.sh: durable atomic progress write (tmp+fsync+rename), matching sqlite_gen.py; quote $LB in both crash-test verify calls
68 lines
2.9 KiB
Bash
Executable File
68 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# SQLite ~1GB load test on the SeaweedFS FUSE mount + crash suite.
|
|
BIN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$BIN/lib.sh"
|
|
|
|
TOTAL=262144 # 262144 * 4096B payload = ~1GiB of row data
|
|
BATCH=4096 # 64 committed transactions (each fsync'd, synchronous=FULL)
|
|
DB=$MNT/sqlite/load.db
|
|
PROG=$LOCAL/sqlite_progress.txt
|
|
REF=$LOCAL/sqlite_ref.txt
|
|
PASS=0; FAIL=0
|
|
chk() { if [ "$1" -eq 0 ]; then echo ">>> $2: PASS"; PASS=$((PASS+1)); else echo ">>> $2: FAIL"; FAIL=$((FAIL+1)); fi; }
|
|
|
|
echo "######## SQLite FUSE load test $(date) ########"
|
|
|
|
# ---------- fresh cluster + 1GB load ----------
|
|
clean_state; cluster_start || exit 1; mount_start || exit 1
|
|
mkdir -p "$MNT/sqlite"
|
|
say "loading ~1GB into SQLite (journal=DELETE synchronous=FULL)"
|
|
t0=$SECONDS
|
|
python3 "$BIN/sqlite_gen.py" "$DB" $TOTAL $BATCH "$PROG" "$REF" FULL DELETE | tail -3
|
|
say "load done in $((SECONDS-t0))s; file size:"; ls -lh "$DB"; du -sh "$MNT/sqlite"
|
|
status_report
|
|
|
|
# ---------- Scenario A: normal (graceful) shutdown + restart ----------
|
|
echo; echo "==================== SCENARIO A: NORMAL SHUTDOWN ===================="
|
|
mount_stop_graceful
|
|
cluster_stop_graceful
|
|
sleep 1
|
|
cluster_start || exit 1; mount_start || exit 1
|
|
say "verifying after graceful restart"
|
|
python3 "$BIN/sqlite_verify.py" "$DB" $TOTAL exact; chk $? "A/normal-shutdown"
|
|
|
|
# ---------- Scenario B: unexpected shutdown (kill -9) + restart ----------
|
|
echo; echo "============== SCENARIO B: UNEXPECTED SHUTDOWN (kill -9) =============="
|
|
hard_kill_all
|
|
sleep 1
|
|
cluster_start || exit 1; mount_start || exit 1
|
|
say "verifying after kill -9 + restart"
|
|
python3 "$BIN/sqlite_verify.py" "$DB" $TOTAL exact; chk $? "B/unexpected-shutdown"
|
|
|
|
# ---------- Scenario C: crash DURING active writes ----------
|
|
echo; echo "=========== SCENARIO C: CRASH DURING ACTIVE WRITES (kill -9) ==========="
|
|
clean_state; cluster_start || exit 1; mount_start || exit 1
|
|
mkdir -p "$MNT/sqlite"; : > "$PROG"
|
|
say "starting loader in background; will crash storage mid-write"
|
|
python3 "$BIN/sqlite_gen.py" "$DB" $TOTAL $BATCH "$PROG" "" FULL DELETE > "$LOGS/sqlite_gen_c.log" 2>&1 &
|
|
GENPID=$!
|
|
# wait until at least half is durably committed
|
|
while :; do
|
|
p=$(cat "$PROG" 2>/dev/null || echo 0); p=${p:-0}
|
|
[ "$p" -ge $((TOTAL/2)) ] && break
|
|
kill -0 $GENPID 2>/dev/null || { say "loader exited early"; break; }
|
|
sleep 0.2
|
|
done
|
|
LB=$(cat "$PROG" 2>/dev/null); LB=${LB:-0} # empty file (killed mid-write) -> 0
|
|
say "durable committed lower-bound at crash = $LB rows; crashing storage now"
|
|
hard_kill_all # storage dies under the still-writing loader
|
|
kill -9 $GENPID 2>/dev/null; wait $GENPID 2>/dev/null
|
|
sleep 1
|
|
cluster_start || exit 1; mount_start || exit 1
|
|
say "verifying recovery (committed prefix must survive, integrity must hold)"
|
|
python3 "$BIN/sqlite_verify.py" "$DB" "$LB" atleast; chk $? "C/crash-during-write"
|
|
|
|
echo; echo "######## SQLite RESULT: PASS=$PASS FAIL=$FAIL ########"
|
|
mount_stop_graceful; cluster_stop_graceful
|
|
exit $FAIL
|