-
Notifications
You must be signed in to change notification settings - Fork 711
fix: file list query #4969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: file list query #4969
Conversation
WalkthroughThe changes in this pull request involve updates to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
src/infra/src/file_list/mod.rs (1)
Line range hint
436-459: Consider improving the garbage collection implementation.A few suggestions to enhance the robustness of the GC implementation:
- Consider making the interval configurable rather than hardcoding 3600 seconds
- Add a mechanism to gracefully shutdown the GC task
- Consider retrying on errors with backoff instead of just logging them
Here's a suggested implementation:
pub async fn local_cache_gc() -> Result<()> { + const DEFAULT_GC_INTERVAL_SECS: u64 = 3600; + let gc_interval = std::env::var("LOCAL_CACHE_GC_INTERVAL_SECS") + .ok() + .and_then(|s| s.parse().ok()) + .unwrap_or(DEFAULT_GC_INTERVAL_SECS); + + let handle = tokio::task::spawn(async move { let cfg = config::get_config(); if cfg.common.local_mode || !cfg.common.meta_store_external { return; } - // gc every hour - let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(3600)); + let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(gc_interval)); interval.tick().await; // the first tick is immediate + + let mut backoff = tokio::time::Duration::from_secs(1); loop { if let Ok(min_id) = get_min_pk_value().await { if min_id > 0 { match LOCAL_CACHE.clean_by_min_pk_value(min_id).await { - Ok(_) => log::info!("[file_list] local cache gc done"), - Err(e) => log::error!("[file_list] local cache gc failed: {}", e), + Ok(_) => { + log::info!("[file_list] local cache gc done"); + backoff = tokio::time::Duration::from_secs(1); + } + Err(e) => { + log::error!("[file_list] local cache gc failed: {}", e); + tokio::time::sleep(backoff).await; + backoff = std::cmp::min(backoff * 2, tokio::time::Duration::from_secs(60)); + } } } } interval.tick().await; } - }); + }); + + // Store the handle somewhere for cleanup during shutdown + Ok(()) }src/config/src/config.rs (2)
Line range hint
1349-1500: Consider adding documentation for file list configurationsThe file list configurations (
file_list_id_batch_sizeandfile_list_multi_thread) would benefit from documentation explaining:
- The impact of batch size on memory usage and performance
- When to enable/disable multi-threading
- Recommended values for different scenarios
Line range hint
1349-1500: Add memory-based validation for file list batch sizeConsider adding validation in
check_memory_configto ensurefile_list_id_batch_sizedoesn't exceed a reasonable percentage of available memory. This would prevent potential memory issues in resource-constrained environments.Example validation to add in
check_memory_config:fn check_memory_config(cfg: &mut Config) -> Result<(), anyhow::Error> { let mem_total = cgroup::get_memory_limit(); cfg.limit.mem_total = mem_total; + + // Validate file_list_id_batch_size + let max_batch_size = mem_total / (1024 * 1024 * 10); // Max 10% of memory + if cfg.limit.file_list_id_batch_size > max_batch_size { + cfg.limit.file_list_id_batch_size = max_batch_size; + log::warn!("Reducing file_list_id_batch_size to {} to prevent memory issues", max_batch_size); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
Cargo.toml(1 hunks)src/config/src/config.rs(1 hunks)src/infra/src/file_list/mod.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/config/src/config.rs (1)
Pattern **/*.rs: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestions
Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
src/infra/src/file_list/mod.rs (1)
Pattern **/*.rs: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestions
Make sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
🔇 Additional comments (5)
Cargo.toml (2)
247-247: LGTM: Minor version update for dotenvy
The minor version bump from 0.15 to 0.15.7 includes bug fixes and improvements while maintaining backward compatibility.
246-246: Verify compatibility with dotenv_config 0.2.1
The major version bump (0.1 -> 0.2.1) might introduce breaking changes. Please ensure all usage of dotenv_config in the codebase is compatible with the new version.
✅ Verification successful
Based on the code analysis, I can now generate the final response since I have enough information to verify the dotenv_config version update:
The dotenv_config version update is safe to proceed
The codebase uses only the EnvConfig trait from dotenv_config, which is a stable feature for deriving configuration from environment variables. The usage is straightforward and limited to struct derivations, making the major version bump (0.1 -> 0.2.1) safe as it maintains the core functionality.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for dotenv_config usage patterns that might need updates
rg -A 5 'dotenv_config::'
Length of output: 329
Script:
#!/bin/bash
# Let's check the actual usage of EnvConfig to understand potential breaking changes
ast-grep --pattern 'use dotenv_config::EnvConfig;
$$$'
Length of output: 56
Script:
#!/bin/bash
# Let's check the actual implementation in config.rs to understand the usage
cat src/config/src/config.rs
Length of output: 78823
src/infra/src/file_list/mod.rs (2)
19-24: LGTM! Clean import organization.
The imports are well-organized and properly grouped under the config namespace.
463-465: LGTM! Improved time conversion clarity.
The use of second_micros makes the time conversion more explicit and maintainable.
src/config/src/config.rs (1)
1349-1349: Improved error handling with expect
Good improvement in error handling by replacing unwrap() with expect(). This provides better context when initialization fails.
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a garbage collection mechanism for the local cache, enhancing resource management. - **Improvements** - Enhanced error handling during configuration initialization for better debugging. - Updated time calculations to improve accuracy and consistency. - **Dependency Updates** - Updated versions of key dependencies to leverage new features and fixes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit