Skip to content

Fix race condition in SharesMonitor that drops shares during send#218

Open
rx18-eng wants to merge 1 commit into
dmnd-pool:masterfrom
rx18-eng:fix/shares-monitor-race-condition
Open

Fix race condition in SharesMonitor that drops shares during send#218
rx18-eng wants to merge 1 commit into
dmnd-pool:masterfrom
rx18-eng:fix/shares-monitor-race-condition

Conversation

@rx18-eng
Copy link
Copy Markdown
Contributor

The share monitor had a race condition where shares could get silently dropped. get_next_shares() clones the vec, then after the HTTP send finishes, clear_next_shares() wipes everything including shares that miners pushed while the request was in flight. Replaced the clone+clear with std::mem::take so it atomically moves shares out in one lock, and new shares that come in during the send just go into the fresh empty vec. Also added a requeue on send failure so shares don't get lost if the monitoring server is down.

@rx18-eng
Copy link
Copy Markdown
Contributor Author

rx18-eng commented Apr 17, 2026

@jbesraa @Priceless-P does this seem valid to you ?

Copy link
Copy Markdown
Contributor

@jbesraa jbesraa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add tests to this module before changing it

@rx18-eng rx18-eng force-pushed the fix/shares-monitor-race-condition branch from d9ec044 to 290eccb Compare April 20, 2026 07:00
@rx18-eng rx18-eng requested a review from jbesraa April 20, 2026 07:00
Comment thread src/monitor/shares.rs Outdated
@rx18-eng rx18-eng requested a review from jbesraa April 20, 2026 08:35
Copy link
Copy Markdown
Contributor

@jbesraa jbesraa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small nit, looks good otherwise

Comment thread src/monitor/shares.rs Outdated
@rx18-eng
Copy link
Copy Markdown
Contributor Author

@jbesraa plss let me know if anyother changes are needed !

@rx18-eng rx18-eng requested a review from jbesraa April 20, 2026 09:07
@jbesraa
Copy link
Copy Markdown
Contributor

jbesraa commented Apr 20, 2026

thanks @rx18-eng this looks good. can u please squash commits?

Signed-off-by: rx18-eng <remopanda78@gmail.com>
@rx18-eng rx18-eng force-pushed the fix/shares-monitor-race-condition branch from 14777ab to c14a1e2 Compare April 20, 2026 18:56
@rx18-eng
Copy link
Copy Markdown
Contributor Author

@jbesraa i have squahed the commits , let me knowif any other changes are needed before you merge !

@rx18-eng
Copy link
Copy Markdown
Contributor Author

@jbesraa shall i update anything else on this pr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants