Skip to content

index: Improve robustness of coinstatsindex at restart - #24133

Merged
fanquake merged 2 commits into
bitcoin:masterfrom
fjahr:2022-01-index-fixups
Feb 20, 2022
Merged

index: Improve robustness of coinstatsindex at restart#24133
fanquake merged 2 commits into
bitcoin:masterfrom
fjahr:2022-01-index-fixups

Conversation

@fjahr

@fjahr fjahr commented Jan 23, 2022

Copy link
Copy Markdown
Contributor

This change lets the coinstatsindex fail loudly in case the internal muhash state differs from the last finalized output saved on disk, which would indicate that the muhash state somehow got out of sync. This should generally not happen since both are written to disk in a batch but #24076 seems to indicate that the might still be an issue.

Since #24076 so far can not be reproduced reliably, the issue should not be closed yet. Further investigation and testing needs to be done.

@DrahtBot

DrahtBot commented Jan 23, 2022

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@mzumsande

Copy link
Copy Markdown
Contributor

Concept ACK.

I was just able to locally reproduce the fails reported in #24076 and find the root cause - will report in more detail / possibly PR a fix tomorrow. This additional check makes sense in any case.

@mzumsande

Copy link
Copy Markdown
Contributor

ACK 2fc159b02187a57980c67268cbf70b9998caa488 - I verified that init aborts now for a corrupted index, and doesn't abort for an uncorrupted one.

@Sjors Sjors left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK 2fc159b02187a57980c67268cbf70b9998caa488

Maybe also annotate MuHash3072 m_muhash; in the header to point out a MuHash is initialized to 1 by default.

Comment thread src/index/coinstatsindex.cpp Outdated
@fjahr
fjahr force-pushed the 2022-01-index-fixups branch from 2fc159b to 820c03a Compare February 16, 2022 23:43
@fjahr

fjahr commented Feb 16, 2022

Copy link
Copy Markdown
Contributor Author

Rebased

@Sjors

Sjors commented Feb 17, 2022

Copy link
Copy Markdown
Member

re-ACK 820c03a

1 similar comment
@mzumsande

Copy link
Copy Markdown
Contributor

re-ACK 820c03a

@ryanofsky ryanofsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review ACK 820c03a. Good to catch the error earlier

uint256 out;
m_muhash.Finalize(out);
if (entry.muhash != out) {
return error("%s: Cannot read current %s state; index may be corrupted",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In commit "index: check muhash is in sync on coinstatsindex launch" (820c03a)

I wonder if it would be good to include hashes or other information in this message (transaction total numbers, pindex height) in the error message, especially if this is supposed to help debug an unresolved issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

re: #24133 (comment)

I wonder if it would be good to include hashes or other information in this message

Never mind if #24138 fixes this though

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will address this together with your idea for a unit test here in a small follow-up.

@fanquake
fanquake merged commit 5f44c5c into bitcoin:master Feb 20, 2022
@bitcoin bitcoin locked and limited conversation to collaborators Feb 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants