Fix critical flaw: actually use error-based detection results
MAJOR FIX: The error detection function was calculating the correct recovery level, but the show_recovery_options() function was NOT using the results - it was still using the old level-based progression logic. Changes: 1. Missing files section (lines 435-445): - Now calls detect_recovery_level_from_errors() - Displays "Error analysis recommends: Force Recovery Level X" - Shows the recommended level to user prominently 2. Redo log incompatibility section (lines 568-615): - Now calls detect_recovery_level_from_errors() - Shows "Error analysis recommends: Force Recovery Level X" - Correctly uses Level 5 (not hardcoded Level 6) - Explains consequences of that level 3. Corruption section (lines 599-675): - Now uses recommended_level to determine what to display - Shows "Try Force Recovery Level X" based on detection - Only shows escalation levels up to recommended_level - Marks the detected level with "RECOMMENDED" indicator Impact: - Error detection now drives the actual user-facing recommendations - Recovery level selection is now truly intelligent, not just level progression - User gets the right recommendation based on error TYPE, not guesswork - Escalation happens only if user retries at the same level All 3 error paths now properly use error-based detection results. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -435,6 +435,12 @@ show_recovery_options() {
|
|||||||
print_error "DIAGNOSIS: Missing or unopenable tablespace files"
|
print_error "DIAGNOSIS: Missing or unopenable tablespace files"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Use error-based detection to confirm recovery level recommendation
|
||||||
|
local detection_result=$(detect_recovery_level_from_errors "$error_log" "$current_recovery")
|
||||||
|
local recommended_level=$(echo "$detection_result" | cut -d'|' -f1)
|
||||||
|
echo "Error analysis recommends: Force Recovery Level $recommended_level"
|
||||||
|
echo ""
|
||||||
|
|
||||||
# Parse error log to find EXACT missing files
|
# Parse error log to find EXACT missing files
|
||||||
echo "Analyzing error log for missing files..."
|
echo "Analyzing error log for missing files..."
|
||||||
echo ""
|
echo ""
|
||||||
@@ -568,6 +574,12 @@ show_recovery_options() {
|
|||||||
elif [ -n "$redo_incompatible" ]; then
|
elif [ -n "$redo_incompatible" ]; then
|
||||||
print_error "DIAGNOSIS: Redo log incompatibility"
|
print_error "DIAGNOSIS: Redo log incompatibility"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Use error-based detection to recommend appropriate recovery level
|
||||||
|
local detection_result=$(detect_recovery_level_from_errors "$error_log" "$current_recovery")
|
||||||
|
local recommended_level=$(echo "$detection_result" | cut -d'|' -f1)
|
||||||
|
local error_type=$(echo "$detection_result" | cut -d'|' -f2)
|
||||||
|
|
||||||
echo "Common causes:"
|
echo "Common causes:"
|
||||||
echo " - Backup from different MySQL version"
|
echo " - Backup from different MySQL version"
|
||||||
echo " - Mixed redo log formats (8.0.30 vs older)"
|
echo " - Mixed redo log formats (8.0.30 vs older)"
|
||||||
@@ -575,7 +587,7 @@ show_recovery_options() {
|
|||||||
echo ""
|
echo ""
|
||||||
print_warning "RECOMMENDED ACTIONS:"
|
print_warning "RECOMMENDED ACTIONS:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Option 1: Start Fresh with Correct Redo Logs"
|
echo " Option 1: Start Fresh with Correct Redo Logs (PREFERRED)"
|
||||||
echo " ────────────────────────────────────────────────"
|
echo " ────────────────────────────────────────────────"
|
||||||
echo " 1. Remove current redo logs:"
|
echo " 1. Remove current redo logs:"
|
||||||
if [ -d "$datadir/#innodb_redo" ]; then
|
if [ -d "$datadir/#innodb_redo" ]; then
|
||||||
@@ -590,10 +602,15 @@ show_recovery_options() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo " 3. Re-run this script"
|
echo " 3. Re-run this script"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Option 2: Force Recovery (if redo logs are lost)"
|
echo " Option 2: Force Recovery (if redo logs are lost/unavailable)"
|
||||||
echo " ────────────────────────────────────────────────"
|
echo " ────────────────────────────────────────────────"
|
||||||
echo " Some data loss may occur, but better than nothing"
|
echo " Error analysis recommends: Force Recovery Level $recommended_level"
|
||||||
echo " Re-run script and select Force Recovery Level 6"
|
echo " Re-run script and select recovery mode $recommended_level"
|
||||||
|
echo ""
|
||||||
|
if [ "$recommended_level" -ge 5 ]; then
|
||||||
|
echo " WARNING: This recovery level will skip log redo operations"
|
||||||
|
echo " Some recent transactions may be lost or incomplete"
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
elif [ -n "$corruption_detected" ]; then
|
elif [ -n "$corruption_detected" ]; then
|
||||||
@@ -610,43 +627,50 @@ show_recovery_options() {
|
|||||||
local level_4_desc="Prevents insert buffer merge operations"
|
local level_4_desc="Prevents insert buffer merge operations"
|
||||||
local level_6_desc="Skips page checksums (maximum recovery, most data loss risk)"
|
local level_6_desc="Skips page checksums (maximum recovery, most data loss risk)"
|
||||||
|
|
||||||
print_warning "RECOMMENDED ACTIONS (IN ORDER):"
|
print_warning "RECOMMENDED ACTION (from error analysis):"
|
||||||
|
echo " ✓ Try Force Recovery Level $recommended_level"
|
||||||
|
echo ""
|
||||||
|
print_warning "STEP-BY-STEP PROGRESSION:"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# If we haven't tried any recovery yet, start with level 1
|
# Show all levels up to and including the recommended level
|
||||||
if [ "$current_recovery" = "0" ] || [ -z "$current_recovery" ]; then
|
# This helps user understand the escalation path if needed
|
||||||
|
|
||||||
|
# Level 1
|
||||||
|
if [ "$recommended_level" -ge 1 ]; then
|
||||||
echo " Step 1: Try Force Recovery Level 1"
|
echo " Step 1: Try Force Recovery Level 1"
|
||||||
echo " ────────────────────────────────────────────────"
|
echo " ────────────────────────────────────────────────"
|
||||||
echo " Re-run script → Step 4 → Select recovery mode 1"
|
echo " Re-run script → Step 4 → Select recovery mode 1"
|
||||||
echo " $level_1_desc"
|
echo " $level_1_desc"
|
||||||
echo ""
|
if [ "$recommended_level" -eq 1 ]; then
|
||||||
echo " (If level 1 fails, proceed to level 4)"
|
echo " ^ RECOMMENDED (error analysis suggests this level)"
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If level 1 was tried, recommend level 4
|
# Level 4 (skip 2 and 3 as they're less commonly needed for corruption)
|
||||||
if [ "$current_recovery" = "1" ]; then
|
if [ "$recommended_level" -ge 4 ]; then
|
||||||
echo " Step 1: Try Force Recovery Level 4"
|
echo " Step 2: If Level 1 Fails, Try Force Recovery Level 4"
|
||||||
echo " ────────────────────────────────────────────────"
|
echo " ────────────────────────────────────────────────"
|
||||||
echo " Re-run script → Step 4 → Select recovery mode 4"
|
echo " Re-run script → Step 4 → Select recovery mode 4"
|
||||||
echo " $level_4_desc"
|
echo " $level_4_desc"
|
||||||
echo ""
|
if [ "$recommended_level" -eq 4 ]; then
|
||||||
echo " (If level 4 fails, proceed to level 6)"
|
echo " ^ RECOMMENDED (error analysis suggests this level)"
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If level 4+ was tried, recommend level 6 (last resort)
|
# Level 6 (last resort)
|
||||||
if [ "${current_recovery:-0}" -ge 4 ]; then
|
if [ "$recommended_level" -ge 6 ]; then
|
||||||
echo " Step 1: Try Force Recovery Level 6 (LAST RESORT)"
|
echo " Step 3: If Level 4 Fails, Try Force Recovery Level 6 (LAST RESORT)"
|
||||||
echo " ────────────────────────────────────────────────"
|
echo " ────────────────────────────────────────────────"
|
||||||
echo " Re-run script → Step 4 → Select recovery mode 6"
|
echo " Re-run script → Step 4 → Select recovery mode 6"
|
||||||
echo " $level_6_desc"
|
echo " $level_6_desc"
|
||||||
echo ""
|
echo " ^ RECOMMENDED (error analysis suggests this level - MAX DATA RISK)"
|
||||||
echo " NOTE: This may recover more data but at risk of data consistency"
|
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo " Step 2: If All Recovery Levels Fail"
|
echo " Step 4: If All Recovery Levels Fail"
|
||||||
echo " ────────────────────────────────────────────────"
|
echo " ────────────────────────────────────────────────"
|
||||||
echo " 1. Corruption may be in the backup itself"
|
echo " 1. Corruption may be in the backup itself"
|
||||||
echo " 2. Try restoring from an older backup date"
|
echo " 2. Try restoring from an older backup date"
|
||||||
|
|||||||
Reference in New Issue
Block a user