Repository navigation
refactor(cache): drop legacy withTransaction + executeTransaction; finish MigrateNarInfo Ent move - #1216
Merged
Conversation
This was referenced May 21, 2026
Owner
Author
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
…e-check After acquiring the migration lock, distinguish ent.IsNotFound (the expected "not yet migrated" case, fall through to migrate) from other DB errors (log at warn level instead of silently swallowing). The migration still attempts on any error so a transient lookup glitch doesn't block progress; if the DB is genuinely broken the upsert below will surface the failure. Addresses gemini-code-assist comment on PR #1216 (PRRT_kwDONV6tZs6D3YoD). Co-Authored-By: Claude Opus 4.7 <[email protected]>
kalbasit
force-pushed
the
feat-cache-lru-eviction-to-ent
branch
from
May 22, 2026 23:02
bb768f2 to
e37ab95
Compare
kalbasit
force-pushed
the
refactor-cache-drop-legacy-tx-helpers
branch
from
May 22, 2026 23:02
86d9c0f to
364285f
Compare
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
…e-check After acquiring the migration lock, distinguish ent.IsNotFound (the expected "not yet migrated" case, fall through to migrate) from other DB errors (log at warn level instead of silently swallowing). The migration still attempts on any error so a transient lookup glitch doesn't block progress; if the DB is genuinely broken the upsert below will surface the failure. Addresses gemini-code-assist comment on PR #1216 (PRRT_kwDONV6tZs6D3YoD). Co-Authored-By: Claude Opus 4.7 <[email protected]>
kalbasit
force-pushed
the
feat-cache-lru-eviction-to-ent
branch
from
May 22, 2026 23:16
e37ab95 to
194863b
Compare
kalbasit
force-pushed
the
refactor-cache-drop-legacy-tx-helpers
branch
from
May 22, 2026 23:16
364285f to
34adccd
Compare
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
…e-check After acquiring the migration lock, distinguish ent.IsNotFound (the expected "not yet migrated" case, fall through to migrate) from other DB errors (log at warn level instead of silently swallowing). The migration still attempts on any error so a transient lookup glitch doesn't block progress; if the DB is genuinely broken the upsert below will surface the failure. Addresses gemini-code-assist comment on PR #1216 (PRRT_kwDONV6tZs6D3YoD). Co-Authored-By: Claude Opus 4.7 <[email protected]>
kalbasit
force-pushed
the
feat-cache-lru-eviction-to-ent
branch
from
May 22, 2026 23:28
194863b to
1d43640
Compare
kalbasit
force-pushed
the
refactor-cache-drop-legacy-tx-helpers
branch
from
May 22, 2026 23:28
34adccd to
6c5decb
Compare
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
…e-check After acquiring the migration lock, distinguish ent.IsNotFound (the expected "not yet migrated" case, fall through to migrate) from other DB errors (log at warn level instead of silently swallowing). The migration still attempts on any error so a transient lookup glitch doesn't block progress; if the DB is genuinely broken the upsert below will surface the failure. Addresses gemini-code-assist comment on PR #1216 (PRRT_kwDONV6tZs6D3YoD). Co-Authored-By: Claude Opus 4.7 <[email protected]>
kalbasit
force-pushed
the
feat-cache-lru-eviction-to-ent
branch
from
May 22, 2026 23:54
1d43640 to
64a722f
Compare
kalbasit
force-pushed
the
refactor-cache-drop-legacy-tx-helpers
branch
from
May 22, 2026 23:54
6c5decb to
e24c793
Compare
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
…e-check After acquiring the migration lock, distinguish ent.IsNotFound (the expected "not yet migrated" case, fall through to migrate) from other DB errors (log at warn level instead of silently swallowing). The migration still attempts on any error so a transient lookup glitch doesn't block progress; if the DB is genuinely broken the upsert below will surface the failure. Addresses gemini-code-assist comment on PR #1216 (PRRT_kwDONV6tZs6D3YoD). Co-Authored-By: Claude Opus 4.7 <[email protected]>
kalbasit
force-pushed
the
feat-cache-lru-eviction-to-ent
branch
from
May 23, 2026 00:07
64a722f to
98d03dc
Compare
kalbasit
force-pushed
the
refactor-cache-drop-legacy-tx-helpers
branch
from
May 23, 2026 00:07
e24c793 to
e6aaef8
Compare
kalbasit
added a commit
that referenced
this pull request
May 23, 2026
…e-check After acquiring the migration lock, distinguish ent.IsNotFound (the expected "not yet migrated" case, fall through to migrate) from other DB errors (log at warn level instead of silently swallowing). The migration still attempts on any error so a transient lookup glitch doesn't block progress; if the DB is genuinely broken the upsert below will surface the failure. Addresses gemini-code-assist comment on PR #1216 (PRRT_kwDONV6tZs6D3YoD). Co-Authored-By: Claude Opus 4.7 <[email protected]>
kalbasit
force-pushed
the
feat-cache-lru-eviction-to-ent
branch
from
May 23, 2026 00:35
98d03dc to
453905e
Compare
kalbasit
force-pushed
the
refactor-cache-drop-legacy-tx-helpers
branch
from
May 23, 2026 00:35
e6aaef8 to
fdf9e14
Compare
kalbasit
added a commit
that referenced
this pull request
May 23, 2026
…e-check After acquiring the migration lock, distinguish ent.IsNotFound (the expected "not yet migrated" case, fall through to migrate) from other DB errors (log at warn level instead of silently swallowing). The migration still attempts on any error so a transient lookup glitch doesn't block progress; if the DB is genuinely broken the upsert below will surface the failure. Addresses gemini-code-assist comment on PR #1216 (PRRT_kwDONV6tZs6D3YoD). Co-Authored-By: Claude Opus 4.7 <[email protected]>
kalbasit
force-pushed
the
feat-cache-lru-eviction-to-ent
branch
from
May 23, 2026 03:31
453905e to
670f6c8
Compare
kalbasit
force-pushed
the
refactor-cache-drop-legacy-tx-helpers
branch
from
May 23, 2026 03:31
fdf9e14 to
ab142f2
Compare
…nish MigrateNarInfo Ent move Now that every cache call site goes through the Ent-backed withEntTransaction + withEntTransactionRetry path (§11.5 LRU conversion was the last holdout), the legacy qtx-style helpers have no production callers. Delete them: - *Cache.withTransaction (sqlc Querier closure + deadlock retry) - *Cache.executeTransaction (BeginTx/Rollback/Commit lifecycle) MigrateNarInfo's remaining db.GetNarInfoByHash post-lock recheck also flips to Ent: NarInfo.Query Where(HashEQ).Only, with the nullable URL handled via *string == nil instead of sql.NullString. The Querier parameter is removed from the function signature, the sole CLI caller (migrate-narinfo.go) is updated, and the unused db local from createDatabaseQuerier is now elided with _. The one internal test that still drove the old withTransaction (testStoreInDatabaseTransactionSafety) is converted to dbClient.WithTransaction + Ent OnConflict/Ignore + Query.Where — same scenario (concurrent UPSERT under a single tx), now via the production code path. The Cache.db Querier field is retained for now (a handful of fixture tests still build rows via the legacy API); §12 deletes it together with the sqlc dependency. Full -race sweep against SQLite + Postgres + MySQL + Redis + MinIO is clean. Co-Authored-By: Claude Opus 4.7 <[email protected]>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/cache/cache.go (1)
4804-4813:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate the exported docs to match the new
MigrateNarInfosignature.The doc block still lists the removed
dbparameter, so the public contract now disagrees with the actual API.✏️ Suggested doc fix
// Parameters: // - ctx: Context for the operation // - locker: Distributed locker for coordination (can be in-memory for single-instance) -// - db: Database querier (legacy; kept for the pre-lock double-check -// until §11 fully retires the Querier surface) -// - dbClient: Ent-backed client used by storeNarInfoInDatabase for -// the actual UPSERT pipeline +// - dbClient: Ent-backed client used for the post-lock migration check +// and the actual UPSERT pipeline // - narInfoStore: Optional storage backend to delete from after migration (nil to skip deletion) // - hash: The narinfo hash to migrate // - ni: The parsed narinfo to migrate🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/cache/cache.go` around lines 4804 - 4813, The doc comment for the exported function MigrateNarInfo is stale: it still lists a removed db parameter and mentions the legacy Querier surface. Update the comment to match the current MigrateNarInfo signature by removing the `db` parameter from the parameters list, ensure the remaining params (ctx, locker, dbClient, narInfoStore, hash, ni) are listed and described correctly, and adjust any wording that refers to the legacy Querier surface so the public docs accurately reflect the new API.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@pkg/cache/cache.go`:
- Around line 4804-4813: The doc comment for the exported function
MigrateNarInfo is stale: it still lists a removed db parameter and mentions the
legacy Querier surface. Update the comment to match the current MigrateNarInfo
signature by removing the `db` parameter from the parameters list, ensure the
remaining params (ctx, locker, dbClient, narInfoStore, hash, ni) are listed and
described correctly, and adjust any wording that refers to the legacy Querier
surface so the public docs accurately reflect the new API.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6408cf9d-8bb9-40fe-9a40-9a27c3bd6e64
📒 Files selected for processing (3)
pkg/cache/cache.gopkg/cache/cache_internal_test.gopkg/ncps/migrate_narinfo.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1216 +/- ##
=====================================
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:
|
This was referenced May 23, 2026
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.
Now that every cache call site goes through the Ent-backed
withEntTransaction + withEntTransactionRetry path (§11.5 LRU
conversion was the last holdout), the legacy qtx-style helpers
have no production callers. Delete them:
MigrateNarInfo's remaining db.GetNarInfoByHash post-lock recheck
also flips to Ent: NarInfo.Query Where(HashEQ).Only, with the
nullable URL handled via *string == nil instead of sql.NullString.
The Querier parameter is removed from the function signature, the
sole CLI caller (migrate-narinfo.go) is updated, and the unused
db local from createDatabaseQuerier is now elided with _.
The one internal test that still drove the old withTransaction
(testStoreInDatabaseTransactionSafety) is converted to
dbClient.WithTransaction + Ent OnConflict/Ignore + Query.Where —
same scenario (concurrent UPSERT under a single tx), now via the
production code path.
The Cache.db Querier field is retained for now (a handful of
fixture tests still build rows via the legacy API); §12 deletes
it together with the sqlc dependency.
Full -race sweep against SQLite + Postgres + MySQL + Redis +
MinIO is clean.
Co-Authored-By: Claude Opus 4.7 [email protected]