Skip to content

fix: revalidatePoolSettings bypasses client cache with WithSkipCache#379

Merged
jeffersonrodrigues92 merged 1 commit intodevelopfrom
fix/revalidation-bypass-cache
Mar 21, 2026
Merged

fix: revalidatePoolSettings bypasses client cache with WithSkipCache#379
jeffersonrodrigues92 merged 1 commit intodevelopfrom
fix/revalidation-bypass-cache

Conversation

@jeffersonrodrigues92
Copy link
Contributor

Summary

revalidatePoolSettings in both tmpostgres.Manager and tmmongo.Manager was calling GetTenantConfig without WithSkipCache(). The 1h in-memory cache returned stale "active" config, preventing detection of tenant suspension/purge (403 response).

Fix

Added client.WithSkipCache() to the GetTenantConfig call in revalidatePoolSettings for both managers. Revalidation now makes a fresh HTTP request to tenant-manager every check interval.

Test plan

  • go test -race ./commons/tenant-manager/postgres/... ./commons/tenant-manager/mongo/... — pass
  • New tests verify cache bypass detects 403 suspension

Revalidation was reading from the 1h in-memory cache instead of making a fresh HTTP request. Added WithSkipCache() to detect 403 (tenant suspended/purged) promptly.

X-Lerian-Ref: 0x1
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 738cb254-cfa6-4885-a206-b9b0a8977d6d

📥 Commits

Reviewing files that changed from the base of the PR and between f7e2fd1 and 21fc784.

📒 Files selected for processing (4)
  • commons/tenant-manager/mongo/manager.go
  • commons/tenant-manager/mongo/manager_test.go
  • commons/tenant-manager/postgres/manager.go
  • commons/tenant-manager/postgres/manager_test.go

Walkthrough

This pull request modifies the asynchronous settings revalidation logic in both the Mongo and Postgres tenant managers. The revalidatePoolSettings methods now explicitly bypass the client cache by adding the client.WithSkipCache() option when calling GetTenantConfig. This ensures that revalidation always retrieves fresh tenant configuration data rather than relying on potentially stale cached values. All other control flow paths, including error handling for suspended tenants and connection eviction, remain unchanged. Corresponding tests are added to both implementations to verify the cache-bypassing behavior.

🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description explains the problem, the fix, and provides evidence of testing (go test -race passes and new tests verify cache bypass). However, it does not follow the repository's pull request template with the required checklist sections. Use the repository's PR template format with the checklist items and mark completed items as [x] to ensure consistency and traceability.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: adding WithSkipCache() to revalidatePoolSettings to bypass the client cache during revalidation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@jeffersonrodrigues92 jeffersonrodrigues92 merged commit 5de4f9d into develop Mar 21, 2026
3 checks passed
@jeffersonrodrigues92 jeffersonrodrigues92 deleted the fix/revalidation-bypass-cache branch March 21, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant