Repository navigation
fix(models): publish the provider catalog through an atomic pointer and drop the dao-side cache so concurrent readers and publishers no longer race - #21749
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Atomic catalog publication internal/entity/models/model.go, internal/entity/models/model_test.go, internal/entity/models/get_driver_test.go, internal/entity/models/nvidia_test.go, internal/entity/models/hostinger_router_test.go |
The models package stores and loads the provider manager through an atomic pointer. Tests check concurrent publication and use the getter and setter to manage manager state. |
DAO catalog access internal/dao/model_provider.go, internal/dao/database.go, internal/dao/model_provider_test.go, internal/service/tenant_test.go |
The DAO getter checks the published manager on each call and uses sync.Once for fallback lookup and initialization. The DAO-local cache and its assignment were removed. Tests check the getter’s result and concurrent callers; the tenant test no longer accesses the DAO-local variable through go:linkname. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers: ricardasbitinas-jpg
Merge Risk: 
Minimal · previous review 79bce
-
No actionable merge-blocking risk was established in the reviewed changes.
Pre-merge checks: 
3 · 
1 · 
1
-
Failed checks: 1 warning · 1 inconclusive Passed checks: 3 passed-
Full details: Title check
-
Explanation
The title names the main change: the provider catalog is published through an atomic pointer and the DAO-side cache is removed to stop races between readers and publishers. The title is long, at 147 characters and 22 words, but its scope matches the changeset. The title is accurate and specific, so it passes.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 7 functions across 7 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Full details: Description check
-
Explanation
The description has only a short Fix section. It says the catalog is published through an atomic pointer and the DAO-side cache is removed, so concurrent reads, lazy init, and re-publishing no longer race. The repository template asks for a Summary section that explains what the PR solves and gives background context for reviewers. The description does not give that background, such as why the DAO cache caused races or how the lazy-init fallback behaves now. The description is brief but names the change, so it is mostly complete in scope but lacks the required Summary heading and background.
Resolution
Rename the section to "Summary" to match the repository template. Add background context: the race or failure that the DAO-side cache and mutex caused, why the atomic pointer fixes it, and how the sync.Once fallback in GetModelProviderManager now behaves. Mention the test coverage added for concurrent reads and publication.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the catalog bright,
And reads its pointer, safe and right.
Eight callers gather, none alone,
While fallback waits its once-known turn.
Test paws restore the state they knew,
Then hop away with work to do.
There was a problem hiding this comment.
[P2] Avoid copying the atomic pointer in this test (internal/entity/models/hostinger_router_test.go:205-206)
providerManager is now an atomic.Pointer, which must not be copied after first use. This test still saves and restores it by direct assignment. Please use GetProviderManager() to save the current catalog and setProviderManager() to restore it, as the updated tests do.
…nd drop the dao-side cache so concurrent readers and publishers no longer race
79bcebe to
ec672ac
Compare
Fix
Publish the model provider catalog via an atomic pointer and drop the dao-side cache so concurrent reads, lazy init, and re-publishing no longer race.