Repository navigation
feat(cache): add withEntTransaction infrastructure helper - #1194
Merged
Merged
Conversation
This was referenced May 21, 2026
Owner
Author
This was referenced May 21, 2026
kalbasit
force-pushed
the
feat-cache-getnarinfo-to-ent
branch
from
May 22, 2026 17:18
7537892 to
2c22541
Compare
kalbasit
force-pushed
the
feat-cache-with-ent-transaction
branch
from
May 22, 2026 17:18
e22ab56 to
8078fbf
Compare
kalbasit
force-pushed
the
feat-cache-getnarinfo-to-ent
branch
from
May 22, 2026 17:39
2c22541 to
38fa3fa
Compare
kalbasit
force-pushed
the
feat-cache-with-ent-transaction
branch
from
May 22, 2026 17:39
8078fbf to
e2c4993
Compare
Adds the Ent-backed counterpart to *Cache.withTransaction so upcoming §11.2-§11.5 caller-migration commits can convert qtx-style closures one at a time without rewriting the deadlock-retry policy each time. The helper: - delegates the lifecycle (begin → fn(tx) → commit / rollback / panic-rollback) to *database.Client.WithTransaction added in §10 - preserves the existing retry-on-deadlock loop verbatim (5 attempts, 50ms initial back-off doubling per try, ctx-aware pacing, deadlock detection via database.IsDeadlockError) so conversions are behavior-preserving - is annotated //nolint:unused because no call site is converted yet; the annotation will come off as soon as the first qtx-style block migrates over Once every withTransaction call site moves off the Querier closure shape, the legacy withTransaction (and the underlying executeTransaction) become dead code and are removed in §12. No behavior change. Lint clean, full pkg/cache -race test suite passes against SQLite + Postgres + MySQL + MinIO + Redis.
kalbasit
force-pushed
the
feat-cache-with-ent-transaction
branch
from
May 22, 2026 17:53
e2c4993 to
f92d4a6
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1194 +/- ##
=====================================
Coverage 4.94% 4.94%
=====================================
Files 6 6
Lines 445 445
=====================================
Hits 22 22
Misses 419 419
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 22, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 23, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
kalbasit
added a commit
that referenced
this pull request
May 23, 2026
PR #1194 review surfaced two issues in withEntTransaction: 1. (PRRT_kwDONV6tZs6DsQzn) Restore "starting transaction" / "committed successfully" debug logs that the legacy executeTransaction emitted. Behind Debug level so noise stays opt-in; restores observability parity. 2. (PRRT_kwDONV6tZs6DsQzo) Replace `case <-time.After(delay):` inside the retry select with `time.NewTimer(delay)` + `t.Stop()` in the ctx-cancellation branch to avoid leaking the underlying timer when ctx wins the race. Behaviour-preserving on the happy path.
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.
Adds the Ent-backed counterpart to *Cache.withTransaction so
upcoming §11.2-§11.5 caller-migration commits can convert
qtx-style closures one at a time without rewriting the
deadlock-retry policy each time.
The helper:
/ panic-rollback) to *database.Client.WithTransaction added
in §10
attempts, 50ms initial back-off doubling per try, ctx-aware
pacing, deadlock detection via database.IsDeadlockError) so
conversions are behavior-preserving
converted yet; the annotation will come off as soon as the
first qtx-style block migrates over
Once every withTransaction call site moves off the Querier
closure shape, the legacy withTransaction (and the underlying
executeTransaction) become dead code and are removed in §12.
No behavior change. Lint clean, full pkg/cache -race test
suite passes against SQLite + Postgres + MySQL + MinIO + Redis.