On this page
Large Table DDL (ALTER TABLE) Blocking Concurrent Writes for Hours
Running 'ALTER TABLE transactions ADD INDEX idx_user_id (user_id)' on a 500 million row table in MySQL.
1. Understand Requirements & Scope
Running 'ALTER TABLE transactions ADD INDEX idx_user_id (user_id)' on a 500 million row table in MySQL. Failure cascade dynamic: Burst → Pool Saturated → Queue Bloat (10k) → STW GC → 💥 504 Timeouts.
Functional Requirements:
- Operational Invariant: "Execute large-table DDL strictly using online schema migration tools (gh- ost) to eliminate write lock downtime."
- Production Hardening: Use online schema change utilities (gh-ost or pt-online- schema-change), which build the modified table asynchronously in the background via triggers or binlog streaming, swapping
- Prevent cascading failure by isolating downstream degradation at the ingress boundary.
2. Back-of-the-Envelope Capacity Estimation
3. High-Level Architecture Flow
Use online schema change utilities (gh-ost or pt-online- schema-change), which build the modified table asynchronously in the background via triggers or binlog streaming, swapping tables with a sub-second metadata rename lock. Invariant: "Execute large-table DDL strictly using online schema migration tools (gh- ost) to eliminate write lock downtime."
Ingress → Bounded Admission Controller → Adaptive Concurrency / Queue Gate → Protected Worker Engine; Overload Shed Path → HTTP 429 / Circuit Fallback (<0.1ms).Fig 1. Architecture data flow and component topology.
4. Production Implementation & Code
// HARDENED: Fast local Bloom filter / Redis revocation list verification
Claims claims = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
if (revocationBloomFilter.mightContain(claims.getId()) && redis.exists("revoked:" + claims.getId())) {
throw new SecurityException("Revoked token access attempt rejected");
}Hardened Implementation Sequence
- Ingress Boundary Defense: Use online schema change utilities (gh-ost or pt-online- schema-change), which build the modified table asynchronously in the background via triggers
- Failure Containment: Eliminate unconstrained buffering and propagate physical backpressure.
- Invariant Enforcement: Execute large-table DDL strictly using online schema migration tools (gh- ost) to eliminate write lock downtime.
5. Key Decisions & Operational Mitigations
Architectural Decisions & Trade-Offs
- •Ingress Admission: Naive unconstrained buffering causes queue bloat and GC exhaustion. Mitigation: Bounded ingress gate with fast non-blocking shedding.
- •Resource Strategy: Static capacity allocations collapse under brownouts. Mitigation: Dynamic adaptive limits scaling to real-time physical bounds.
- •Outage Impact: Cascading lock convoys and memory saturation. Mitigation: Isolated failure domains keep P99 latency flat and protected.
Operational Hazards & Mitigations
- •Cascading Failure: Executing raw DDL directly in MySQL. The table is locked against writes. Application checkout transactions queue up, exhaust connection pools within 10 seconds, and crash the entire e- commerce store for the 3 hours the index builds.
- •Breakdown Chain: Burst → Pool Saturated → Queue Bloat (10k) → STW GC → 💥 504 Timeouts
- •Shedding Failure: Without fast rejection at the boundary, queued dead work triggers multi-second GC pauses, CPU thrashing, and cascading 504 Gateway Timeouts.
Interactive Knowledge Check • Question 1 of 3↓
Canary vs Blue-Green Release Strategies
What is the key advantage of Canary Deployments over Blue-Green Deployments for large-scale microservice clusters?