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=""
|
local memory_issue=""
|
||||||
|
|
||||||
if [ -f "$error_log" ]; then
|
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"
|
missing_files="yes"
|
||||||
fi
|
fi
|
||||||
if grep -qE "Corrupted|Database page corruption" "$error_log"; then
|
if grep -qE "Corrupted|Database page corruption" "$error_log"; then
|
||||||
@@ -303,9 +303,16 @@ show_recovery_options() {
|
|||||||
|
|
||||||
# Extract tablespace names from various error patterns
|
# Extract tablespace names from various error patterns
|
||||||
while IFS= read -r error_line; do
|
while IFS= read -r error_line; do
|
||||||
# Pattern 1: "Cannot open tablespace 'db/table'"
|
# 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"; then
|
if echo "$error_line" | grep -qE "Cannot open|Unable to open|Tablespace.*missing|was not found at"; then
|
||||||
local tablespace=$(echo "$error_line" | grep -oE "'[^']+'" | tr -d "'" | head -1)
|
# 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
|
if [ -n "$tablespace" ]; then
|
||||||
missing_list+=("$tablespace")
|
missing_list+=("$tablespace")
|
||||||
missing_count=$((missing_count + 1))
|
missing_count=$((missing_count + 1))
|
||||||
@@ -320,7 +327,7 @@ show_recovery_options() {
|
|||||||
missing_count=$((missing_count + 1))
|
missing_count=$((missing_count + 1))
|
||||||
fi
|
fi
|
||||||
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
|
if [ "$missing_count" -gt 0 ]; then
|
||||||
print_warning "MISSING FILES DETECTED ($missing_count found):"
|
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"
|
print_warning "Could not parse specific missing files from error log"
|
||||||
echo "Showing raw error lines:"
|
echo "Showing raw error lines:"
|
||||||
echo ""
|
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 ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user