Keep quota reads side-effect free and tune MySQL pool lifetimes#764
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughQuota reads and admin tenant operations no longer synchronize or backfill TiDB Cloud spending limits. BASIC cluster metadata now supplies labels, and role-based MySQL pool timing defaults are increased. ChangesTiDB Cloud quota flow
Connection pool defaults
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR makes TiDB Cloud quota/authorization reads side‑effect free (no meta DB backfills) while still validating credentials using minimal (BASIC) cluster data, and it tunes default MySQL connection pool lifetimes to reduce churn/invalid-connection issues.
Changes:
- Switch credential-based authorization reads to
view=BASICcluster lookups and stop reading cloud spending limits on quota GET. - Remove spending-limit backfill behavior from quota and admin tenant read endpoints (explicit quota updates / lifecycle seeding remain the mutation points).
- Increase default meta DB and user-schema DB connection max lifetimes (and slightly adjust meta idle timeout).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/tenant/tidbcloudnative/provisioner.go | Replaces full cluster/quota fetch with BASIC cluster info for label-based authorization and removes spending-limit reads from GetQuota. |
| pkg/tenant/tidbcloudnative/provisioner_test.go | Updates/extends tests to assert BASIC view usage and absence of spending-limit reads on quota authorization. |
| pkg/server/quota.go | Removes spending-limit sync/backfill side effects from the quota GET handler while keeping RBAC caching behavior. |
| pkg/server/quota_test.go | Adjusts expectations to ensure GET paths do not mutate persisted spending limits / checked-at timestamps and adds coverage for admin list include_quota behavior. |
| pkg/server/admin_tenants.go | Removes admin tenant list/get spending-limit sync/backfill logic so reads no longer mutate quota config state. |
| pkg/mysqlutil/pool.go | Tunes default connection max lifetimes/idle times for meta and user-schema pools. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Reviewed the full branch (read-only, did not compile; noting the test-plan already covers the focused quota/admin suites + lint). This is a clean, well-scoped change — net -176/+162, mostly deleting read-path side effects. LGTM with a couple of things to confirm, no blockers. ✅ Theme 1: side-effect-free quota reads — correct
This is the right resolution to the concern I raised on #762 (the sync-failure-downgraded-to-warning): rather than a read that best-effort-writes, reads are now purely reads, and spending limits are written only by explicit quota updates + lifecycle seeds. One consequence worth stating in the PR body: a GET can now return a stale spending limit (no cloud refresh on read). That's the intended trade and it's consistent, but it is a client-visible contract change from "GET refreshes from cloud" to "GET returns last-persisted" — worth a sentence so downstream consumers know. ✅ Theme 2: BASIC view + removing clusterQuotaInfo — clean
One thing to confirm: 🟡 Theme 3: MySQL pool lifetimes — low-risk tuning, no data givenmeta lifetime 5→10m, meta idle 45s→1m, user-schema lifetime 1→3m. Direction is reasonable (fewer reconnects, less churn — plausibly related to the earlier Nit
Net: correct, subtractive, and it resolves the read-side-effect concern from #762. Happy to see it land once the stale-GET contract note and the admin-cache-TTL check are addressed. |
Summary
Test Plan
Full server test note
A full go test ./pkg/server -count=1 was attempted twice. In both runs, the package-local MySQL test instance returned invalid connection after roughly two minutes, causing cascading failures in later token, upload, and vault tests. No quota or admin-quota assertion failed, and the focused affected test set above passes.
Summary by CodeRabbit
Bug Fixes
Tests