Skip to content

fix hot tier path#1562

Merged
nikhilsinhaparseable merged 1 commit intoparseablehq:mainfrom
nikhilsinhaparseable:hot-tier-fix
Mar 1, 2026
Merged

fix hot tier path#1562
nikhilsinhaparseable merged 1 commit intoparseablehq:mainfrom
nikhilsinhaparseable:hot-tier-fix

Conversation

@nikhilsinhaparseable
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable commented Mar 1, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved hot tier metadata handling stability by eliminating potential crash scenarios.
    • Expanded hot tier metadata path resolution to support both tenant-scoped and global configurations for more flexible multi-tenant deployments.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

Walkthrough

The change modifies src/hottier.rs to support both tenant-scoped and global paths when checking for a stream's hot tier metadata file existence. The implementation conditionally includes tenant_id in the path hierarchy and removes an unsafe unwrap() call, replacing it with direct existence checks.

Changes

Cohort / File(s) Summary
Hot tier path resolution
src/hottier.rs
Added conditional tenant-scoped path resolution for hot tier metadata file existence checks. Removed unwrap() call to prevent potential panics, implementing multi-path fallback logic for both tenant-aware and global path scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A path now splits in two directions,
Tenant-scoped or global affections,
No panic shall we find today,
Just safer logic on the way! 🌿

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is entirely missing, with no content provided by the author despite a clear template being available in the repository. Add a complete pull request description following the template, including the issue number, description of the goal, rationale for the solution, key changes made, and checklist items for testing and documentation.
Title check ❓ Inconclusive The title 'fix hot tier path' is vague and generic, using non-descriptive terms that don't convey specific information about what aspect of the hot tier path is being fixed. Provide a more specific title that describes the fix, such as 'Support tenant-scoped and global hot tier paths' or 'Fix hot tier metadata path resolution for multi-tenant support'.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hottier.rs (1)

216-216: ⚠️ Potential issue | 🔴 Critical

Bug: delete_hot_tier path does not include tenant_id.

The path construction at line 216 is inconsistent with the updated check_stream_hot_tier_exists. For multi-tenant deployments:

  • Existence check looks at: hot_tier_path/tenant_id/stream/
  • Delete operates on: hot_tier_path/stream/

This will cause deletion of the wrong directory (or failure if it doesn't exist) when tenant_id is provided.

Proposed fix
     pub async fn delete_hot_tier(
         &self,
         stream: &str,
         tenant_id: &Option<String>,
     ) -> Result<(), HotTierError> {
         if !self.check_stream_hot_tier_exists(stream, tenant_id) {
             return Err(HotTierValidationError::NotFound(stream.to_owned()).into());
         }
-        let path = self.hot_tier_path.join(stream);
+        let path = if let Some(tenant_id) = tenant_id.as_ref() {
+            self.hot_tier_path.join(tenant_id).join(stream)
+        } else {
+            self.hot_tier_path.join(stream)
+        };
         fs::remove_dir_all(path).await?;

         Ok(())
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hottier.rs` at line 216, delete_hot_tier is building the wrong path
(self.hot_tier_path.join(stream)) and must mirror check_stream_hot_tier_exists
which uses hot_tier_path/tenant_id/stream; update the path construction inside
delete_hot_tier to include the tenant_id when present (e.g., join tenant_id
before joining stream) so the delete targets hot_tier_path/tenant_id/stream, and
keep the fallback to hot_tier_path/stream only if tenant_id is absent; reference
function names: delete_hot_tier, check_stream_hot_tier_exists, and fields:
hot_tier_path, tenant_id, stream.
🧹 Nitpick comments (1)
src/hottier.rs (1)

597-607: The path construction logic is correct but duplicates hot_tier_file_path.

The tenant-aware path logic here is identical to lines 246-255. Consider extracting a shared helper method that returns PathBuf to avoid duplication:

Suggested helper extraction
+    /// Build the hot tier file path for a stream as a PathBuf
+    fn hot_tier_file_path_buf(&self, stream: &str, tenant_id: &Option<String>) -> PathBuf {
+        if let Some(tenant_id) = tenant_id.as_ref() {
+            self.hot_tier_path
+                .join(tenant_id)
+                .join(stream)
+                .join(STREAM_HOT_TIER_FILENAME)
+        } else {
+            self.hot_tier_path
+                .join(stream)
+                .join(STREAM_HOT_TIER_FILENAME)
+        }
+    }
+
     pub fn hot_tier_file_path(
         &self,
         stream: &str,
         tenant_id: &Option<String>,
     ) -> Result<object_store::path::Path, HotTierError> {
-        let path = if let Some(tenant_id) = tenant_id.as_ref() {
-            self.hot_tier_path
-                .join(tenant_id)
-                .join(stream)
-                .join(STREAM_HOT_TIER_FILENAME)
-        } else {
-            self.hot_tier_path
-                .join(stream)
-                .join(STREAM_HOT_TIER_FILENAME)
-        };
+        let path = self.hot_tier_file_path_buf(stream, tenant_id);
         let path = object_store::path::Path::from_absolute_path(path)?;
         Ok(path)
     }

     pub fn check_stream_hot_tier_exists(&self, stream: &str, tenant_id: &Option<String>) -> bool {
-        let path = if let Some(tenant_id) = tenant_id.as_ref() {
-            self.hot_tier_path
-                .join(tenant_id)
-                .join(stream)
-                .join(STREAM_HOT_TIER_FILENAME)
-        } else {
-            self.hot_tier_path
-                .join(stream)
-                .join(STREAM_HOT_TIER_FILENAME)
-        };
-        path.exists()
+        self.hot_tier_file_path_buf(stream, tenant_id).exists()
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hottier.rs` around lines 597 - 607, Extract the duplicated tenant-aware
PathBuf construction into a single helper method (e.g.,
hot_tier_file_path(&self, stream: &str, tenant_id: Option<&str>) -> PathBuf)
that uses self.hot_tier_path, STREAM_HOT_TIER_FILENAME, and joins tenant_id when
present; replace the duplicated blocks (the one shown and the identical logic at
lines ~246-255) to call this helper and then call .exists() on its result so the
path-building logic is centralized and reused.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/hottier.rs`:
- Line 216: delete_hot_tier is building the wrong path
(self.hot_tier_path.join(stream)) and must mirror check_stream_hot_tier_exists
which uses hot_tier_path/tenant_id/stream; update the path construction inside
delete_hot_tier to include the tenant_id when present (e.g., join tenant_id
before joining stream) so the delete targets hot_tier_path/tenant_id/stream, and
keep the fallback to hot_tier_path/stream only if tenant_id is absent; reference
function names: delete_hot_tier, check_stream_hot_tier_exists, and fields:
hot_tier_path, tenant_id, stream.

---

Nitpick comments:
In `@src/hottier.rs`:
- Around line 597-607: Extract the duplicated tenant-aware PathBuf construction
into a single helper method (e.g., hot_tier_file_path(&self, stream: &str,
tenant_id: Option<&str>) -> PathBuf) that uses self.hot_tier_path,
STREAM_HOT_TIER_FILENAME, and joins tenant_id when present; replace the
duplicated blocks (the one shown and the identical logic at lines ~246-255) to
call this helper and then call .exists() on its result so the path-building
logic is centralized and reused.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ca4cfd and 8025b15.

📒 Files selected for processing (1)
  • src/hottier.rs

@nikhilsinhaparseable nikhilsinhaparseable merged commit b2fae6f into parseablehq:main Mar 1, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant