Fix missing files detection - add 'was not found at' pattern
The intelligent recovery system wasn't detecting missing .ibd files because MariaDB/MySQL error format uses 'was not found at' instead of 'missing'. Changes: - Added 'was not found at' pattern to grep searches (3 locations) - Enhanced tablespace extraction to parse './db/table.ibd' format - Extracts database/table from error: 'Tablespace N was not found at ./db/table.ibd' - Falls back to quoted tablespace name extraction if new pattern doesn't match Now when script detects missing .ibd files it will: - Show DIAGNOSIS: Missing or unopenable tablespace files - List exact missing tables with database names - Provide copy-paste ready cp commands - Show all recovery options instead of generic troubleshooting
This commit is contained in:
@@ -275,7 +275,7 @@ show_recovery_options() {
|
||||
local memory_issue=""
|
||||
|
||||
if [ -f "$error_log" ]; then
|
||||
if grep -qE "Cannot open tablespace|Tablespace.*missing|Unable to open" "$error_log"; then
|
||||
if grep -qE "Cannot open tablespace|Tablespace.*missing|Tablespace.*was not found|Unable to open" "$error_log"; then
|
||||
missing_files="yes"
|
||||
fi
|
||||
if grep -qE "Corrupted|Database page corruption" "$error_log"; then
|
||||
@@ -303,9 +303,16 @@ show_recovery_options() {
|
||||
|
||||
# Extract tablespace names from various error patterns
|
||||
while IFS= read -r error_line; do
|
||||
# Pattern 1: "Cannot open tablespace 'db/table'"
|
||||
if echo "$error_line" | grep -qE "Cannot open|Unable to open|Tablespace.*missing"; then
|
||||
local tablespace=$(echo "$error_line" | grep -oE "'[^']+'" | tr -d "'" | head -1)
|
||||
# Pattern 1: "Cannot open tablespace 'db/table'" or "Tablespace N was not found at ./db/table.ibd"
|
||||
if echo "$error_line" | grep -qE "Cannot open|Unable to open|Tablespace.*missing|was not found at"; then
|
||||
# Try to extract path from "was not found at ./path/table.ibd"
|
||||
local tablespace=$(echo "$error_line" | grep -oE '\./[^/]+/[^.]+\.ibd' | sed 's|\./||;s|\.ibd||' | head -1)
|
||||
|
||||
# Fallback: try to extract from quoted tablespace name
|
||||
if [ -z "$tablespace" ]; then
|
||||
tablespace=$(echo "$error_line" | grep -oE "'[^']+'" | tr -d "'" | head -1)
|
||||
fi
|
||||
|
||||
if [ -n "$tablespace" ]; then
|
||||
missing_list+=("$tablespace")
|
||||
missing_count=$((missing_count + 1))
|
||||
@@ -320,7 +327,7 @@ show_recovery_options() {
|
||||
missing_count=$((missing_count + 1))
|
||||
fi
|
||||
fi
|
||||
done < <(grep -iE "Cannot open|Unable to open|Tablespace.*missing|Cannot find space id" "$error_log" 2>/dev/null)
|
||||
done < <(grep -iE "Cannot open|Unable to open|Tablespace.*missing|was not found at|Cannot find space id" "$error_log" 2>/dev/null)
|
||||
|
||||
if [ "$missing_count" -gt 0 ]; then
|
||||
print_warning "MISSING FILES DETECTED ($missing_count found):"
|
||||
@@ -351,7 +358,7 @@ show_recovery_options() {
|
||||
print_warning "Could not parse specific missing files from error log"
|
||||
echo "Showing raw error lines:"
|
||||
echo ""
|
||||
grep -iE "Cannot open|Unable to open|Tablespace.*missing" "$error_log" 2>/dev/null | head -10
|
||||
grep -iE "Cannot open|Unable to open|Tablespace.*missing|was not found at" "$error_log" 2>/dev/null | head -10
|
||||
echo ""
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user