Skip to content

Conversation

@Lyndon-Li
Copy link
Contributor

@Lyndon-Li Lyndon-Li commented Nov 3, 2025

Maintenance is critical for healthy of the repository.
On the other hand, Maintenance is complex, because it runs multiple sub tasks each may generate different results according to the maintenance policy. The results may include deleting/combining/adding data/metadata to the repository.

It is worthy to add more observability for these tasks for below reasons:

  • It is helpful for troubleshooting. Any data change to the repository is critical, the observability info helps to understand what happened during the maintenance and why that happened
  • It is helpful for users to understand/predict the repo's behavior. The repo data may be stored in a public cloud for which costs are sensitive to scale/duration of data stored. On the other hand, repository has its own policy to manage the data, so the data is not deleted until it is safe enough according to the policy. The observability info helps users to understand how much data is in-use, how much data is out of use and when it is deleted

There will be a serial of PRs to add observability info for each sub task.
The current PR add the stats info for CompactIndexesStats sub task.

@Lyndon-Li
Copy link
Contributor Author

This task performs quite differently for V0 and V1 format, and is much simpler for V1 format.
We could include more info in the stats for V0 format, but since V0 is legacy, I just ignored them and only include the info that is shared by V0 and V1.

Let me know if we want the stats to be more informative for V0 format.

@Lyndon-Li Lyndon-Li marked this pull request as ready for review November 3, 2025 09:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds observability statistics for the "drop deleted indexes" maintenance task by introducing a new DropDeletedIndexesStats struct. The changes enable tracking when deleted indexes are dropped from the repository, which helps with troubleshooting and understanding repository behavior over time.

Key changes:

  • Introduces DropDeletedIndexesStats struct to track when deleted indexes are dropped
  • Updates CompactIndexes method signature to return statistics instead of just an error
  • Adds comprehensive test coverage for the new statistics functionality

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
repo/maintenancestats/stats_compact_indexes.go New file defining the DropDeletedIndexesStats struct with JSON serialization and summary methods
repo/maintenancestats/builder.go Adds support for building DropDeletedIndexesStats from serialized data
repo/maintenancestats/builder_test.go Test cases for serialization/deserialization of the new stats type
repo/content/indexblob/index_blob.go Updates Manager interface to return stats from Compact method
repo/content/indexblob/index_blob_manager_v0.go Updates V0 manager implementation to return DropDeletedIndexesStats
repo/content/indexblob/index_blob_manager_v1.go Updates V1 manager implementation to return DropDeletedIndexesStats
repo/content/content_manager_indexes.go Updates CompactIndexes to handle the new return type
repo/maintenance/drop_deleted_contents.go Updates function signature to return stats
repo/maintenance/index_compaction.go Updates to handle new return type from CompactIndexes
repo/maintenance/maintenance_run.go Updates task runner to handle stats return value
cli/command_index_optimize.go Updates CLI command to handle new return type
repo/repository_test.go Updates test calls to handle new return signature
repo/content/content_manager_test.go Updates test calls to handle new return signature
tests/repository_stress_test/repository_stress_test.go Updates test calls to handle new return signature

@julio-lopez
Copy link
Collaborator

@julio-lopez
Copy link
Collaborator

but since V0 is legacy, I just ignored them and only include the info that is shared by V0 and V1.

That's OK. There is NO need to include details about the V0 implementation at the moment.

What is desirable is to clearly call out the 2 conceptually separate maintenance tasks.

@Lyndon-Li Lyndon-Li force-pushed the compact-index-stats branch 2 times, most recently from ec0df39 to f96c942 Compare November 4, 2025 07:48
@Lyndon-Li Lyndon-Li requested a review from julio-lopez November 4, 2025 07:50
@Lyndon-Li Lyndon-Li changed the title feat(general): add stats to maintenance run - DropDeletedIndexesStats feat(general): add stats to maintenance run - CompactIndexesStats Nov 4, 2025
@Lyndon-Li Lyndon-Li force-pushed the compact-index-stats branch from f96c942 to 1c3d221 Compare November 4, 2025 08:02
@julio-lopez julio-lopez requested a review from Copilot November 4, 2025 19:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 57.89474% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.96%. Comparing base (cb455c6) to head (1c3d221).
⚠️ Report is 729 commits behind head on master.

Files with missing lines Patch % Lines
repo/content/indexblob/index_blob_manager_v0.go 50.00% 9 Missing and 1 partial ⚠️
repo/content/content_manager_indexes.go 42.85% 3 Missing and 1 partial ⚠️
repo/content/indexblob/index_blob_manager_v1.go 60.00% 2 Missing and 2 partials ⚠️
repo/maintenancestats/stats_compact_indexes.go 50.00% 4 Missing ⚠️
internal/epoch/epoch_manager.go 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4948      +/-   ##
==========================================
+ Coverage   75.86%   77.96%   +2.09%     
==========================================
  Files         470      543      +73     
  Lines       37301    31333    -5968     
==========================================
- Hits        28299    24429    -3870     
+ Misses       7071     4856    -2215     
- Partials     1931     2048     +117     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@julio-lopez julio-lopez merged commit 83bd4d4 into kopia:master Nov 4, 2025
22 of 23 checks passed
@julio-lopez
Copy link
Collaborator

Thanks!

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