Repository navigation
feat(cache): convert NarInfo/NarFile delete paths to Ent - #1201
Conversation
e5d9040 to
435ce97
Compare
e9c62db to
b49741f
Compare
435ce97 to
e73fdb1
Compare
b49741f to
b5e2e6c
Compare
e73fdb1 to
ff60258
Compare
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughTwo deletion code paths in the cache package migrate from legacy ChangesNarInfo Deletion Ent Migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
b5e2e6c to
fc295e1
Compare
ff60258 to
65ea5a4
Compare
fc295e1 to
96e4a3d
Compare
65ea5a4 to
e4ebb15
Compare
96e4a3d to
ab5cee7
Compare
e4ebb15 to
71fda8d
Compare
ab5cee7 to
0604b80
Compare
71fda8d to
32d47d0
Compare
0604b80 to
a326646
Compare
32d47d0 to
bf73661
Compare
a326646 to
088f9bb
Compare
bf73661 to
44acb3d
Compare
§11.3 partial. The simple delete sites in pkg/cache convert cleanly without the UPSERT cascade that storeInDatabase will need; landing them in a separate commit keeps each diff reviewable. Converted: - `deleteNarInfoFromStore` (line 4778): `c.db.DeleteNarInfoByHash` → `c.dbClient.Ent().NarInfo.Delete().Where(HashEQ(hash)).Exec(ctx)`. - `purgeNarInfo` (line 4076): switched the wrapper from `c.withTransaction(... qtx ...)` to `c.withEntTransaction(... tx *ent.Tx ...)`. The two inside-tx deletes (NarInfo + NarFile) become Ent Delete builders with the same predicates the sqlc query used (hash for NarInfo; hash + compression + query for NarFile). Behaviour preservation: - The cascading deletes the comment notes (references, signatures, narinfo_nar_files links) are still handled by the database-level ON DELETE CASCADE the §8 bridge migration set up. Ent's Delete builder doesn't need to do anything beyond DELETE FROM narinfos WHERE hash = ?. Deferred to follow-up commits in §11.3: - `storeInDatabase` and the second PutNarInfo helper (line 4631) — both do a conditional UPSERT (`ON CONFLICT (hash) DO UPDATE ... WHERE url IS NULL`) plus bulk reference / signature inserts plus a NarFile UPSERT plus a NarFile<->NarInfo link. Substantial; their own commit. - `DeleteNarInfoByID` inside the LRU eviction loop (line 5535) — sits in a larger withTransaction block whose surrounding qtx calls belong to §11.5 (orphan cleanup). Leaving it qtx-style until that whole block converts as a unit. `go test -race ./pkg/cache/...` passes against SQLite + Postgres + MySQL + Redis. Lint clean.
44acb3d to
2cfb023
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1201 +/- ##
=====================================
Coverage 5.68% 5.68%
=====================================
Files 6 6
Lines 387 387
=====================================
Hits 22 22
Misses 361 361
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
§11.3 partial. The simple delete sites in pkg/cache convert
cleanly without the UPSERT cascade that storeInDatabase
will need; landing them in a separate commit keeps each diff
reviewable.
Converted:
deleteNarInfoFromStore(line 4778):c.db.DeleteNarInfoByHash→c.dbClient.Ent().NarInfo.Delete().Where(HashEQ(hash)).Exec(ctx).purgeNarInfo(line 4076):switched the wrapper from
c.withTransaction(... qtx ...)to
c.withEntTransaction(... tx *ent.Tx ...). The twoinside-tx deletes (NarInfo + NarFile) become Ent Delete
builders with the same predicates the sqlc query used
(hash for NarInfo; hash + compression + query for NarFile).
Behaviour preservation:
signatures, narinfo_nar_files links) are still handled by
the database-level ON DELETE CASCADE the §8 bridge
migration set up. Ent's Delete builder doesn't need to do
anything beyond DELETE FROM narinfos WHERE hash = ?.
Deferred to follow-up commits in §11.3:
storeInDatabaseand the second PutNarInfo helper (line4631) — both do a conditional UPSERT
(
ON CONFLICT (hash) DO UPDATE ... WHERE url IS NULL) plusbulk reference / signature inserts plus a NarFile UPSERT
plus a NarFile<->NarInfo link. Substantial; their own
commit.
DeleteNarInfoByIDinside the LRU eviction loop (line5535) — sits in a larger withTransaction block whose
surrounding qtx calls belong to §11.5 (orphan cleanup).
Leaving it qtx-style until that whole block converts as a
unit.
go test -race ./pkg/cache/...passes against SQLite + Postgres