Files
memory/patterns/galera-ddl-deadlock.md
Dominik Schön bbbe4f8985 feat: patterns/ directory + skill-impact tracker (WikiSkill-inspired)
- New patterns/ directory with 7 initial failure-mode patterns (PAT-001..007)
- skill-impact.md audit trail for skill modifications
- _template.md for future pattern creation
- index.md updated with Patterns section
- log.md entry for this change
- Inspired by arXiv:2608.27454 (WikiSkill)
2026-08-30 11:16:19 +00:00

1.8 KiB

pattern_id, title, category, severity, status, first_observed, last_updated, related_systems, related_solution_docs, related_skills
pattern_id title category severity status first_observed last_updated related_systems related_solution_docs related_skills
PAT-001 OPTIMIZE TABLE on Galera triggers TOI DDL → Deadlock database high active 2026-07 2026-08-30
galera-maxscale
docs/solutions/bug-fixes/2026-07-23-cnpg-timeline-corruption-rebuild.md

OPTIMIZE TABLE on Galera triggers TOI DDL → Deadlock

Symptom

Running OPTIMIZE TABLE on a Galera cluster node causes a cluster-wide stall or deadlock. The table lock propagates via TOI (Total Order Isolation) to all nodes, blocking all writes to ALL tables during the operation.

Root Cause

Galera executes DDL statements (including OPTIMIZE TABLE, ALTER TABLE, etc.) in TOI mode. This means the DDL is replicated as a global operation that blocks the entire cluster — not just the target table. For large tables, the rebuild phase can take minutes, causing apparent outages.

Mitigation

  1. Use RSU before DDL: Switch the node to Rolling Schema Update (RSU) mode before running OPTIMIZE TABLE. This prevents cluster-wide blocking:
    SET GLOBAL wsrep_OSU_method = 'RSU';
    -- run OPTIMIZE TABLE on this node only
    SET GLOBAL wsrep_OSU_method = 'TOI';  -- restore
    
  2. Schedule during maintenance window — even with RSU, the node itself is degraded
  3. Consider pt-online-schema-change for large tables — avoids blocking entirely

Prevention

  • Never run OPTIMIZE TABLE or ALTER TABLE in production without RSU on Galera
  • Add this check to DBA runbooks and monitoring alerts
  • The Galera skill (mariadb-galera-cluster-administration) documents this pitfall

Evidence

  • Observed during Galera cluster administration sessions (Jul 2026)
  • MEMORY.md entry: "OPTIMIZE TABLE=TOI DDL→Deadlock! RSU davor."
  • Galera cluster: nodes 300/301/302, VIP .70:3306