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

Get the page size from the second meta page if the first one is invalid #294

Merged
merged 2 commits into from
Dec 28, 2022
Merged

Get the page size from the second meta page if the first one is invalid #294

merged 2 commits into from
Dec 28, 2022

Conversation

ahrtr
Copy link
Member

@ahrtr ahrtr commented Oct 18, 2021

The current implementation only gets the pageSize from the first meta page when opening a db file. We should try to get the page size from the second meta page when the first one is invalid. There is a comment "// TODO: scan for next page" as well.

One more method getPageSize() is added into db.go in this PR. It tries to get the page size from the first meta page, and return the page size if everything is OK. Otherwise, it tries to get the page size from the second meta page, and return the page size if it's successful.

If it fails to read the page size from both meta pages, but can read either page, then it assumes the page size is the same as the OS or the one given in options. Otherwise, it returns ErrInvalid.

This PR is also the very first step to fix etcd/issues/13406

@ahrtr
Copy link
Member Author

ahrtr commented Oct 18, 2021

@ptabor Could you please help to review this PR? Thanks.

db.go Outdated Show resolved Hide resolved
@ahrtr ahrtr requested a review from ptabor October 18, 2021 11:34
db_test.go Show resolved Hide resolved
@ahrtr
Copy link
Member Author

ahrtr commented Jan 30, 2022

Resolved all the comments, PTAL, thanks.

@tmm1
Copy link
Contributor

tmm1 commented Oct 27, 2022

Any blockers here?

@ahrtr
Copy link
Member Author

ahrtr commented Oct 28, 2022

This PR should be ready to go. There are two meta pages, and anyone of them might be corrupted for whatever reason. It isn't correct to always to read/trust the first meta page, so it is exactly what this PR tries to resolve. @ptabor

ahrtr and others added 2 commits December 28, 2022 16:52
Signed-off-by: Benjamin Wang <wachao@vmware.com>
Signed-off-by: Benjamin Wang <wachao@vmware.com>
@ahrtr ahrtr merged commit 7b6c235 into etcd-io:master Dec 28, 2022
@ahrtr ahrtr added this to the 1.3.7 milestone Dec 28, 2022
@ahrtr ahrtr mentioned this pull request Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

SIGBUS on startup in etcd-3.5.0 after filesystem rollback
3 participants