fix: poison lock, use parking_lot#1651
Conversation
parking_lot in - Stream metadata - Stream writer - Streams struct
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR migrates lock primitives from ChangesLock Poisoning Removal via parking_lot Migration
Sequence DiagramNo sequence diagram generated; this PR is a lock API migration and error-handling cleanup without new multi-component sequential interactions. Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/parseable/streams.rs (1)
1924-1924:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winFix test compilation: remove
.expect()fromparking_lot::RwLock::read()/write()guards
parking_lot::RwLock::read()andwrite()return guard types directly (e.g.,RwLockReadGuard), notResult, so calling.expect(...)on them is a type error. Update these test lines: 1924, 1937, 1960, 2007.🐛 Proposed fix
@@ -1921,7 +1921,7 @@ fn get_or_create_returns_existing_stream() { assert!(Arc::ptr_eq(&stream1, &stream2)); // Verify the map contains only one entry - let guard = streams.read().expect("Failed to acquire read lock"); + let guard = streams.read(); assert_eq!(guard.len(), 1); } @@ -1934,7 +1934,7 @@ fn create_and_return_new_stream_when_name_does_not_exist() { let ingestor_id = Some("new_ingestor".to_owned()); // Assert the stream doesn't exist already - let mut guard = streams.write().expect("Failed to acquire read lock"); + let mut guard = streams.write(); assert_eq!(guard.len(), 0); @@ -1957,7 +1957,7 @@ fn create_and_return_new_stream_when_name_does_not_exist() { assert_eq!(stream.ingestor_id, ingestor_id); // Assert that the stream is created - let guard = streams.read().expect("Failed to acquire read lock"); + let guard = streams.read(); assert_eq!(guard.len(), 1); @@ -2004,7 +2004,7 @@ fn get_or_create_stream_concurrently() { assert!(Arc::ptr_eq(&stream1, &stream2)); // Verify the map contains only one entry - let guard = streams.read().expect("Failed to acquire read lock"); + let guard = streams.read(); assert_eq!(guard.len(), 1); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/parseable/streams.rs` at line 1924, The tests call parking_lot::RwLock::read()/write() and then call .expect(...) even though those methods return guard types (RwLockReadGuard/RwLockWriteGuard) directly, causing a type error; remove the .expect(...) calls and assign the guard directly (e.g., let guard = streams.read(); and similarly for streams.write()) wherever you see streams.read().expect(...) or streams.write().expect(...), ensuring the rest of the test uses the guard value as before.
🧹 Nitpick comments (1)
src/parseable/streams.rs (1)
1323-1330: 💤 Low valueRemove commented-out dead code.
The commented line at line 1329 is leftover from previous refactoring and should be removed.
🧹 Suggested cleanup
pub fn delete(&self, stream_name: &str, tenant_id: &Option<String>) { let tenant_id = tenant_id.as_deref().unwrap_or(DEFAULT_TENANT); let mut guard = self.write(); if let Some(tenant_streams) = guard.get_mut(tenant_id) { tenant_streams.remove(stream_name); } - // self.write().remove(stream_name); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/parseable/streams.rs` around lines 1323 - 1330, In the delete method, remove the dead commented-out line "// self.write().remove(stream_name);"—keep the existing implementation that resolves tenant_id via DEFAULT_TENANT, acquires the write lock via self.write(), and removes the stream from tenant_streams; simply delete the leftover commented code to clean up the function.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/parseable/streams.rs`:
- Line 1924: The tests call parking_lot::RwLock::read()/write() and then call
.expect(...) even though those methods return guard types
(RwLockReadGuard/RwLockWriteGuard) directly, causing a type error; remove the
.expect(...) calls and assign the guard directly (e.g., let guard =
streams.read(); and similarly for streams.write()) wherever you see
streams.read().expect(...) or streams.write().expect(...), ensuring the rest of
the test uses the guard value as before.
---
Nitpick comments:
In `@src/parseable/streams.rs`:
- Around line 1323-1330: In the delete method, remove the dead commented-out
line "// self.write().remove(stream_name);"—keep the existing implementation
that resolves tenant_id via DEFAULT_TENANT, acquires the write lock via
self.write(), and removes the stream from tenant_streams; simply delete the
leftover commented code to clean up the function.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 45c5ecbe-ca5d-4790-9675-7ac1ef5ccdac
📒 Files selected for processing (8)
src/event/mod.rssrc/handlers/http/logstream.rssrc/handlers/http/modal/mod.rssrc/parseable/mod.rssrc/parseable/staging/mod.rssrc/parseable/streams.rssrc/prism/logstream/mod.rssrc/rbac/map.rs
💤 Files with no reviewable changes (2)
- src/parseable/staging/mod.rs
- src/rbac/map.rs
parking_lot in
Summary by CodeRabbit