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

add PreLoadFreelist to support loading free pages in readonly mode #381

Merged
merged 3 commits into from
Jan 11, 2023
Merged

add PreLoadFreelist to support loading free pages in readonly mode #381

merged 3 commits into from
Jan 11, 2023

Conversation

ahrtr
Copy link
Member

@ahrtr ahrtr commented Jan 11, 2023

Fixes #372

Signed-off-by: Benjamin Wang wachao@vmware.com

tx.go Outdated
@@ -652,6 +652,9 @@ func (tx *Tx) Page(id int) (*PageInfo, error) {
return nil, nil
}

// Force loading free list if opened in ReadOnly mode.
tx.db.loadFreelist()
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the PR.

Everything looks good to me apart this line. As we discussed in #371 , I find it a risk and indeterminism if within a blocking (exclusive lock) transaction we perform lazy initialization with cost of O(db) size.

I would prefer the call to exit with error that Page(is) is not supported in RO transaction without pre-loaded free pages.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @ptabor for the feedback.

In that case, we need to process

bbolt/tx.go

Lines 418 to 419 in b654ce9

// Force loading free list if opened in ReadOnly mode.
tx.db.loadFreelist()
in the same way. But it might be a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it (db.loadFreelist()) can stay in check:

  • it's already O(all pages) operation to perform check
  • it's goal it's explicitly to fail in case of any problems is the storage-layer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Please take a look at the third commit d2fae80

thx

Signed-off-by: Benjamin Wang <wachao@vmware.com>
Signed-off-by: Benjamin Wang <wachao@vmware.com>
Signed-off-by: Benjamin Wang <wachao@vmware.com>
Copy link
Contributor

@ptabor ptabor left a comment

Choose a reason for hiding this comment

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

Thank you. Please merge when the tests are green.

@ahrtr
Copy link
Member Author

ahrtr commented Jan 11, 2023

Thank you. Please merge when the tests are green.

Thank you for the review

@ahrtr ahrtr merged commit ad85400 into etcd-io:master Jan 11, 2023
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.

bbolt pages should distinguish reachable (vs. free) pages
2 participants