Fix RecycleCleanCommand critical database access bug and standardize logging#3854
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Fix database access: Changed from open_rooch_db_readonly() to open_rooch_db() - Standardize logging: Replaced all println!/eprintln! with tracing macros - Use standard input handling: Replaced manual input with utils::prompt_yes_no() Co-authored-by: jolestar <77268+jolestar@users.noreply.github.com>
- Maintain high safety barrier by requiring explicit 'DELETE' confirmation - Use utils::read_line() instead of manual std::io operations - Add clearer warning messages using tracing Co-authored-by: jolestar <77268+jolestar@users.noreply.github.com>
- Use 'DELETE-RECYCLE-BIN' instead of 'DELETE' to maintain the same safety level as original - This ensures no reduction in safety barrier for this destructive operation Co-authored-by: jolestar <77268+jolestar@users.noreply.github.com>
- Move read_line import to top with other imports - Follows Rust conventions and improves code organization Co-authored-by: jolestar <77268+jolestar@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical runtime bug in RecycleCleanCommand and standardizes its logging to match codebase conventions. The command was previously attempting write operations (deletion) on a read-only database handle, causing runtime failures. Additionally, all console output has been migrated from println!/eprintln! to structured tracing macros for better log level control.
Key Changes:
- Fixed database access mode from read-only to writable, enabling deletion operations
- Standardized all logging using
tracingmacros with appropriate levels (info, warn, error) - Replaced manual input handling with the
read_line()utility for consistency
|
@copilot 确保 make lint 可以通过 |
- Apply rustfmt formatting to recycle_bin.rs - Fix line length for long tracing::warn! message - Remove trailing whitespace - Ensures make lint passes Co-authored-by: jolestar <77268+jolestar@users.noreply.github.com>
已修复。已应用 Fixed in commit 8c64c89 - applied Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
RecycleCleanCommand Bug Fixes
✅ Phase 1: Critical Bug Fixes (COMPLETE)
open_rooch_db_readonly()toopen_rooch_db()on line 574println!andeprintln!withtracingmacrosinfo,warn,error)std::iooperations withutils::read_line()make lintformatting check passes📝 Phase 2: Performance Optimization (Deferred to Follow-up PR)
The O(1) deletion optimization via column family drop requires architectural changes:
🎯 Summary
This PR successfully fixes the three critical bugs identified:
All safety features are preserved:
--dry-runand--forcerequirements remain📊 Impact
make lintOriginal prompt
This section details on the original issue you should resolve
<issue_title>commands/db: Fix RecycleCleanCommand critical bugs and performance issues</issue_title>
<issue_description>## 🐛 Bug Description
The
RecycleCleanCommandhas several critical issues that prevent it from functioning correctly and provide poor user experience:1. Critical Database Access Bug
open_rooch_db_readonly()instead ofopen_rooch_db()for deletion operationscrates/rooch/src/commands/db/commands/recycle_bin.rs:574-5792. Inconsistent Logging
eprintln!andprintln!throughout the commandeprintln!for errors, Line 654 useseprintln!for user prompts3. Manual Input Handling
std::iooperations instead of existing utility functionscrates/rooch/src/commands/db/commands/recycle_bin.rs:654-6634. Suboptimal Performance for Full Cleanup
🎯 Proposed Solution
Phase 1: Critical Bug Fixes
open_rooch_db_readonly()withopen_rooch_db()utils::prompt_yes_no()Phase 2: Performance Optimization
📊 Performance Impact
🛠 Implementation Details
Database Access Fix
Hybrid Deletion Strategy
Standardized Logging
Standard Input Handling
🧪 Testing Strategy
🔒 Safety Considerations
--dry-runand--forcerequirements remain📝 Files to Modify
Primary Files
crates/rooch/src/commands/db/commands/recycle_bin.rs- Main implementation fixescrates/rooch-pruner/src/recycle_bin.rs- Hybrid deletion strategyReference Files
crates/rooch/src/utils.rs- Utility functions to usemoveos/moveos-store/src/state_store/mod.rs- Column family operations🎉 Expected Outcomes
🏷 Labels
bug,enhancement,area::db,status::ready-for-dev🔗 Related Is...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.