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

sorter/leveldb(ticdc): replace cleaner with delete range #4632

Merged
merged 11 commits into from
Feb 24, 2022

Conversation

overvenus
Copy link
Member

What problem does this PR solve?

  • Add DeleteRange API to DB
  • Update DB dashboard in grafana
  • Adjust DB block cahce by sorter.max-memory-percentage

Issue Number: ref #4631

Check List

Tests

  • Unit test
  • Integration test

Release note

None

* Add DeleteRange API to DB
* Update DB dashboard in grafana
* Adjust DB block cahce by sorter.max-memory-percentage

Signed-off-by: Neil Shen <[email protected]>
@overvenus overvenus added subject/performance Denotes an issue or pull request is related to replication performance. component/sorter Sorter component. labels Feb 19, 2022
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 19, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • sdojjy
  • zhaoxinyu

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 19, 2022
@codecov-commenter
Copy link

codecov-commenter commented Feb 19, 2022

Codecov Report

Merging #4632 (80f670a) into master (9607554) will decrease coverage by 0.6400%.
The diff coverage is 39.9056%.

Flag Coverage Δ
cdc 59.4522% <45.5122%> (-0.4700%) ⬇️
dm 51.2830% <32.2139%> (-0.7458%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@               Coverage Diff                @@
##             master      #4632        +/-   ##
================================================
- Coverage   55.6402%   55.0001%   -0.6401%     
================================================
  Files           494        512        +18     
  Lines         61283      63638      +2355     
================================================
+ Hits          34098      35001       +903     
- Misses        23750      25154      +1404     
- Partials       3435       3483        +48     

return false
// trySchdeduleCompact try to schedule a compact task.
// Returns true if it schedules compact task successfully.
func (s *CompactScheduler) trySchdeduleCompact(id actor.ID, deleteCount int) bool {
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
func (s *CompactScheduler) trySchdeduleCompact(id actor.ID, deleteCount int) bool {
func (s *CompactScheduler) tryScheduleCompact(id actor.ID, deleteCount int) bool {

@@ -138,6 +138,14 @@ func (ldb *DBActor) close(err error) {
ldb.closedWg.Done()
}

func (ldb *DBActor) trySchdeduleCompact() {
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
func (ldb *DBActor) trySchdeduleCompact() {
func (ldb *DBActor) tryScheduleCompact() {

Signed-off-by: Neil Shen <[email protected]>
if len(task.DeleteReq.Range[0]) != 0 && len(task.DeleteReq.Range[1]) != 0 {
// Force write pending write batch before delete range.
if err := ldb.maybeWrite(true); err != nil {
log.Panic("db error", zap.Error(err))
Copy link
Member

Choose a reason for hiding this comment

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

log tableID?

Signed-off-by: Neil Shen <[email protected]>
Signed-off-by: Neil Shen <[email protected]>
// CleanupTask returns a clean up task that delete sorter's data.
func (ls *Sorter) CleanupTask() actormsg.Message {
return actormsg.SorterMessage(message.NewCleanupTask(ls.uid, ls.tableID))
// CleanupFunc returns a funcation that cleans up sorter's data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// CleanupFunc returns a funcation that cleans up sorter's data.
// CleanupFunc returns a function that cleans up sorter's data.

return func(ctx context.Context) error {
task := message.Task{UID: ls.uid, TableID: ls.tableID}
task.DeleteReq = &message.DeleteRequest{
// We do not set task.Delte.Count, because we don't know
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// We do not set task.Delte.Count, because we don't know
// We do not set task.Delete.Count, because we don't know

@@ -48,8 +48,8 @@ func (c *SorterConfig) ValidateAndAdjust() error {
if c.NumWorkerPoolGoroutine < 1 {
return cerror.ErrIllegalSorterParameter.GenWithStackByArgs("num-workerpool-goroutine should be at least 1, larger than 8 is recommended")
}
if c.MaxMemoryPressure < 0 || c.MaxMemoryPressure > 100 {
return cerror.ErrIllegalSorterParameter.GenWithStackByArgs("max-memory-percentage should be a percentage")
if c.MaxMemoryPressure <= 0 || c.MaxMemoryPressure > 80 {
Copy link
Contributor

@zhaoxinyu zhaoxinyu Feb 23, 2022

Choose a reason for hiding this comment

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

Should this SorterConfig. MaxMemoryPressure field be renamed as MaxMemoryPercentage?

@@ -229,6 +231,20 @@ func (ldb *DBActor) Poll(ctx context.Context, tasks []actormsg.Message) bool {
log.Panic("db error", zap.Error(err))
}
}
if task.DeleteReq != nil {
ldb.deleteCount += task.DeleteReq.Count
Copy link
Member

@sdojjy sdojjy Feb 23, 2022

Choose a reason for hiding this comment

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

for DBActor, task.DeleteReq.Count is always 0? the value is from CleanFunc

Copy link
Member Author

Choose a reason for hiding this comment

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

For now, it's always zero, we will fill Count in later PRs.

log.Panic("db error", zap.Error(err))
}
start, end := task.DeleteReq.Range[0], task.DeleteReq.Range[1]
if err := ldb.db.DeleteRange(start, end); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

is DeleteRange a blocking function call or non-blocking function call?

Signed-off-by: Neil Shen <[email protected]>
Copy link
Member

@sdojjy sdojjy left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 23, 2022
@zhaoxinyu
Copy link
Contributor

/LGTM

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 23, 2022
@overvenus
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: c39e522

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 23, 2022
@overvenus
Copy link
Member Author

/run-integration-test

@overvenus overvenus added the type/enhancement The issue or PR belongs to an enhancement. label Feb 23, 2022
@overvenus
Copy link
Member Author

/run-check-issue-triage-complete

@overvenus
Copy link
Member Author

/merge

@overvenus
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

@overvenus: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit c396df1 into pingcap:master Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/sorter Sorter component. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. subject/performance Denotes an issue or pull request is related to replication performance. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants