Repository navigation
fix #398: remove lease.enabled flag — TTL always active, fix fatal crash on put_with_ttl - #399
Conversation
…ash on put_with_ttl
|
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 (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR removes the ChangesTTL/Lease Always Enabled
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
d-engine-server/src/api/standalone.rs (1)
125-129: 💤 Low valueStale comment: "Inject lease if enabled".
The comment says "if enabled" but the code now unconditionally injects the lease. Consider removing or updating this comment to match the new always-on behavior.
Suggested fix
- // Inject lease if enabled + // Inject lease (TTL is always active) let lease = Arc::new(crate::storage::DefaultLease::new(🤖 Prompt for 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. In `@d-engine-server/src/api/standalone.rs` around lines 125 - 129, The inline comment "Inject lease if enabled" is stale because the code now unconditionally creates DefaultLease and calls sm.set_lease; update or remove the comment to reflect always-on behavior (referencing DefaultLease::new and sm.set_lease) — e.g., change to "Inject lease (always enabled)" or remove the comment entirely so it matches the unconditional DefaultLease creation and sm.set_lease call.
🤖 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 `@d-engine-server/tests/embedded_client/embedded_client_operations.rs`:
- Around line 597-602: The test's liveness check calls client.put(...) after the
TTL write but never performs the corresponding read; fix this by following the
existing client.put(b"probe", b"alive").await.expect(...) with a linearizable
read using client.get_linearizable(b"probe").await and assert the returned value
equals b"alive" (use .expect(...) or appropriate assertion) so the test verifies
both put and get post put_with_ttl.
---
Nitpick comments:
In `@d-engine-server/src/api/standalone.rs`:
- Around line 125-129: The inline comment "Inject lease if enabled" is stale
because the code now unconditionally creates DefaultLease and calls
sm.set_lease; update or remove the comment to reflect always-on behavior
(referencing DefaultLease::new and sm.set_lease) — e.g., change to "Inject lease
(always enabled)" or remove the comment entirely so it matches the unconditional
DefaultLease creation and sm.set_lease call.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 771c5d6d-8f81-43c0-b204-cfc1d6e5a1d3
📒 Files selected for processing (21)
config/base/raft.tomld-engine-core/src/config/lease.rsd-engine-core/src/config/lease_test.rsd-engine-core/src/errors.rsd-engine-server/benches/lease_performance.rsd-engine-server/benches/state_machine.rsd-engine-server/benches/ttl.rsd-engine-server/src/api/embedded.rsd-engine-server/src/api/standalone.rsd-engine-server/src/node/builder.rsd-engine-server/src/storage/adaptors/file/file_state_machine.rsd-engine-server/src/storage/adaptors/rocksdb/rocksdb_state_machine.rsd-engine-server/src/storage/adaptors/rocksdb/rocksdb_unified_engine_test.rsd-engine-server/src/storage/lease_integration_test.rsd-engine-server/src/storage/lease_unit_test.rsd-engine-server/tests/consistent_reads/lease_read_embedded.rsd-engine-server/tests/drain_batching/select_fairness_embedded.rsd-engine-server/tests/embedded_client/embedded_client_operations.rsexamples/three-nodes-standalone/config/n1.tomlexamples/three-nodes-standalone/config/n2.tomlexamples/three-nodes-standalone/config/n3.toml
💤 Files with no reviewable changes (10)
- examples/three-nodes-standalone/config/n3.toml
- d-engine-server/benches/state_machine.rs
- d-engine-core/src/errors.rs
- examples/three-nodes-standalone/config/n2.toml
- d-engine-server/benches/lease_performance.rs
- d-engine-server/src/storage/adaptors/rocksdb/rocksdb_unified_engine_test.rs
- d-engine-server/benches/ttl.rs
- d-engine-server/tests/consistent_reads/lease_read_embedded.rs
- examples/three-nodes-standalone/config/n1.toml
- d-engine-server/tests/drain_batching/select_fairness_embedded.rs
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
What Does This PR Do?
Removes
lease.enabledconfig flag — TTL is now always active. Fixes a fatal crashwhere
put_with_ttl()with default config caused the SM worker to sendFatalError,shutting down the entire node.
Type:
Why Is This Needed?
Root cause: With default config (no
[raft.state_machine.lease]section),put_with_ttl()would commit a TTL entry to the Raft log, then fail during SM applywith
StorageError::FeatureNotEnabled. The SM worker incorrectly mapped this toRoleEvent::FatalError— a path reserved for unrecoverable I/O failures — causingthe node to shut down with no recovery path.
Fix: Remove
lease.enabledentirely. TTL is always active. Overhead when no TTLkeys exist is negligible: cleanup worker costs a single atomic load (~10ns) per cycle
via the new
has_lease_keys()fast path.Why not keep
enabledwith a better error? A committed Raft entry cannot beun-committed. Rejecting it at apply time violates the Raft consistency invariant (all
nodes must apply committed entries deterministically). The correct fix is to make TTL
always work, not to fail more gracefully at the wrong layer.
Checklist
Required:
make testpassesIf changing APIs:
Testing
How tested:
lease_test.rs— updated to removeenabledfield; all validationrange tests preserved
lease_integration_test.rs— removedenabled: truefrom allfixtures; added 4 new fast path tests (file + rocksdb × no-TTL-keys +
unexpired-keys)
test_put_with_ttl_succeeds_with_default_configinembedded_client_operations.rs— confirmed FAIL on main (ConnectionTimeout due tonode crash), PASS after fix
For bug fixes:
For performance improvements:
lease_background_cleanup()now short-circuits in two stages:has_lease_keys() == false→ single atomic load, ~10ns (most common case)may_have_expired_keys() == false→ sample first 10 entries, ~30nsDoes This Follow d-engine's Principles?
Reviewer Notes
Breaking change:
LeaseConfig.enabledfield is removed. Any config file with[raft.state_machine.lease] enabled = true/falsemust remove that line. The fieldis silently ignored by serde (unknown fields are ignored in TOML), so existing
deployments won't crash — but the field no longer has any effect.
All affected files updated:
config/base/raft.toml,examples/three-nodes-standalone/,test fixtures, bench files.
Estimated review complexity:
Summary by CodeRabbit
Configuration Changes
enabledtoggle was removedBehavior Changes
Tests