-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix utxo scan edge case when pc awakes from sleep #3160
fix: fix utxo scan edge case when pc awakes from sleep #3160
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine. Could have also been done in fewer lines using a delay that you set each time instead of an interval, but doesn't really matter
@@ -709,21 +709,34 @@ where TBackend: WalletBackend + 'static | |||
let mut shutdown = self.shutdown_signal.clone(); | |||
let start_at = Instant::now() + Duration::from_secs(1); | |||
let mut work_interval = time::interval_at(start_at.into(), self.scan_for_utxo_interval).fuse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut work_interval = time::interval_at(start_at.into(), self.scan_for_utxo_interval).fuse(); | |
let mut work_interval = time::delay_for(self.scan_for_utxo_interval); |
} | ||
previous = Instant::now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previous = Instant::now(); | |
work_interval = time::delay_for(self.scan_for_utxo_interval); |
// This bit of code prevents bottled up tokio interval events to be fired successively for the edge | ||
// case where a computer wakes up from sleep. | ||
if start_at.elapsed() > self.scan_for_utxo_interval && | ||
previous.elapsed() < self.scan_for_utxo_interval.mul_f32(0.9) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The strictly less than probably is good enough without the mul_f32
PR queued successfully. Your position in queue is: 8 |
PR is on top of the queue now |
PR failed to merge with reason: Some CI status(es) failed |
This PR fixes an issue where bottled up tokio interval events are fired successively for the edge case where a computer wakes up from sleep. This was evident in the UTXO scanning service where many many UTXO scanning tasks would be started in parallel afterwards instead of only one.
c920337
to
4d09eae
Compare
PR queued successfully. Your position in queue is: 1 |
PR failed to merge with reason: Failed due to unknown reason |
PR queued successfully. Your position in queue is: 1 |
PR failed to merge with reason: Failed due to unknown reason |
PR queued successfully. Your position in queue is: 1 |
PR failed to merge with reason: Failed due to unknown reason |
PR queued successfully. Your position in queue is: 1 |
PR failed to merge with reason: Failed due to unknown reason |
PR queued successfully. Your position in queue is: 1 |
PR failed to merge with reason: Failed due to unknown reason |
PR queued successfully. Your position in queue is: 1 |
PR failed to merge with reason: Ready label was manually removed |
Description
This PR fixes an issue where bottled up tokio interval events are fired successively for the edge case where a computer wakes up from sleep. This was evident in the UTXO scanning service where many UTXO scanning tasks would be started in parallel afterwards instead of only one.
The log extract below shows multiple tokio interval events being fired and negated by the code change. The computer was put to sleep just after a completed scan at 14:23:29 and woken again at ~14:39:47. UTXO scanning interval was set at 30s for this test.
Motivation and Context
The code should behave in a predicted manner when waking from sleep.
How Has This Been Tested?
System-level testing with a base node and a console wallet.
Checklist:
development
branch.