Skip to content

fix: delete date stats #1306

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

Merged
merged 3 commits into from
May 3, 2025
Merged

Conversation

parmesant
Copy link
Contributor

@parmesant parmesant commented May 1, 2025

Stats were not getting deleted during stream deletion

Fixes #XXXX.

Description


This PR has:

  • been tested to ensure log ingestion and log query works.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages when deleting local stream data, now providing detailed error information if deletion fails.
  • Refactor
    • Enhanced metric removal logic to match and delete metrics based on label presence rather than positional prefix.
    • Added safer error handling during metric label removal to prevent error propagation and log warnings instead.

Stats were not getting deleted during stream deletion
Copy link
Contributor

coderabbitai bot commented May 1, 2025

Walkthrough

The changes update error handling and logic for stream deletion and metric removal across several modules. In the HTTP logstream handlers, error messages now include specific error details when directory removal fails, using a more explicit error-capturing pattern. In the ingestor logstream handler, the pre-deletion existence check and recreation logic are removed, with deletion now proceeding directly if the stream is present in memory. In the stats module, the logic for deleting metrics by label prefix is revised to check for the presence of prefix elements anywhere in the label values, rather than requiring a positional prefix match. Additionally, a helper function was introduced to handle label value removals with error logging.

Changes

File(s) Change Summary
src/handlers/http/logstream.rs
src/handlers/http/modal/query/querier_logstream.rs
Updated error handling in stream directory deletion to capture and log specific error details.
src/handlers/http/modal/ingest/ingestor_logstream.rs Removed pre-deletion existence check and recreation of streams; improved error logging in directory deletion.
src/stats.rs Added helper for safe removal of label values with error logging; changed metric deletion by label prefix to check for presence anywhere in label values instead of positional prefix.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant HTTP_Handler
    participant StreamMemory
    participant FileSystem
    participant Stats

    Client->>HTTP_Handler: DELETE /stream/{name}
    HTTP_Handler->>StreamMemory: Retrieve stream directory
    alt Stream exists
        HTTP_Handler->>FileSystem: Remove directory at data_path
        alt Remove fails
            HTTP_Handler->>HTTP_Handler: Log warning with error details
        end
        HTTP_Handler->>StreamMemory: Remove stream from memory
        HTTP_Handler->>Stats: Delete metrics with label prefix
        HTTP_Handler-->>Client: Respond with result
    else Stream missing
        HTTP_Handler-->>Client: Respond with error
    end
Loading

Suggested reviewers

  • nikhilsinhaparseable

Poem

In the warren of code, a tidy-up spree,
Error logs now show what went wrong, you see!
No more checking twice if a stream is around—
If it’s not in memory, it won’t be found.
Metrics now vanish if their labels align,
Not just at the start, but anywhere in line.
🐇 Cheers to clear logs and code that’s refined!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 79e5424 and 9d1750c.

📒 Files selected for processing (1)
  • src/stats.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/stats.rs
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: coverage
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/handlers/http/modal/ingest/ingestor_logstream.rs (1)

64-71: ⚠️ Potential issue

Simplified logic with improved error handling

The updated code makes two significant improvements:

  1. Uses get_stream which returns an error if the stream doesn't exist instead of trying to create it
  2. Captures and logs the specific error when removing the stream directory

This change ensures that statistics deletion is properly tied to stream existence and improves error diagnostics.

This change is essential for fixing the main issue where statistics were not being deleted during stream deletion, as mentioned in the PR description. The previous implementation might have failed silently if the stream wasn't found in memory.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a90ed13 and ac24570.

📒 Files selected for processing (4)
  • src/handlers/http/logstream.rs (1 hunks)
  • src/handlers/http/modal/ingest/ingestor_logstream.rs (1 hunks)
  • src/handlers/http/modal/query/querier_logstream.rs (1 hunks)
  • src/stats.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: coverage
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
🔇 Additional comments (2)
src/handlers/http/logstream.rs (1)

60-63: Improved error handling with detailed error messages

The updated code now captures and logs the specific error when removing the stream directory, which provides better diagnostics for troubleshooting file system issues.

src/handlers/http/modal/query/querier_logstream.rs (1)

71-74: Improved error handling with detailed error messages

The updated code now captures and logs the specific error when removing the stream directory, which provides better diagnostics for troubleshooting file system issues.

@nikhilsinhaparseable nikhilsinhaparseable changed the title bugfix fix: delete date stats May 1, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes May 2, 2025
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable left a comment

Choose a reason for hiding this comment

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

looks good

@nitisht nitisht merged commit 01d4449 into parseablehq:main May 3, 2025
14 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.

3 participants