Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves resilience by replacing lock-poisoning panics with recoverable errors (or logged warnings), and updates Rust + Python surfaces accordingly. It also standardizes import formatting to address compiler/linter warnings and modernize formatting config.
Changes:
- Replace several
expect("...lock poisoned")patterns withResult-based error propagation and/or logging incortexadb-core. - Make
CortexaDB::stats()(Rust) andCortexaDB.stats()(PyO3 wrapper) handle fallible stat retrieval, updating tests accordingly. - Update rustfmt configuration and refactor imports across multiple modules.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| rustfmt.toml | Switch to imports_granularity to replace deprecated import-merge setting. |
| crates/cortexadb-py/src/lib.rs | Update Python bindings for fallible stats + adjust exceptions/__repr__/__len__. |
| crates/cortexadb-core/tests/integration.rs | Update integration tests to handle fallible stats(). |
| crates/cortexadb-core/src/store.rs | Propagate lock poisoning via new error variant; make some methods fallible; adjust background threads. |
| crates/cortexadb-core/src/storage/wal.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/storage/segment.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/storage/compaction.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/storage/checkpoint.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/query/intent.rs | Replace lock-poison panics with warning logs + fallback behavior. |
| crates/cortexadb-core/src/query/hybrid.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/query/executor.rs | Replace lock-poison panics in cache handling with logging + best-effort behavior. |
| crates/cortexadb-core/src/index/vector.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/index/temporal.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/index/hnsw.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/index/graph.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/index/combined.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/facade.rs | Make stats() fallible; update internal tests accordingly. |
| crates/cortexadb-core/src/engine.rs | Add error variant + import organization / lint cleanup. |
| crates/cortexadb-core/src/core/state_machine.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/core/memory_entry.rs | Import organization / lint cleanup. |
| crates/cortexadb-core/src/core/command.rs | Import organization / lint cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+700
to
+704
| pub fn set_vector_backend_mode(&self, mode: VectorBackendMode) -> Result<()> { | ||
| let mut writer = writer_lock(&self.writer)?; | ||
| writer.indexes.set_vector_backend_mode(mode); | ||
| self.publish_snapshot_from_write_state(&writer); | ||
| Ok(()) |
Comment on lines
+856
to
+857
| pub fn wal_len(&self) -> Result<u64> { | ||
| Ok(writer_lock(&self.writer)?.engine.wal_len()) |
Comment on lines
498
to
+506
| /// Get database statistics. | ||
| pub fn stats(&self) -> Stats { | ||
| Stats { | ||
| pub fn stats(&self) -> Result<Stats> { | ||
| Ok(Stats { | ||
| entries: self.inner.state_machine().len(), | ||
| indexed_embeddings: self.inner.indexed_embeddings(), | ||
| wal_length: self.inner.wal_len(), | ||
| wal_length: self.inner.wal_len()?, | ||
| vector_dimension: self.inner.vector_dimension(), | ||
| storage_version: 1, | ||
| } | ||
| }) |
| if stats.entries > 0 && stats.vector_dimension != dimension { | ||
| return Err(CortexaDBConfigError::new_err(format!( | ||
| "dimension mismatch: database has dimension={}, but open() was called with dimension={}", | ||
| return Err(PyValueError::new_err(format!( |
Comment on lines
650
to
+651
| fn __len__(&self) -> usize { | ||
| self.inner.stats().entries | ||
| self.inner.stats().map(|s| s.entries).unwrap_or(0) |
Comment on lines
+34
to
+38
| if let Ok(mut guard) = policy_cell().write() { | ||
| *guard = policy; | ||
| crate::query::executor::clear_intent_anchor_cache(); | ||
| } else { | ||
| log::warn!("intent policy write lock poisoned"); |
Comment on lines
42
to
+48
| pub fn get_intent_policy() -> IntentPolicy { | ||
| policy_cell().read().expect("intent policy read lock poisoned").clone() | ||
| if let Ok(guard) = policy_cell().read() { | ||
| guard.clone() | ||
| } else { | ||
| log::warn!("intent policy read lock poisoned, falling back to default"); | ||
| IntentPolicy::default() | ||
| } |
Comment on lines
+448
to
453
| log::error!("cortexadb sync manager flush error (lock poisoned): {e}"); | ||
| continue; | ||
| } | ||
| }; | ||
| if let Err(err) = write_state.engine.flush_buffers() { | ||
| log::error!("cortexadb sync manager flush_buffers error: {err}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR focuses on improving system resilience, fixing build/compilation issues on modern Python versions, and addressing all compiler & linter warnings.
The most significant change is the removal of cascading panics during lock poisoning. Instead of crashing the entire application with .expect("lock poisoned") when a shared resource lock is compromised, the cortexadb-core engine now propagates these errors gracefully so they can be handled or recovered from.