Skip to content

Conversation

@codetheweb
Copy link
Contributor

@codetheweb codetheweb commented Jun 19, 2025

Description of changes

The GC orchestrator has two fields it uses to track pending tasks: pending_list_files_at_version_tasks and pending_mark_versions_at_sysdb_tasks. All of these tasks must complete before the logic inside advance_after_list_files_and_mark_version_tasks_complete() runs at which point GC proceeds to delete the enumerated files (DeleteUnusedFiles) and then subsequently delete the marked versions from the SysDb (DeleteVersionsAtSysDb).

Prior to this change, the MarkVersionsAtSysDb tasks spawned when GC'ing soft-deleted collections were not tracked in pending_mark_versions_at_sysdb_tasks. This caused pending_list_files_at_version_tasks to run more than once, which in turn resulted in DeleteUnusedFiles and DeleteVersionsAtSysDb tasks running more than once. Both are safe to run multiple times so this is not a correctness issue. However, running DeleteUnusedFiles multiple times causes a slight performance hit and DeleteVersionsAtSysDb will error if run more than once.

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 section?

n/a

@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)

@codetheweb codetheweb marked this pull request as ready for review June 19, 2025 19:53
@propel-code-bot
Copy link
Contributor

This PR corrects the logic in the garbage collector orchestrator to ensure that MarkVersionsAtSysDb tasks for soft-deleted collections are correctly tracked in pending_mark_versions_at_sysdb_tasks. This prevents duplicate invocation of DeleteUnusedFiles and DeleteVersionsAtSysDb tasks, which previously led to unnecessary repeated execution and potential errors when attempting to delete already-deleted versions.

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

@codetheweb codetheweb requested a review from Sicheng-Pan June 19, 2025 19:54
@codetheweb codetheweb merged commit a753117 into main Jun 19, 2025
58 checks passed
@codetheweb codetheweb deleted the fix-gc-duplicate-task branch June 19, 2025 20:02
Inventrohyder pushed a commit to Inventrohyder/chroma that referenced this pull request Aug 5, 2025
…llections (chroma-core#4892)

## Description of changes

The GC orchestrator has two fields it uses to track pending tasks:
`pending_list_files_at_version_tasks` and
`pending_mark_versions_at_sysdb_tasks`. All of these tasks must complete
before the logic inside
`advance_after_list_files_and_mark_version_tasks_complete()` runs at
which point GC proceeds to delete the enumerated files
(`DeleteUnusedFiles`) and then subsequently delete the marked versions
from the SysDb (`DeleteVersionsAtSysDb`).

Prior to this change, the `MarkVersionsAtSysDb` tasks spawned when
GC'ing soft-deleted collections were not tracked in
`pending_mark_versions_at_sysdb_tasks`. This caused
`pending_list_files_at_version_tasks` to run more than once, which in
turn resulted in `DeleteUnusedFiles` and `DeleteVersionsAtSysDb` tasks
running more than once. Both are safe to run multiple times so this is
not a correctness issue. However, running `DeleteUnusedFiles` multiple
times causes a slight performance hit and `DeleteVersionsAtSysDb` will
error if run more than once.

## Test plan

_How are these changes tested?_

- [x] 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
section](https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com)?_

n/a
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.

3 participants