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

Dedupe Reload/NoSyncReload, prefer empty instead of nil init #804

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

tjungblu
Copy link
Contributor

@tjungblu tjungblu commented Aug 5, 2024

Reload and NoSyncReload have duplicated code, this unifies both for later refactoring.

This PR is split from #786, where the tests found differences on reloading and nil/empty initializations. Added some more clarifications in godocs for certain panic behavior and expected returns on the interface.

@@ -65,7 +66,7 @@ type Interface interface {
// NoSyncReload reads the freelist from Pgids and filters out pending items.
NoSyncReload(pgIds common.Pgids)

// freePageIds returns the IDs of all free pages.
// freePageIds returns the IDs of all free pages. No free pages returns an empty slice.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// freePageIds returns the IDs of all free pages. No free pages returns an empty slice.
// freePageIds returns the IDs of all free pages. Returns an empty slice if no free pages are available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied

Free(txId common.Txid, p *common.Page)

// Freed returns whether a given page is in the free list.
Freed(pgId common.Pgid) bool

// Rollback removes the pages from a given pending tx.
// Should always be followed by Reload or NoSyncReload from last freelist state.
Copy link
Member

Choose a reason for hiding this comment

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

Such restriction isn't friendly to users. We should consider to get rid of such restriction in following PRs. We can discuss this separately.

Suggested change
// Should always be followed by Reload or NoSyncReload from last freelist state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied

Reload and NoSyncReload have duplicated code, this unifies both
for later refactoring.

This PR is split from etcd-io#786, where the tests found differences on reloading
and nil/empty initializations. Added some more clarifications in godocs
for certain panic behavior and expected returns on the interface.

Signed-off-by: Thomas Jungblut <[email protected]>
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahrtr, tjungblu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ahrtr ahrtr merged commit f777377 into etcd-io:main Aug 6, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants