Conversation
4 tasks
- Add IDistributedLock interface + InProcessDistributedLock implementation - Add lock_ttl_ms field to MaintenanceScheduleEntry (configurable per schedule) - Add setDistributedLock() to DatabaseMaintenanceOrchestrator - Integrate distributed lock in executeSchedule(): tryAcquire before job, RAII release guard on every code path, SKIPPED + DEBUG log when peer holds lock - Auto-compute TTL from window_duration + 30s safety margin when lock_ttl_ms==0 - Add 14 new tests (DL-1..9 + InProcessDistributedLock unit tests) - Update FUTURE_ENHANCEMENTS.md, ROADMAP.md, artifacts roadmap body Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/5249e380-12f0-4bb6-8f83-7f577da13c19 Co-authored-by: makr-code <150588092+makr-code@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement distributed maintenance coordination via Raft
feat(maintenance): Distributed Maintenance Coordination via Raft (v2.0.0)
Apr 13, 2026
makr-code
added a commit
that referenced
this pull request
Apr 14, 2026
…0.0) (#4630) * Initial plan * feat(maintenance): Distributed Maintenance Coordination via Raft (#252) - Add IDistributedLock interface + InProcessDistributedLock implementation - Add lock_ttl_ms field to MaintenanceScheduleEntry (configurable per schedule) - Add setDistributedLock() to DatabaseMaintenanceOrchestrator - Integrate distributed lock in executeSchedule(): tryAcquire before job, RAII release guard on every code path, SKIPPED + DEBUG log when peer holds lock - Auto-compute TTL from window_duration + 30s safety margin when lock_ttl_ms==0 - Add 14 new tests (DL-1..9 + InProcessDistributedLock unit tests) - Update FUTURE_ENHANCEMENTS.md, ROADMAP.md, artifacts roadmap body Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/5249e380-12f0-4bb6-8f83-7f577da13c19 Co-authored-by: makr-code <150588092+makr-code@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: makr-code <150588092+makr-code@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a multi-node cluster, every node independently fires the same maintenance schedules, causing compaction storms and duplicate work. This PR introduces a pluggable distributed lock that the orchestrator acquires before each scheduled job, ensuring only one node executes per schedule per cron tick.
Description
IDistributedLockinterface +InProcessDistributedLock(include/maintenance/i_distributed_lock.h)tryAcquire(key, ttl_ms),release(key),getHolderNodeId(key),nodeId()InProcessDistributedLock: thread-safe in-process implementation for single-node and tests; TTL expiry checked per acquiresetDistributedLock()Orchestrator lock integration (
database_maintenance_orchestrator.*)setDistributedLock(shared_ptr<IDistributedLock>)— DI setter, thread-safe, nullable (disables feature)executeSchedule(), lock is acquired before the window check; on failure: job →SKIPPED, DEBUG log:"schedule {id} skipped — lock held by peer {node_id}"DistLockGuardensures release on every exit path (success, window skip, DAG error, cancellation)TTL computation
MaintenanceScheduleEntry::lock_ttl_ms(default0) makes TTL configurable per schedule.New fields
MaintenanceScheduleEntry::lock_ttl_ms— serialized intoJson()/fromJson()/applyPatch()Linked Issues
Closes #252
Type of Change
Breaking Change Checklist
VERSIONandCMakeLists.txtdocs/migration/### Removed/### Changedsection updatedTesting
14 new tests in
test_database_maintenance_orchestrator.cpp:DL-1: no lock configured → backwards-compatible, job runs normallyDL-2: lock acquired → job executes, acquire + release called onceDL-3: lock held by peer →SKIPPED, error message contains peer node IDDL-4/5: TTL auto-compute from window vs. explicitlock_ttl_msDL-6/7:lock_ttl_msJSON round-trip andapplyPatchDL-8:setDistributedLock(nullptr)clears lock, no acquire/release callsInProcessDistributedLock: first acquires, second blocked; release; TTL expiry;getHolderNodeIdafter expiry📚 Research & Knowledge (wenn applicable)
/docs/research/angelegt?/docs/research/implementation_influence/eingetragen?Relevante Quellen:
Checklist
[Unreleased]