Skip to content

Conversation

@julio-lopez
Copy link
Collaborator

Track and report errors separately according to the type of error:

  • missing pack
  • truncated pack
  • unreadable content.

Add a counter stat for the contents that are read and fully verified (via GetContent).
Count errors grouped by pack ID using a CountersMap. This allows determining the number of referenced contents that were missing in a particular pack.

Report the counter stats via structured logging.

Sample output

$ kopia content verify --progress-interval=0.5s --download-percent=100
Listing blobs...
Listed 102 blobs.
Verifying contents...
  Verified 1 contents, 0 errors, estimating...
  Verified 279 contents, 0 errors, estimating...
  Verified 512 of 624 contents (82.1%), 0 errors, remaining 0s, ETA 2025-09-17 23:03:38 PDT
Finished verifying contents
verifyCounters:	{"verifiedContents":624,"totalErrorCount":0,"contentsInMissingPacks":0,\
"contentsInTruncatedPacks":0,"unreadableContents":0,"readContents":624,\
"missingPacks":0,"truncatedPacks":0,"corruptedPacks":0}

It will be used to introduce additional stats to the
`content verify` CLI command.

The stats include number of missing or corrupted contents
grouped by pack blob ID.
@codecov
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.49%. Comparing base (cb455c6) to head (dd45a25).
⚠️ Report is 661 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4830      +/-   ##
==========================================
+ Coverage   75.86%   76.49%   +0.63%     
==========================================
  Files         470      532      +62     
  Lines       37301    40548    +3247     
==========================================
+ Hits        28299    31018    +2719     
- Misses       7071     7490     +419     
- Partials     1931     2040     +109     

☔ 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 marked this pull request as ready for review September 18, 2025 06:34
Copilot AI review requested due to automatic review settings September 18, 2025 06:34
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 extends content verification statistics to provide more granular error tracking and reporting. Instead of treating all errors equally, it now categorizes them by type (missing pack, truncated pack, unreadable content) and tracks per-pack error counts.

  • Replaces a single error counter with separate counters for different error types
  • Introduces CountersMap data structure for tracking per-pack error counts
  • Adds structured logging output with detailed verification statistics

Reviewed Changes

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

File Description
repo/content/verify.go Refactors error tracking to use separate counters and adds structured logging
internal/stats/count_map.go Implements thread-safe map for tracking counters by key
internal/stats/count_map_test.go Comprehensive test suite for the CountersMap implementation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

contentErrorCount := v.errorContentCount.Load()
totalErrorCount := contentInMissingPackCount + contentInTruncatedPackCount + contentErrorCount

contentCount := v.verifiedCount.Load()
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The variable contentCount should represent the total number of contents processed (both successful and failed), but it's assigned from v.verifiedCount.Load() which only counts verified contents. This should be v.successCount.Load() + totalErrorCount to match the original logic.

Suggested change
contentCount := v.verifiedCount.Load()
contentCount := v.successCount.Load() + totalErrorCount

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
// Length returns the approximate number of keys in the map. The actual number
// of keys can be equal or larger to the returned value, but not less.
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The comment states that the actual number can be 'equal or larger' but 'not less', which is unclear. The length could temporarily be larger than actual due to race conditions in concurrent operations. The comment should clarify that this is an approximation that may be slightly higher due to concurrent updates.

Suggested change
// Length returns the approximate number of keys in the map. The actual number
// of keys can be equal or larger to the returned value, but not less.
// Length returns the approximate number of keys in the map. Due to concurrent
// updates, the returned value may be slightly higher than the actual number of keys.
// The value is never less than the actual number, since keys are never removed.

Copilot uses AI. Check for mistakes.
@julio-lopez julio-lopez merged commit 490fa4b into kopia:master Sep 18, 2025
27 checks passed
@julio-lopez julio-lopez deleted the poc/enhance-content-verify branch September 18, 2025 06:36
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.

1 participant