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
rpc/blockchain: Reset scantxoutset progress before inferring descriptors #19362
rpc/blockchain: Reset scantxoutset progress before inferring descriptors #19362
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.
At first sight, it seems that your patch b6b1945 makes more sense. |
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.
Still a race, but I don't see an easy fix and this is probably good enough
utACK
Oh, @promag's solution does look better though. |
71fee9c
to
8c4129b
Compare
ACK |
@@ -2021,13 +2021,15 @@ class CoinsViewScanReserver | |||
if (g_scan_in_progress.exchange(true)) { | |||
return false; | |||
} | |||
CHECK_NONFATAL(g_scan_progress == 0); |
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.
If this were to fail, wouldn't it likely block all future reserves?
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.
You mean this should be fatal?
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.
Since it should be impossible, maybe simplest solution is to just remove it.
Otherwise, it might need something like:
CHECK_NONFATAL(g_scan_progress == 0); | |
if (g_scan_progress) { | |
error("ERROR: g_scan_progress was %s when it should be 0, in %s", g_scan_progress, __func__); | |
g_scan_progress = 0; | |
} |
Or:
CHECK_NONFATAL(g_scan_progress == 0); | |
if (g_scan_progress) { | |
g_scan_in_progress = false; | |
CHECK_NONFATAL(g_scan_progress == 0); | |
} |
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.
Then this should be assert(g_scan_progress == 0)
. I don't think all RPC code should use CHECK_NONFATAL
, at least #17192 doesn't say it.
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.
You can restart your node if this fails, but I don't think there is a need to crash the node.
Diff-minimised Github-Pull: bitcoin#19362 Rebased-From: 8c4129b
@prusnak I tend to like these invariants, it makes easier to understand the code. I think @luke-jr concern could be addressed by: const int scan_progress = g_scan_progress.exchange(0);
CHECK_NONFATAL(scan_progress == 0); I think @jonasschnelli, @MarcoFalke, @laanwj should take a look too for 0.21. |
Concept ACK. In the absence of test coverage, I agree this should check and fail somewhat loudly if |
Code review ACK 8c4129b |
Sorry for bumping the milestone here again. It seems almost ready for merge (could use one more ACK) but we don't want to rush a backport into 0.21.1. |
This came up in the IRC meeting. Adding this to the 22.0 milestone so it can hopefully be included there. |
Backported in #22580. |
Fixes #19361 by moving resetting the
g_scan_progress
variable before inferring the descriptors