feat(transaction): Adaptive Deadlock Prevention via DeadlockPredictor (v1.9.0)#4202
Open
feat(transaction): Adaptive Deadlock Prevention via DeadlockPredictor (v1.9.0)#4202
Conversation
Add DeadlockPredictor class with: - Historical deadlock pattern analysis via pair-conflict weight matrix - Lock acquire order recommendation (danger-score sort) - Deadlock probability scoring with active-transaction contention scaling - Dynamic timeout estimation from observed per-key hold-time percentiles Integrate into TransactionManager: - setDeadlockPredictor / getDeadlockPredictor - predictDeadlockProbability / recommendLockOrder / recommendTimeout - Auto-training on commitTransaction, rollbackTransaction, resolveDeadlock Add 30 focused tests (DeadlockPredictorTest + AdaptiveDeadlockIntegrationTest), register in tests/CMakeLists.txt, add CI workflow, update ROADMAP.md. Co-authored-by: makr-code <150588092+makr-code@users.noreply.github.com>
- Use chrono::duration_cast for 60s constant in test - Clarify NUL byte comment in deadlock_predictor.cpp Co-authored-by: makr-code <150588092+makr-code@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement adaptive deadlock prevention for transaction domain
feat(transaction): Adaptive Deadlock Prevention via DeadlockPredictor (v1.9.0)
Mar 13, 2026
makr-code
approved these changes
Mar 14, 2026
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.
Implements the
Adaptive Deadlock Preventionroadmap item for the transaction domain targeting v1.9.0. Adds aDeadlockPredictorclass that learns from historical lock patterns and deadlock events to score deadlock risk, recommend safe lock ordering, and suggest adaptive timeouts.Description
DeadlockPredictor(new standalone class)deadlock_weight_multiplier) to reinforce high-risk pairspredictDeadlockProbability(proposed_locks, active_txns): normalised conflict score scaled bylog1p(active_count)contention factor; returns 0.0 belowmin_samples_for_predictionthresholdrecommendLockOrder(keys): sorts keys by ascending danger score (sum of conflict weights), lexicographic tiebreak — deterministic, safe-first orderingrecommendTimeout(keys): derives p90 of observed per-key hold times × 2 safety margin, clamped to[min, max]config boundsrecordTransaction()/recordDeadlock(); bounded circular buffers (pattern deque + eviction on pair-conflict map overflow)TransactionManagerintegrationcommitTransaction/rollbackTransaction(records key pattern + duration)resolveDeadlock(collects held + waiting keys from cycle participants and callsrecordDeadlock)deadlock_timeout_ms_)Files added / changed
include/transaction/deadlock_predictor.h+src/transaction/deadlock_predictor.cpp— standalone, no heavy depsinclude/transaction/transaction_manager.h—#include deadlock_predictor.h, 5 new public methods,deadlock_predictor_private membersrc/transaction/transaction_manager.cpp— new method bodies + training hooks incommitTransaction,rollbackTransaction,resolveDeadlocktests/test_adaptive_deadlock_prevention.cpp— 30 focused tests (DeadlockPredictorTest× 18,AdaptiveDeadlockIntegrationTest× 12)tests/CMakeLists.txt—AdaptiveDeadlockPreventionFocusedTeststarget.github/workflows/adaptive-deadlock-prevention-ci.yml— CI on ubuntu-22.04/gcc-12 + ubuntu-24.04/gcc-14src/transaction/ROADMAP.md— Phase 5 added, item marked[x]Type of Change
Testing
📚 Research & Knowledge (wenn applicable)
/docs/research/angelegt?/docs/research/implementation_influence/eingetragen?Relevante Quellen:
Checklist
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.