Skip to content
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

[ENH] Make SysDb return eligible collections to GC. #3916

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rohitcpbot
Copy link
Contributor

Limit the number of collections, and return
those that have at least 1 version that is
elligible for GC.

Description of changes

Summarize the changes made by this PR.

  • 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

Documentation Changes

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

Copy link

github-actions bot commented Mar 6, 2025

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)

// before this cutoff time.
// SysDb can apply additional logic to return the collections that should
// be prioritized for GC.
optional uint64 cutoff_time_secs = 1;
Copy link
Collaborator

@HammadB HammadB Mar 7, 2025

Choose a reason for hiding this comment

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

I think the sysdb should fail requests with a cutoff time of less than 30 mins from NOW() or similar as a backstop/defensive measure. Or cutoff times in the future etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats a good suggestion. Let me send a separate PR or make it part of another PR where i am doing some cleanup on the rust side.
Tracking it here - https://github.com/chroma-core/hosted-chroma/issues/1791

// be prioritized for GC.
optional uint64 cutoff_time_secs = 1;

// Limit the number of collections that can be returned.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you assuming one GC node is sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of limit is to make GC do smaller runs so that in case of midway crash it does not restart the whole thing again.

Assuming more than one node will be needed.
Either node can use limit (without any offset).
They will both get the same n collections. Will use rendezvous hash to determine if they should do it.
After a run to GC these n collections, it will request n more.
[We could choose to use same cutoff (preferred) or new cutoff in the next run. Still need to think through that.]

@@ -835,7 +835,10 @@ impl GrpcSysDb {
) -> Result<Vec<CollectionToGcInfo>, GetCollectionsToGcError> {
let res = self
.client
.list_collections_to_gc(chroma_proto::ListCollectionsToGcRequest {})
.list_collections_to_gc(chroma_proto::ListCollectionsToGcRequest {
cutoff_time_secs: None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we pipe these values through?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR does not contain the rust side changes. I only added this for the code to compile. Sending another PR for using these correctly on the rust side.

@@ -0,0 +1,2 @@
-- Modify "collections" table
ALTER TABLE "public"."collections" ADD COLUMN "num_versions" bigint NULL DEFAULT 0, ADD COLUMN "oldest_version_ts" timestamp NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: integer should suffice over bigint?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Limit the number of collections, and return
those that have at least 1 version that is
elligible for GC.
@rohitcpbot
Copy link
Contributor Author

@HammadB - removed the migration from this PR, and added test cases. Can add few more tests before merging.

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.

2 participants