Skip to content

[ENH] When the log offset is behind sysdb, this can repair it safely. #4722

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

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

Conversation

rescrv
Copy link
Contributor

@rescrv rescrv commented Jun 3, 2025

Description of changes

This adds a tool to make the log offset match sysdb. Then a test to make sure it cannot move things
backwards breaking invariants.

Test plan

Added a test.

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

Documentation Changes

N/A

Copy link

github-actions bot commented Jun 3, 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)

Copy link
Contributor

propel-code-bot bot commented Jun 3, 2025

Enable Safe Repair of Log Offset to System Database State

This PR adds tooling and backend changes to safely synchronize a collection's log offset with the system database (sysdb) if it has fallen behind, preventing illegal backward movement of the offset. The changes span proto, Rust, and Go domains, including a new Rust tool for repair, a strong server-side test for log invariants, and sysdb interface updates to surface required information.

Key Changes:
• Introduced a standalone Rust tool (bin/chroma-update-collection-log-offset.rs) to synchronize log offset from sysdb for a collection.
• Added a comprehensive Rust test (update_collection_log_offset_never_moves_backwards) ensuring log offsets cannot be moved backward, maintaining WAL invariants.
• Updated sysdb proto (CheckCollectionsResponse) and Go backend to provide log positions alongside deleted status for collections.
• Refactored Go coordinator, service, and catalog layers to wire log_position into the sysdb API and through to check responses.

Affected Areas:
• Rust log-service (tests, CLI tool)
• Go sysdb coordinator, service, and proto
• IDL (Proto file, coordinator.proto)

Potential Impact:

Functionality: Users and operators can now repair a collection's log offset in case of desynchronization, with safeguards to prevent violating offset monotonicity.

Performance: Negligible impact; the repair tool and proto expansion add minimal runtime complexity.

Security: No new externally-exposed vectors; repair tool assumes trusted access and sysdb/reflection pairing.

Scalability: Neutral-changes make operations safer, even at large scale, but fundamentally do not alter scaling characteristics.

Review Focus:
• Correctness of monotonicity enforcement during log offset updates in Rust service and associated test coverage.
• Go sysdb and proto contract-ensure all usages of CheckCollections and new log_position semantics are consistently applied.
• Backward compatibility with systems/components that previously expected CheckCollectionsResponse to include only deleted status.
• CLI usability and error reporting in chroma-update-collection-log-offset tool.

Testing Needed

• Manual invocation of the new chroma-update-collection-log-offset tool against intentionally skewed log/sysdb states.
• Run the supplied Rust test suite to check log offset update invariants.
• Verify interoperability after proto/grpc changes between Go sysdb and Rust log service.

Code Quality Assessment

rust/log-service/src/lib.rs: Added a well-structured async test ensuring strict invariants. Change is sound and idiomatic.

rust/log-service/src/bin/chroma-update-collection-log-offset.rs: Tool is concise, idiomatic, and includes clear error-handling.

go/pkg/sysdb/coordinator/table_catalog.go: Refactor maintains style and handles new log_position output safely.

go/pkg/sysdb/grpc/collection_service.go: Proto method changes are correctly propagated; code is still readable.

go/pkg/sysdb/coordinator/coordinator.go: Simple function signature update; transparent change.

idl/chromadb/proto/coordinator.proto: Proto update is minimal, clear, backward compatible as long as clients properly ignore unknown fields.

Best Practices

Testing:
• Regression and invariant unit tests provided for critical mutation path.

Backward Compatibility:
• Proto changes are additive; but recommend confirming client behaviors.

Validation:
• Input argument and state validation in CLI tool
• Comprehensive assertion-based testing for core invariants

Potential Issues

• External consumers of CheckCollectionsResponse may break if they don't ignore the new log_position field; confirm downstream compatibility.
• CLI repair tool requires precise host arguments and is not self-discovering-misuse could go quietly unnoticed without clear logs.
• If sysdb and log service are at incompatible schema or versions during rolling upgrades, log offset repair may fail or behave unexpectedly.

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

@rescrv rescrv closed this Jun 6, 2025
@rescrv rescrv deleted the rescrv/utility-to-update-sysdb branch June 6, 2025 17:20
@rescrv rescrv restored the rescrv/utility-to-update-sysdb branch June 6, 2025 17:21
@rescrv rescrv reopened this Jun 6, 2025
@rescrv rescrv force-pushed the rescrv/utility-to-update-sysdb branch from d382541 to dddd899 Compare June 9, 2025 15:27
@rescrv rescrv requested a review from Sicheng-Pan June 9, 2025 19:42
std::process::exit(13);
}
if collection_info.deleted[0] {
eprintln!("cowardly refusing to do anything with a deleted database");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "deleted collection"?

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