Repository navigation
Isolate PRISM share hot-path locking - #83
Merged
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 406e9e9. Configure here.
| key = (label, reason) | ||
| self.worker_rejection_counts[key] = ( | ||
| int(self.worker_rejection_counts.get(key, 0)) + 1 | ||
| ) |
There was a problem hiding this comment.
Share metrics lock-order deadlock
High Severity
record_rejection takes _share_accounting_lock then worker_metrics_lock, while note_worker_accepted_share takes worker_metrics_lock then _share_accounting_lock for stale-grace credits. Concurrent reject and grace-accept paths can deadlock and stall share handling.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 406e9e9. Configure here.
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.


Summary
Testing
python -m unittest tests.test_prism_hot_path tests.test_prism_share_ledger tests.test_prism_coordinator_vardiff(413 tests)python3 -m unittest tests.test_prism_coordinator_job_cache tests.test_prism_initial_job_delivery tests.test_prism_tip_refresh_validation tests.test_prism_coordinator_shutdown(186 tests)python -m compileall -q docker lab tests examples scriptsgit diff --checkNote
High Risk
Changes lock ordering and share/block submission concurrency in the mining coordinator; regressions could affect tip publication, duplicate detection, or block-candidate durability, though coverage targets those paths explicitly.
Overview
Reduces coordinator lock convoys on the Stratum share path by moving recent-share dedup, global share counters/rejections, and per-connection Vardiff state onto dedicated locks, with a fixed rule that
vardiff_lockis taken beforeself.lockon job delivery and idle retarget paths.Normal
mining.submitnow does one control-plane snapshot (pool_closed, job context, published tip) instead of multiple coordinator acquisitions; duplicate-share tracking and accounting no longer run under the global lock.The coordinator lock becomes
_ObservedRLockwith Prometheus contention/wait metrics. Block-candidate retries use sliced heartbeat waits during backoff (so intentional sleeps refresh the submitter watchdog but stuck RPC/SQL does not),mark_block_candidate_attemptedat processing entry (ledger/outbox), and new gauges for pending candidate age and retry backoff state.Reviewed by Cursor Bugbot for commit 406e9e9. Bugbot is set up for automated code reviews on this repo. Configure here.