Skip to content

Conversation

@tanujnay112
Copy link
Contributor

@tanujnay112 tanujnay112 commented Oct 30, 2025

Description of changes

This change introduces garbage collection for soft deleted attached functions.

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

Test plan

How are these changes tested?

  • 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?_

@github-actions
Copy link

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)

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@tanujnay112 tanujnay112 force-pushed the functions_gc branch 2 times, most recently from 3e8363c to d996d65 Compare October 30, 2025 09:05
@tanujnay112 tanujnay112 marked this pull request as ready for review October 30, 2025 09:06
@tanujnay112 tanujnay112 requested a review from rescrv October 30, 2025 09:06
@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Oct 30, 2025

Background Garbage-Collector Pipeline for Soft-Deleted Attached Functions

This PR wires up an end-to-end garbage-collection workflow that permanently removes “attached functions” after they have been soft-deleted. The change introduces a Rust-based GC worker, new SysDB task orchestration plumbing, configuration knobs for retention/batching, and updates the front-end to soft-delete instead of immediately hard-deleting. The goal is to keep the reversible-delete safety net while guaranteeing eventual storage reclamation and lower operational cost. Roll-out is non-breaking but requires a small DB migration for the new task kind and the addition of a GC configuration block.

Key Changes

• New Rust garbage_collector_component.rs that scans for AttachedFunctions with deleted=true beyond a configurable grace period and issues hard deletes in batches.
• Adds GC-specific settings (retention_window, batch_size, polling_interval) to config.rs and ships a reference garbage_collector_config.yaml.
• Extends SysDB task orchestration (Go) with an AttachedFunctionDelete task type; DAO, models, GRPC TaskService and related tests/mocks updated.
• Updates coordinator.proto and generated code to expose the new task kind.
• SysDB (Rust) exposes helpers to enumerate and remove soft-deleted AttachedFunctions for reuse by the collector.
• service_based_frontend.rs now performs a soft delete, delegating hard deletion to the GC job.
• Metric/log hooks added so the new GC reuses existing observability dashboards.

Affected Areas

• Rust GC worker (src/garbage_collector_component.rs)
• Configuration files and parsing (config.rs, garbage_collector_config.yaml)
• SysDB Go task DAO/model/service layer
• coordinator.proto & generated GRPC stubs
• SysDB Rust helpers
• Front-end service deletion flow
• Database schema (new task_kind enum value)
• CI/tests touching task creation and deletion

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

Comment on lines 418 to 428
for attached_function_id in attached_functions_to_delete {
match self
.sysdb_client
.finish_attached_function_deletion(attached_function_id)
.await
{
Copy link
Contributor

Choose a reason for hiding this comment

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

1+n problem. Perhaps we make finish_attached_function_deletion take a list of function ids?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Following the pattern of collection deletion. It seems like the deletions for those weren't batched as it's easier to debug.

Comment on lines +1978 to +1981
DetachFunctionError::Internal(Box::new(chroma_error::TonicError(
tonic::Status::unimplemented("Not implemented"),
)))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

It's good that you're handling the NotImplemented error case. However, returning a generic tonic::Status::unimplemented("Not implemented") might be a bit opaque for clients. It would be more informative to specify which backend is missing the implementation, which can aid in debugging, especially in environments where different backends might be in use.

Consider making the error message more specific.

Context for Agents
[**BestPractice**]

It's good that you're handling the `NotImplemented` error case. However, returning a generic `tonic::Status::unimplemented("Not implemented")` might be a bit opaque for clients. It would be more informative to specify which backend is missing the implementation, which can aid in debugging, especially in environments where different backends might be in use.

Consider making the error message more specific.

File: rust/frontend/src/impls/service_based_frontend.rs
Line: 1981

Comment on lines +2293 to +2297
impl ChromaError for GetSoftDeletedAttachedFunctionsError {
fn code(&self) -> ErrorCodes {
ErrorCodes::Internal
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

To improve error handling consistency, the ChromaError implementation for GetSoftDeletedAttachedFunctionsError should propagate the underlying gRPC status code instead of always returning Internal. This follows the standard tonic pattern for error propagation and provides more specific error information to upstream callers.

Suggested Change
Suggested change
impl ChromaError for GetSoftDeletedAttachedFunctionsError {
fn code(&self) -> ErrorCodes {
ErrorCodes::Internal
}
}
impl ChromaError for GetSoftDeletedAttachedFunctionsError {
fn code(&self) -> ErrorCodes {
match self {
GetSoftDeletedAttachedFunctionsError::FailedToGetSoftDeletedAttachedFunctions(e) => {
e.code().into()
}
GetSoftDeletedAttachedFunctionsError::ServerReturnedInvalidData => ErrorCodes::Internal,
GetSoftDeletedAttachedFunctionsError::NotImplemented => ErrorCodes::Internal,
}
}
}

Committable suggestion

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Context for Agents
[**BestPractice**]

To improve error handling consistency, the `ChromaError` implementation for `GetSoftDeletedAttachedFunctionsError` should propagate the underlying gRPC status code instead of always returning `Internal`. This follows the standard tonic pattern for error propagation and provides more specific error information to upstream callers.

<details>
<summary>Suggested Change</summary>

```suggestion
impl ChromaError for GetSoftDeletedAttachedFunctionsError {
    fn code(&self) -> ErrorCodes {
        match self {
            GetSoftDeletedAttachedFunctionsError::FailedToGetSoftDeletedAttachedFunctions(e) => {
                e.code().into()
            }
            GetSoftDeletedAttachedFunctionsError::ServerReturnedInvalidData => ErrorCodes::Internal,
            GetSoftDeletedAttachedFunctionsError::NotImplemented => ErrorCodes::Internal,
        }
    }
}
```

⚡ **Committable suggestion**

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

</details>

File: rust/sysdb/src/sysdb.rs
Line: 2297

Comment on lines +2307 to +2311
impl ChromaError for FinishAttachedFunctionDeletionError {
fn code(&self) -> ErrorCodes {
ErrorCodes::Internal
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

Similar to other error types in this file, the ChromaError implementation for FinishAttachedFunctionDeletionError should propagate the gRPC status code from the tonic::Status to provide more detailed error information. This follows the standard tonic error handling pattern.

Suggested Change
Suggested change
impl ChromaError for FinishAttachedFunctionDeletionError {
fn code(&self) -> ErrorCodes {
ErrorCodes::Internal
}
}
impl ChromaError for FinishAttachedFunctionDeletionError {
fn code(&self) -> ErrorCodes {
match self {
FinishAttachedFunctionDeletionError::FailedToFinishDeletion(e) => e.code().into(),
FinishAttachedFunctionDeletionError::NotImplemented => ErrorCodes::Internal,
}
}
}

Committable suggestion

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Context for Agents
[**BestPractice**]

Similar to other error types in this file, the `ChromaError` implementation for `FinishAttachedFunctionDeletionError` should propagate the gRPC status code from the `tonic::Status` to provide more detailed error information. This follows the standard tonic error handling pattern.

<details>
<summary>Suggested Change</summary>

```suggestion
impl ChromaError for FinishAttachedFunctionDeletionError {
    fn code(&self) -> ErrorCodes {
        match self {
            FinishAttachedFunctionDeletionError::FailedToFinishDeletion(e) => e.code().into(),
            FinishAttachedFunctionDeletionError::NotImplemented => ErrorCodes::Internal,
        }
    }
}
```

⚡ **Committable suggestion**

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

</details>

File: rust/sysdb/src/sysdb.rs
Line: 2311

@tanujnay112 tanujnay112 enabled auto-merge (squash) October 31, 2025 20:21
@tanujnay112 tanujnay112 disabled auto-merge October 31, 2025 20:35
Copy link
Contributor

@codetheweb codetheweb left a comment

Choose a reason for hiding this comment

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

my main question is whether we should be hard deleting functions prior to executing collection GC
should we hard delete functions per collection instead to match the existing pattern?

Copy link
Contributor Author

Functions could be deleted for undeleted collections. Also in the future, it could be possible to have multiple input collections for a function. I guess one thing to consider is maybe disabling a function if one of its input collections is deleted but that could also be detected when the function attempts to run.

@tanujnay112 tanujnay112 merged commit 3b6dcb4 into main Nov 5, 2025
62 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.

4 participants