Skip to content

Conversation

@Lyndon-Li
Copy link
Contributor

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 CompactSingleEpoch sub task.

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.00%. Comparing base (cb455c6) to head (f7aaa8c).
⚠️ Report is 725 commits behind head on master.

Files with missing lines Patch % Lines
...epo/maintenancestats/stats_compact_single_epoch.go 40.00% 6 Missing ⚠️
internal/epoch/epoch_manager.go 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4941      +/-   ##
==========================================
+ Coverage   75.86%   78.00%   +2.14%     
==========================================
  Files         470      542      +72     
  Lines       37301    31309    -5992     
==========================================
- Hits        28299    24424    -3875     
+ Misses       7071     4843    -2228     
- Partials     1931     2042     +111     

☔ 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 requested a review from Copilot November 3, 2025 04:17
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 CompactSingleEpoch maintenance task to help users understand repository behavior and troubleshoot maintenance operations. It introduces a new stats structure to track compaction metrics including blob count, size, and epoch information.

Key changes:

  • Creates a new CompactSingleEpochStats struct to capture compaction metrics
  • Updates the MaybeCompactSingleEpoch method to return statistics instead of just an error
  • Adds comprehensive test coverage for the new stats functionality

Reviewed Changes

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

Show a summary per file
File Description
repo/maintenancestats/stats_compact_single_epoch.go New stats struct with JSON serialization and human-readable summary methods
repo/maintenancestats/builder_test.go Test cases for stats serialization/deserialization
repo/maintenancestats/builder.go Adds support for the new stats type in the builder pattern
repo/maintenance/maintenance_run.go Updates maintenance runners to capture and handle returned stats
internal/epoch/epoch_manager_test.go Updates existing tests to handle new return signature and validate stats
internal/epoch/epoch_manager.go Core implementation changes to calculate and return compaction statistics

}

result.CurrentEpoch++
result.CurrentEpoch = cs.WriteEpoch + 1
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

This change appears unrelated to the CompactSingleEpoch stats feature. The original result.CurrentEpoch++ was incrementing from the current value, but now it's being set to cs.WriteEpoch + 1 which could produce different behavior. This change should either be reverted or moved to a separate PR with proper justification.

Suggested change
result.CurrentEpoch = cs.WriteEpoch + 1
result.CurrentEpoch++

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copilot's comment makes sense, it is orthogonal to the changes in this PR.
However, we'll merge it with this PR to avoid an additional roundtrip.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is irrelevant to the current changes. This is for the comment #4937 (comment) of another PR.

It should be included, but it would be better if it was in a separate PR. Will do it next time. And since the PR has been merged, we don't need to do any further thing.

Epoch: uncompacted,
}

contentlog.Log1(ctx, e.log, "starting single-epoch compaction for epoch", result)
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The logging call is passing result (a *CompactSingleEpochStats struct) as the log parameter, but the original code passed logparam.Int(\"uncompacted\", uncompacted). This will likely not log the epoch number properly. Consider changing to logparam.Int(\"uncompacted\", uncompacted) or implement a proper logging format for the stats struct.

Suggested change
contentlog.Log1(ctx, e.log, "starting single-epoch compaction for epoch", result)
contentlog.Log1(
ctx,
e.log,
"starting single-epoch compaction for epoch",
logparam.Int("epoch", result.Epoch),
logparam.Int("compactedBlobCount", result.CompactedBlobCount),
logparam.Int64("compactedBlobSize", result.CompactedBlobSize),
)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no information lose -- all the information has been included in result.

Copy link
Collaborator

@julio-lopez julio-lopez left a comment

Choose a reason for hiding this comment

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

Let's merge and iterate.
A followup PR will fix the field names.

@julio-lopez julio-lopez marked this pull request as ready for review November 3, 2025 04:37
@julio-lopez julio-lopez merged commit 29ee7b1 into kopia:master Nov 3, 2025
24 of 27 checks passed
@julio-lopez
Copy link
Collaborator

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