bd43a6b566
Implement three critical validation checkpoints to improve recovery reliability and provide users with clear diagnostic information before recovery attempts. Issue #1: Pre-flight file validation - New validate_backup_files() function validates all critical files before starting MySQL instance (ibdata1, redo logs, mysql/, target DB) - Checks readability and permissions - Prevents wasted time starting instance when files are missing - Provides clear remediation steps if issues found Issue #2: Enhanced database discovery - New discover_and_report_databases() function lists all found databases and explains why target database might be missing - Automatic system table accessibility testing - Root cause diagnosis (which system tables are corrupted) - Actionable remediation suggestions based on failure type Issue #3: System table validation - New test_system_tables() function validates critical system tables after instance starts, before dump attempt - Tests mysql.db, mysql.innodb_table_stats, information_schema.schemata - Early detection of system table corruption - User choice to continue or cancel based on test results Integration into recovery workflow: - validate_backup_files() called before instance startup (~line 2080) - test_system_tables() called after startup, before dump (~line 2184) - discover_and_report_databases() called in dump_database() (~line 1571) Benefits: - Immediate feedback if recovery will fail (before instance startup) - Clear diagnostic output explaining exactly what's wrong - No more mystery failures with vague error messages - Actionable remediation steps for each failure mode Testing: - ✓ Syntax validation passed - ✓ All integration points verified - ✓ MySQL version compatibility (5.7, 8.0, 8.0.30+) - ✓ Edge cases handled (permissions, missing tables, corruption) - ✓ Backward compatible with existing workflow Related: Ticket #43751550, MYSQL_RESTORE_SCRIPT_IMPROVEMENTS.md Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>