fix: reset metering billing cycles without Redis KEYS - #743
Conversation
|
Warning Review limit reached
More reviews will be available in 32 minutes and 16 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (23)
✨ Finishing Touches🧪 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 |
📊 Benchmark Results❌ Some benchmarks failed
Updated: 2026-06-14T21:07:29.884Z · Commit: 2beed79 |
6fc54d1 to
539d672
Compare
539d672 to
8ee40e7
Compare
Summary
Fixes #703.
RedisUsageStorage.resetBillingCycle(tenantId)now resets tenant-wide billing cycle usage with bounded RedisSCANbatches instead of the blockingKEYScommand. Single-meter reset keeps the exact-key delete path, and tenant-wide patterns now escape Redis glob metacharacters in tenant IDs.변경 사항
KEYSscript with repeatedSCAN MATCH ... COUNT 500batches that delete only each returned batch.@croco/metering-core.@croco/testingAPI docs from Typedoc so the required docs-sync and docs-catalog checks agree on trunk-generated documentation.Verification
pnpm --filter @croco/metering-core exec vitest run src/tests/RedisUsageStorage.spec.ts --reporter verbose- 26 tests passed.pnpm --filter @croco/metering-core test- 13 files, 158 tests passed.pnpm test --filter=@croco/metering-core- 14 Turbo tasks passed.pnpm typecheck --filter=@croco/metering-core- 14 Turbo tasks passed.pnpm build --filter=@croco/metering-core- 7 Turbo tasks passed.pnpm --filter @croco/metering-core lint- 0 warnings/errors.pnpm docs:build- generated docs successfully and emitted@croco/testingAPI reference pages.pnpm check- passed package manifest, docs catalog, circular dependency, oxlint, and oxfmt checks after docs regeneration.pnpm exec changeset status --since origin/trunk- patch bump reported for@croco/metering-coreand dependent packages.pnpm test197/197 tasks passed; fullpnpm typecheck196/196 tasks passed.Self-review
SCANand notKEYS.RedisClientandUsageStoragepublic contracts are unchanged, no dependencies or lockfile entries changed, tenant glob metacharacters are escaped beforeMATCH, and a patch changeset covers the runtime behavior change.RedisUsageStorage, keeps single-meter reset unchanged, uses the existingevalboundary, and avoids new abstractions or unrelated cleanup.Risk
Low to moderate. Tenant-wide reset still scans the Redis keyspace, but it does so in bounded batches instead of blocking on
KEYS. Redis Cluster-specific Lua key declaration restrictions are not covered by the currentRedisClienttest harness; this PR keeps the existing eval-based storage boundary unchanged.