Companion code for Zero-Downtime Database Migrations: Expand-Contract in Practice with Spring Boot: a full expand/migrate-writes/migrate-reads/contract sequence run as an actual rolling deploy across two live replicas, with a load generator sending continuous HTTP traffic through all four deploys (99.98% success, every residual error traced to a root cause rather than left unexplained). Findings include a real NOT NULL constraint trap in the expand migration, a backfill-window bug in the read switch, H2's AUTO_SERVER=TRUE single-point-of-failure behavior under a rolling restart, the drain-before-SIGTERM fix needed to close a health-check gap during graceful shutdown, and H2 silently discarding a concurrently committed INSERT during an ALTER TABLE ADD/DROP COLUMN rebuild - confirmed, by primary source, to be an H2-specific behavior rather than a property of the technique itself. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019Fb7vW8vLyLKngBc4R3huA
23 lines
875 B
Bash
Executable File
23 lines
875 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Starts the load generator against both replica ports for a fixed duration and
|
|
# returns immediately - it runs in the background for the rest of run-all.sh.
|
|
# Usage: run-load-generator.sh <durationSeconds>
|
|
set -euo pipefail
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$DIR/env.sh"
|
|
|
|
DURATION="${1:-170}"
|
|
rm -f "$EC_PHASE_FILE" "$EC_LOAD_SUMMARY"
|
|
set_phase "00-baseline-soak"
|
|
|
|
nohup java -cp "$MODULE_DIR/target/classes:$(cat "$CP_FILE")" \
|
|
com.ankurm.expandcontract.loadgen.LoadGenerator \
|
|
--ports="$PORT_A,$PORT_B" \
|
|
--durationSeconds="$DURATION" \
|
|
--phaseFile="$EC_PHASE_FILE" \
|
|
--outFile="$EC_LOAD_SUMMARY" \
|
|
--threads=8 \
|
|
> "$EC_LOG_DIR/load-generator.log" 2>&1 < /dev/null &
|
|
echo $! > "$EC_PID_DIR/loadgen.pid"
|
|
echo "load generator started (pid $(cat "$EC_PID_DIR/loadgen.pid")), running for ${DURATION}s"
|