Skip to content

[CHORE]: Better error logging for rebuilds#6848

Open
tanujnay112 wants to merge 1 commit intomainfrom
rebuild_error_fix
Open

[CHORE]: Better error logging for rebuilds#6848
tanujnay112 wants to merge 1 commit intomainfrom
rebuild_error_fix

Conversation

@tanujnay112
Copy link
Copy Markdown
Contributor

@tanujnay112 tanujnay112 commented Apr 8, 2026

Description of changes

Edited the rebuild flow to explicitly log upon failure.

  • Improvements & Bug fixes
    • ...
  • New functionality
    • ...

Test plan

Local testing.

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

Copy link
Copy Markdown
Contributor Author

tanujnay112 commented Apr 8, 2026

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@tanujnay112 tanujnay112 marked this pull request as ready for review April 8, 2026 20:02
@tanujnay112 tanujnay112 marked this pull request as draft April 8, 2026 20:02
@tanujnay112 tanujnay112 marked this pull request as ready for review April 8, 2026 20:02
@propel-code-bot
Copy link
Copy Markdown
Contributor

propel-code-bot bot commented Apr 8, 2026

Improve rebuild_batch logging for collection fetch and per-collection rebuild outcomes

This PR updates rebuild observability in rust/worker/src/compactor/compaction_manager.rs by improving error context when sysdb collection lookup fails and by adding explicit per-collection success/failure logs after rebuild futures complete. It also renames the temporary futures result binding from let _ to let results to consume and report outcomes.

The change is narrowly scoped to logging behavior in the rebuild path, with no API or schema changes. However, the new result-to-collection association currently relies on zip between results and collections, which can misattribute logs due to filtered entries and unordered completion from FuturesUnordered.

This summary was automatically generated by @propel-code-bot

Copy link
Copy Markdown
Contributor

@propel-code-bot propel-code-bot bot left a comment

Choose a reason for hiding this comment

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

Changes suggested due to an important logic flaw where async result ordering causes incorrect collection-to-result logging associations.

Status: Changes Suggested | Risk: Medium

Issues Identified & Suggestions
  • Async result-to-collection pairing is unreliable; avoid positional zip mapping: rust/worker/src/compactor/compaction_manager.rs
  • filter_map and FuturesUnordered can reorder/misalign results; carry collection ID through futures: rust/worker/src/compactor/compaction_manager.rs
Review Details

📁 1 files reviewed | 💬 1 comments

👍 / 👎 individual comments to help improve reviews for you

.await;

// Log results
for (result, collection) in results.into_iter().zip(collections.iter()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

[Logic] There are actually two bugs causing the zip pairing between results and collections to be incorrect:

  1. filter_map misalignment: If any collection has an invalid DatabaseName, it's filtered out, making results shorter than collections. The Nth result will then be logged as belonging to the wrong collection.

  2. FuturesUnordered ordering (even more critical): FuturesUnordered yields results in arbitrary completion order — whichever future finishes first, not insertion order. So even if every collection has a valid database name, results will be in a random order that doesn't match collections, and zip will mis-pair them virtually every time there are 2+ concurrent rebuilds.

The fix is to carry the collection reference through the future chain so each result is self-describing, rather than relying on positional alignment:

let results = collections
    .iter()
    .filter_map(|collection| {
        match chroma_types::DatabaseName::new(collection.database.clone()) {
            Some(database_name) => Some((
                collection,
                self.context.clone().compact(
                    collection.collection_id,
                    database_name,
                    collection.tenant.clone(),
                    true,
                    segment_scopes.clone(),
                ),
            )),
            None => {
                tracing::error!(
                    "Invalid database name '{}' for collection {} (must be at least 3 characters)",
                    collection.database,
                    collection.collection_id
                );
                None
            }
        }
    })
    .map(|(collection, fut)| async move { (collection.collection_id, fut.await) })
    .collect::<FuturesUnordered<_>>()
    .collect::<Vec<_>>()
    .await;

Then log using the collection_id embedded in each tuple, removing the zip entirely.

Context for Agents
There are actually **two** bugs causing the `zip` pairing between `results` and `collections` to be incorrect:

1. **`filter_map` misalignment**: If any collection has an invalid `DatabaseName`, it's filtered out, making `results` shorter than `collections`. The Nth result will then be logged as belonging to the wrong collection.

2. **`FuturesUnordered` ordering** (even more critical): `FuturesUnordered` yields results in arbitrary completion order — whichever future finishes first, not insertion order. So even if every collection has a valid database name, `results` will be in a random order that doesn't match `collections`, and `zip` will mis-pair them virtually every time there are 2+ concurrent rebuilds.

The fix is to carry the collection reference through the future chain so each result is self-describing, rather than relying on positional alignment:

```rust
let results = collections
    .iter()
    .filter_map(|collection| {
        match chroma_types::DatabaseName::new(collection.database.clone()) {
            Some(database_name) => Some((
                collection,
                self.context.clone().compact(
                    collection.collection_id,
                    database_name,
                    collection.tenant.clone(),
                    true,
                    segment_scopes.clone(),
                ),
            )),
            None => {
                tracing::error!(
                    "Invalid database name '{}' for collection {} (must be at least 3 characters)",
                    collection.database,
                    collection.collection_id
                );
                None
            }
        }
    })
    .map(|(collection, fut)| async move { (collection.collection_id, fut.await) })
    .collect::<FuturesUnordered<_>>()
    .collect::<Vec<_>>()
    .await;
```
Then log using the `collection_id` embedded in each tuple, removing the `zip` entirely.

File: rust/worker/src/compactor/compaction_manager.rs
Line: 304

Copy link
Copy Markdown
Contributor

@propel-code-bot propel-code-bot bot left a comment

Choose a reason for hiding this comment

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

Review found no issues; the error-logging improvement appears safe and straightforward.

Status: No Issues Found | Risk: Low

Review Details

📁 1 files reviewed | 💬 0 comments

Copy link
Copy Markdown
Contributor Author

tanujnay112 commented Apr 9, 2026

Merge activity

  • Apr 9, 12:42 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 9, 12:44 AM UTC: Graphite rebased this pull request as part of a merge.

@tanujnay112 tanujnay112 changed the base branch from config_sharding to graphite-base/6848 April 9, 2026 00:42
@tanujnay112 tanujnay112 changed the base branch from graphite-base/6848 to main April 9, 2026 00:42
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