Fix additional issues found in deep dive analysis
1. Remove dead code: Broken socket safety check (line 882)
- The condition [ "\$datadir/socket.mysql" = "/var/lib/mysql/mysql.sock" ]
would never be true and is redundant (real check exists at line 864)
- Removed 4 lines of dead code
2. Simplify confirmation logic (line 1660)
- Was: if [ "\$confirm" = "0" ] || [ "\$confirm" != "y" ]
- Now: if [ "\$confirm" != "y" ]
- More readable and clearer intent (only "y" proceeds)
3. Quote unquoted variable in kill command (line 1000)
- Was: kill -0 \$pid
- Now: kill -0 "\$pid"
- Prevents word splitting if PID contains spaces
4. Clarify script flow (line 740-742)
- Added comment explaining why script exits after show_recovery_options()
- Helps users understand they must re-run script with new recovery level
- Prevents confusion about script termination
This is intentional design: show recovery options, user manually selects
level, user re-runs script. This prevents blind escalation through recovery
levels without explicit user approval at each step (safety consideration).
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -736,6 +736,11 @@ show_recovery_options() {
|
|||||||
echo "════════════════════════════════════════════════════════════════"
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# NOTE: After showing recovery options, the script will exit and user must
|
||||||
|
# re-run it with the selected recovery level in Step 4.
|
||||||
|
# This is intentional to avoid automatic retries with different recovery levels
|
||||||
|
# which could cause data corruption if blindly escalating through levels.
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check available disk space (CRITICAL SAFETY CHECK #3)
|
# Check available disk space (CRITICAL SAFETY CHECK #3)
|
||||||
@@ -878,12 +883,6 @@ start_second_instance() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify using custom socket (not live MySQL socket)
|
|
||||||
if [ -S "/var/lib/mysql/mysql.sock" ] && [ "$datadir/socket.mysql" = "/var/lib/mysql/mysql.sock" ]; then
|
|
||||||
print_error "CRITICAL: Attempting to use live MySQL socket!"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Display isolation confirmation
|
# Display isolation confirmation
|
||||||
echo ""
|
echo ""
|
||||||
print_success "Safety checks passed:"
|
print_success "Safety checks passed:"
|
||||||
@@ -998,7 +997,7 @@ start_second_instance() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Check if process is still running
|
# Check if process is still running
|
||||||
if ! kill -0 $pid 2>/dev/null; then
|
if ! kill -0 "$pid" 2>/dev/null; then
|
||||||
print_error "Second MySQL instance failed to start"
|
print_error "Second MySQL instance failed to start"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -1660,10 +1659,10 @@ step5_create_dump() {
|
|||||||
print_warning "Your live MySQL instance will NOT be affected."
|
print_warning "Your live MySQL instance will NOT be affected."
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "Proceed with dump creation? (y/n, or 0 to cancel): "
|
echo -n "Proceed with dump creation? (y/n): "
|
||||||
read -r confirm
|
read -r confirm
|
||||||
|
|
||||||
if [ "$confirm" = "0" ] || [ "$confirm" != "y" ]; then
|
if [ "$confirm" != "y" ]; then
|
||||||
echo "Operation cancelled."
|
echo "Operation cancelled."
|
||||||
press_enter
|
press_enter
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user