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

membuffer: support staging & checkpoint for ART #1465

Merged
merged 5 commits into from
Sep 23, 2024

Conversation

you06
Copy link
Contributor

@you06 you06 commented Sep 19, 2024

ref pingcap/tidb#55287

This PR implements Staging/Release/Cleanup and Checkpoint/RevertToCheckpoint for ART, the behavior is exactly same with RBT.

@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 19, 2024
internal/unionstore/art/art.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Sep 19, 2024
Copy link
Contributor

@ekexium ekexium left a comment

Choose a reason for hiding this comment

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

Could we implement unit tests for multi-level stages? The existing tests only cover single-level scenarios with simple staging and cleanup operations.
The rest LGTM.


func (t *ART) truncate(snap *arena.MemDBCheckpoint) {
panic("unimplemented")
cp := &t.stages[h-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible that len(stages)=0 and h=0? Shall we test that?

Copy link
Contributor Author

@you06 you06 Sep 20, 2024

Choose a reason for hiding this comment

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

h == 0 means staging is not support in TiDB, I think we can just return for this case.

I'll add test for it.

panic("unimplemented")
}
if h > len(t.stages) {
return
Copy link
Contributor

@ekexium ekexium Sep 19, 2024

Choose a reason for hiding this comment

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

Not directly related to this change, but I wonder whether there are such usages...

Copy link
Contributor Author

@you06 you06 Sep 20, 2024

Choose a reason for hiding this comment

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

TiDB always call defer memBuffer.Clean after a group of mutations (even memBuffer.Release is already invoked), so this case is expected and valid.

func addRecord() {
	sh := memBuffer.Staging() // sh == 2, len(stages) == 2
	defer memBuffer.Cleanup(sh) // sh == 2, len(stages) == 1
	...
	memBuffer.Release(sh) // len(stages) == 1 after this call 
}

@@ -392,51 +393,89 @@ func (t *ART) Size() int {
}

func (t *ART) checkpoint() arena.MemDBCheckpoint {
panic("unimplemented")
return t.allocator.vlogAllocator.Checkpoint()
}

func (t *ART) RevertNode(hdr *arena.MemdbVlogHdr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is "RevertVLogEntry" or something similar a more appropriate name? RevertNode looks like we are deleting the node.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rename it to RevertVAddr.

@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 20, 2024
Signed-off-by: you06 <[email protected]>
Copy link

ti-chi-bot bot commented Sep 23, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, ekexium

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 23, 2024
Copy link

ti-chi-bot bot commented Sep 23, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-19 07:49:42.825517305 +0000 UTC m=+1120252.565941229: ☑️ agreed by cfzjywxk.
  • 2024-09-23 03:50:29.023191133 +0000 UTC m=+1451498.763615071: ☑️ agreed by ekexium.

@ti-chi-bot ti-chi-bot bot merged commit 271945f into tikv:master Sep 23, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants