Skip to content
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

chain+wallet: fix race over RescanProgress message #891

Merged
merged 3 commits into from
Oct 17, 2023

Conversation

yyforyongyu
Copy link
Collaborator

@yyforyongyu yyforyongyu commented Oct 13, 2023

There's a race found in lnd side re multiple goroutines accessing the RescanProgress, details in this PR.

It also fixes the case where bitcoind is still loading blocks, causing the NewBitcoindConn to return an error.

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

utACK, just one nit 🎉

for {
select {
// Timeout after 30s.
case <-time.After(30 * time.Second):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we extract this into a constant at least or even make it configurable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated to make it a constant

func getBlockHashDuringStartup(
client *rpcclient.Client) (*chainhash.Hash, error) {

errCode := "-28"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: extract to constant above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated to make it a constant

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Missed a crucial thing in my first review. Once that's fixed the PR is ready to go though, very nice fixes!

chain/bitcoind_conn.go Outdated Show resolved Hide resolved
We sometimes see this error in test,
```
--- FAIL: TestBitcoindEvents (7.72s)
    --- FAIL: TestBitcoindEvents/Events_via_RPC_Polling (1.00s)
        bitcoind_events_test.go:480:
            	Error Trace:	/home/runner/work/btcwallet/btcwallet/chain/bitcoind_events_test.go:480
            	            				/home/runner/work/btcwallet/btcwallet/chain/bitcoind_events_test.go:49
            	Error:      	Received unexpected error:
            	            	-28: Loading block index…
            	Test:       	TestBitcoindEvents/Events_via_RPC_Polling
FAIL
```
which can also happen in real life if `bitcoind` is still loading
blocks. This commit adds a retry logic to wait for `bitcoind` to finish
its startup.
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@guggero guggero merged commit e3ff374 into btcsuite:master Oct 17, 2023
3 checks passed
@yyforyongyu yyforyongyu deleted the fix-rescan-race branch October 17, 2023 15:54
buck54321 pushed a commit to buck54321/btcwallet that referenced this pull request Apr 21, 2024
chain+wallet: fix race over `RescanProgress` message
buck54321 pushed a commit to buck54321/btcwallet that referenced this pull request Apr 21, 2024
chain+wallet: fix race over `RescanProgress` message
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.

3 participants