feat(ledger): add setting to disable alone-in-bucket query optimization#478
Conversation
Add a `ledger.disable-ledger-scope-optimization` bool setting that, when true, sets DISABLE_LEDGER_SCOPE_OPTIMIZATION=true on the stateless ledger deployment. This forces the ledger to always emit the `ledger = ?` predicate on read queries, disabling the alone-in-bucket optimization that skips it when a ledger is the only one in its bucket. Mirrors the --disable-ledger-scope-optimization serve flag introduced in formancehq/ledger@222fb71. Scoped to the stateless (serve) deployment only; the worker keeps the optimization on, matching the upstream commit. Constraint: optimization is wired only into `serve` upstream — worker/buckets-upgrade keep it on (correctness-neutral) Confidence: high Scope-risk: narrow
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
WalkthroughThis PR adds a new configuration setting ChangesLedger scope optimization disable setting
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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 |
What
Adds a
ledger.disable-ledger-scope-optimizationbool Settings key. When set totrue, the operator setsDISABLE_LEDGER_SCOPE_OPTIMIZATION=trueon the stateless ledger deployment.This forces the ledger to always emit the
ledger = ?predicate on read queries, disabling the "alone-in-bucket" optimization that skips it when a ledger is the only one in its bucket.Why
Mirrors the
--disable-ledger-scope-optimizationserve flag introduced upstream in formancehq/ledger@222fb71, exposing it as an operator Settings escape hatch for operators who need the always-correct scoped query behavior independent of bucket population.Scope
serve) deployment, matching the upstream commit — the worker keeps the optimization on (correctness-neutral).experimental-*/schema-enforcement-modesettings.Usage
Changes
internal/resources/ledgers/deployments.go— read the new setting ininstallLedgerStateless, emit the env var when enabled.docs/04-Modules/03-Ledger.md— new section with a Settings example.docs/09-Configuration reference/01-Settings.md— new settings-table row.docs/09-Configuration reference/settings.catalog.json— regenerated viagenerate-settings-catalog.Verification
go build ./internal/resources/ledgers/passes.