Crash in aptly db recover#1565
Open
muresan wants to merge 1 commit intoaptly-dev:masterfrom
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1565 +/- ##
==========================================
- Coverage 77.22% 76.89% -0.34%
==========================================
Files 161 161
Lines 15080 15082 +2
==========================================
- Hits 11646 11597 -49
- Misses 2291 2344 +53
+ Partials 1143 1141 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes crash in
aptly db recoverCrash
Notes:
After an aptly pod was killed during a publish, it would not start back up and crash with:
I've ran this through Claude which generated the current PR, and the reasoning:
Now I have a complete picture of the bug. Here's the full cause chain:
Root cause — LoadComplete in deb/local.go:172-173
When a repo has no ref key in the DB (empty repo or corrupted key), LoadComplete returns nil without touching repo.packageRefs, leaving it as its zero value: nil.
Propagation — checkRepo in cmd/db_recover.go:63
Crash — ForEach in deb/reflist.go:83
There are two good places to fix this:
Fix 1 (root cause) — initialize packageRefs before the early return in LoadComplete:
Fix 2 (defensive) — nil guard in ForEach:
I'd recommend both: Fix 1 is the correct semantic fix (an unfound ref key means an empty list, not a missing list), and Fix 2 makes ForEach safe to call on nil receivers as defensive programming, since PackageRefList is used widely throughout the codebase.
Requirements
All new code should be covered with tests, documentation should be updated. CI should pass.
Also, to speed up things, if you could kindly "Allow edits and access to secrets by maintainers" in the
PR settings, as this allows us to rebase the PR on master, fix conflicts, run coverage and help with
implementing code and tests.
Description of the Change
Checklist
AUTHORS