Skip to content

fix(ratelimiter): return error when olric setup fails#292

Open
mesutoezdil wants to merge 2 commits into
NVIDIA:mainfrom
mesutoezdil:mesutoezdil/fix/ratelimiter-olric-new-error
Open

fix(ratelimiter): return error when olric setup fails#292
mesutoezdil wants to merge 2 commits into
NVIDIA:mainfrom
mesutoezdil:mesutoezdil/fix/ratelimiter-olric-new-error

Conversation

@mesutoezdil

@mesutoezdil mesutoezdil commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

TL;DR

NewRateLimiter logged the olric.New error and kept going with a nil db, so the next db.Start call panicked and crashed the process. Now it returns a wrapped error, and a stopCaches helper stops the two ttlcache goroutines on all three constructor error paths. go build and go test pass; no new test because olric.New cannot be forced to fail from outside the module.

Issues

Closes #291

Summary by CodeRabbit

  • Bug Fixes
    • Improved rate limiter startup reliability by ensuring background caches are stopped when initialization fails.
    • Initialization now fails fast and returns a clear error instead of continuing in a partially configured state.
  • Documentation
    • Clarified comment text around rate-limit tier applicability and precedence.

@mesutoezdil
mesutoezdil requested a review from a team as a code owner July 21, 2026 09:07
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The rate limiter now stops its caches when Olric or store initialization fails, returns a wrapped Olric error instead of continuing with a nil database, and updates comments describing tier behavior.

Changes

Rate limiter initialization

Layer / File(s) Summary
Handle initialization failures and clarify tier comments
src/invocation-plane-services/ratelimiter/rate_limiter.go
NewRateLimiter reuses cache cleanup across Olric and store failure paths, returns a wrapped Olric error, and updates comments for per-user, user-tier, and NCA-tier behavior.

Estimated code review effort: 2 (Simple) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: returning an error when Olric setup fails.
Linked Issues check ✅ Passed The fix returns Olric init errors instead of continuing with a nil db, addressing the reported startup panic.
Out of Scope Changes check ✅ Passed The extra cache shutdown and comment tweaks are incidental to the constructor error-handling fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/invocation-plane-services/ratelimiter/rate_limiter.go`:
- Line 304: Add a regression test for the Olric construction failure path in the
relevant rate-limiter startup function, verifying that an `olric.New` error
returns a nil limiter and propagates the same error. Use the repository’s native
test runner; if testing is infeasible, document the reason in the pull request
description.
- Around line 303-304: Remove the zap.L().Error call from the Olric
initialization failure path and continue returning err to the caller. Keep the
existing error propagation behavior in the surrounding initialization function
without adding duplicate logging.
- Around line 301-304: Update the Olric initialization error path after
olric.New in the rate-limiter setup to stop both ttlcache instances with
cache.Stop() and indexedPoliciesCache.Stop() before returning the error.
Preserve the existing error log and return values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 865fa2c6-1ede-4bb7-9cf2-6ea71dda8474

📥 Commits

Reviewing files that changed from the base of the PR and between 5ef95ed and 506a8ea.

📒 Files selected for processing (1)
  • src/invocation-plane-services/ratelimiter/rate_limiter.go

Comment thread src/invocation-plane-services/ratelimiter/rate_limiter.go Outdated
Comment thread src/invocation-plane-services/ratelimiter/rate_limiter.go Outdated
Comment thread src/invocation-plane-services/ratelimiter/rate_limiter.go Outdated
@mesutoezdil
mesutoezdil force-pushed the mesutoezdil/fix/ratelimiter-olric-new-error branch 2 times, most recently from c1f1df9 to 8099447 Compare July 21, 2026 12:32
@kristinapathak
kristinapathak requested a review from Max-NV July 21, 2026 17:13
@mesutoezdil
mesutoezdil force-pushed the mesutoezdil/fix/ratelimiter-olric-new-error branch from 8099447 to 4c15bfa Compare July 21, 2026 17:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/invocation-plane-services/ratelimiter/rate_limiter.go`:
- Around line 331-334: In the store initialization error path around NewStore,
call db.Shutdown(context.Background()) on a best-effort basis before returning
the store error, after stopping caches. Preserve the existing error logging and
ensure shutdown failures do not replace or suppress the original NewStore error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 35fb9aae-c1e3-41bb-9839-594dee98dd38

📥 Commits

Reviewing files that changed from the base of the PR and between 8099447 and 4c15bfa.

📒 Files selected for processing (1)
  • src/invocation-plane-services/ratelimiter/rate_limiter.go

Comment thread src/invocation-plane-services/ratelimiter/rate_limiter.go
@mesutoezdil
mesutoezdil force-pushed the mesutoezdil/fix/ratelimiter-olric-new-error branch from 4c15bfa to 8c892dc Compare July 21, 2026 18:07
NewRateLimiter logged the olric.New error but continued with a nil db,
so the following db.Start call panicked in a goroutine and crashed the
process. Return the wrapped error instead of logging it, per the
log-or-return rule, and stop the two ttlcache expiration goroutines on
every constructor error path so failed setup does not leak them. Also
replace three em dashes in nearby comments to satisfy the ASCII-only
style rule.

Closes NVIDIA#291

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
@mesutoezdil
mesutoezdil force-pushed the mesutoezdil/fix/ratelimiter-olric-new-error branch from 8c892dc to 8e138ae Compare July 21, 2026 18:28
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.

ratelimiter: startup panic when olric.New fails

2 participants