- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 135
fix: dataloss due to contention at stream creation #1258
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
Conversation
WalkthroughThis pull request revises stream management by replacing the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🪧 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 (
|
Signed-off-by: Devdutt Shenoi <devdutt@outlook.in>
Signed-off-by: Devdutt Shenoi <devdutt@outlook.in>
@coderabbitai, are you even checking the code comments for typos and semantics! 😭 |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed:
Length of output: 73435 @de-sh I do check for typos in comments, but I may have missed some. Sorry about that! 😅 Could you point out which specific comments have typos so I can improve my review quality? I'd be happy to pay more attention to comment quality in both code and reviews going forward. Is this related to the documentation comment for the 🐰 (Feeling a bit embarrassed) |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed:
Length of output: 250 🏁 Script executed:
Length of output: 166 🏁 Script executed:
Length of output: 3565 @de-sh You're absolutely right, and I apologize for missing this! I should have been more attentive to the code comments during my review. I see that you had to make separate commits titled "doc: improve messaging" and "doc: fix typo" to address these issues. Rest assured, I'll be more diligent about checking comments for typos and semantic clarity in future reviews. Thank you for bringing this to my attention. ✏️ Learnings added
|
Thank you ❤️ |
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
🧹 Nitpick comments (1)
src/parseable/streams.rs (1)
740-742
: Documentation looks good but minor typo.The documentation clearly explains the intended behavior of the new method. This is an important change that helps prevent contention among threads during stream creation.
Correct the typo in the word "exclusive":
- /// Checks after getting an excluse lock whether the stream already exists, else creates it. + /// Checks after getting an exclusive lock whether the stream already exists, else creates it.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/metadata.rs
(1 hunks)src/parseable/streams.rs
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- GitHub Check: coverage
- GitHub Check: Build Default x86_64-apple-darwin
- GitHub Check: Build Default x86_64-pc-windows-msvc
- GitHub Check: Build Default x86_64-unknown-linux-gnu
- GitHub Check: Build Kafka aarch64-apple-darwin
- GitHub Check: Build Default aarch64-apple-darwin
- GitHub Check: Build Default aarch64-unknown-linux-gnu
- GitHub Check: Build Kafka x86_64-unknown-linux-gnu
- GitHub Check: Quest Smoke and Load Tests for Distributed deployments
- GitHub Check: Quest Smoke and Load Tests for Standalone deployments
🔇 Additional comments (3)
src/parseable/streams.rs (2)
743-758
: Well-implemented locking mechanism to prevent contention.The implementation properly acquires an exclusive write lock before checking if the stream exists, providing thread safety. If the stream exists, it returns a clone of the existing stream; otherwise, it creates a new one.
1196-1303
: Great test coverage for the new functionality.The unit tests thoroughly verify the behavior of the
get_or_create
method, covering:
- Returning existing streams
- Creating new streams when they don't exist
- Handling concurrent access with multiple threads
This comprehensive test suite helps ensure the implementation is robust and correctly addresses the contention issue.
src/metadata.rs (1)
77-77
: Good addition of the Clone trait to support the new functionality.Adding the
Clone
trait toLogStreamMetadata
is necessary to support theget_or_create
method's ability to return a clone of an existing stream. This change aligns well with the PR's goal of preventing data loss from contention.
@coderabbitai the nitpick is pointing to a typo that was already fixed in a previous commit. |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed:
Length of output: 150 🏁 Script executed:
Length of output: 16064 🏁 Script executed:
Length of output: 134 🏁 Script executed:
Length of output: 817 🏁 Script executed:
Length of output: 249 🏁 Script executed:
Length of output: 22146 @de-sh I apologize for the confusion. You're absolutely right - my nitpick about the "excluse" vs "exclusive" typo in the documentation comment was already fixed in your "doc: fix typo" commit before I made my review comment. I should have been more careful to review the latest version of the code instead of commenting on an outdated version. Thank you for pointing this out. I'll be more diligent about checking the latest commits before making review comments in the future. |
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.
good to merge
Fixes #XXXX.
Description
Ensure streams are not created in a contentious manner, which may lead to dataloss
Testing Methodology
/api/vi/ingest
onlyThis PR has:
Summary by CodeRabbit
Summary by CodeRabbit
Refactor
New Features
LogStreamMetadata
instances, allowing for easier management of stream metadata.