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

issue_3170: drop space after stop all AdminTaskJobs #3406

Merged
merged 2 commits into from
Dec 15, 2021

Conversation

Nivras
Copy link
Contributor

@Nivras Nivras commented Dec 3, 2021

What type of PR is this?

  • bug
  • feature
  • enhancement

What does this PR do?

  • When Storage use MetaClient Heartbeat find out there is a space have been dropped, before remove the space, cancel all AdminTasks in this space and wait them stopped first.

  • mark AdminTask status in memory, use std::atomic, when the AdminTask in task, and status is QUEUE, we will set QUEUE to CANCELED, and do not run this task.

Which issue(s)/PR(s) this PR relates to?

issue: #3170

Special notes for your reviewer, ex. impact of this fix, etc:

This PR is trying to stop all the AdminTasks(RebuildTagIndex, RebuildEdgeIndex, Stats) before storage delete a space. AdminTaskManager support the interface to cancel a job, but this interface only set a flag (canceled_) to true, when the job pending in the taskQueue, it won't be canceled until the job going to run.

So this PR add a atomic enum to mark the job's status, the status is QUEUE, RUNNING, CANCELED, FINISNED, and when we canceled a job, first if the job's status is QUEUE, change status to CANCELED, and return. else we only change the flag(canceled_), because this job is RUNNING or FINISHED.

When TaskManager take a job in taskQueue, it will check the job's status, and if the status is CANCELED, TaskManager will clean this job without running it. if the job's status is QUEUE, taskManger change it to RUNNING and run it. And a RUNNING job will be canceled if flag(canceled_) is true.

Additional context:

Checklist:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatible (If it is incompatible, please describe it and add corresponding label.)
  • Need to cherry-pick (If need to cherry-pick to some branches, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to reflect in release notes and how to describe:

                                                            `

@Nivras Nivras added wip Solution: work in progress do not review PR: not ready for the code review yet ready-for-testing PR: ready for the CI test and removed wip Solution: work in progress labels Dec 3, 2021
@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2021

Codecov Report

Merging #3406 (07d5bc2) into master (ab73b4c) will decrease coverage by 0.02%.
The diff coverage is 56.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3406      +/-   ##
==========================================
- Coverage   85.23%   85.20%   -0.03%     
==========================================
  Files        1277     1304      +27     
  Lines      119088   121306    +2218     
==========================================
+ Hits       101502   103360    +1858     
- Misses      17586    17946     +360     
Impacted Files Coverage Δ
src/storage/admin/RebuildIndexTask.h 16.66% <0.00%> (-33.34%) ⬇️
src/storage/admin/StatsTask.h 28.57% <0.00%> (-38.10%) ⬇️
src/storage/admin/RebuildIndexTask.cpp 74.34% <25.00%> (-0.83%) ⬇️
src/storage/admin/StatsTask.cpp 81.63% <33.33%> (-2.33%) ⬇️
src/storage/admin/RebuildEdgeIndexTask.cpp 71.71% <50.00%> (ø)
src/storage/admin/RebuildTagIndexTask.cpp 70.78% <50.00%> (ø)
src/storage/admin/AdminTaskManager.h 77.77% <60.00%> (-22.23%) ⬇️
src/storage/admin/AdminTaskManager.cpp 79.84% <72.72%> (-0.68%) ⬇️
src/storage/admin/AdminTask.h 85.36% <80.00%> (-0.75%) ⬇️
src/clients/meta/MetaClient.h 94.23% <83.33%> (-1.43%) ⬇️
... and 182 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab73b4c...07d5bc2. Read the comment docs.

@Nivras Nivras removed the do not review PR: not ready for the code review yet label Dec 6, 2021
@Nivras Nivras requested a review from pengweisong December 6, 2021 10:43
src/clients/meta/MetaClient.cpp Outdated Show resolved Hide resolved
src/storage/admin/AdminTaskManager.cpp Outdated Show resolved Hide resolved
src/clients/meta/MetaClient.h Outdated Show resolved Hide resolved
src/storage/admin/RebuildIndexTask.h Outdated Show resolved Hide resolved
critical27
critical27 previously approved these changes Dec 13, 2021
Copy link
Contributor

@critical27 critical27 left a comment

Choose a reason for hiding this comment

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

LGTM now, good job

@liuyu85cn
Copy link
Contributor

so now, drop space may stuck in console for a while?

@Nivras
Copy link
Contributor Author

Nivras commented Dec 14, 2021

so now, drop space may stuck in console for a while?

No, console execute "drop space" will delete space infos in meta, and return. This PR only changed the storage, storage will drop the space when it found this space is not in heartbeat info from meta.

@liuyu85cn
Copy link
Contributor

liuyu85cn commented Dec 15, 2021

Mmmm, functional, this PR looks good to me. Also, I suggest not to modify meta client.
(why meta client need to know anything about task manager?)

I think it's better to open a add (un)register function in kvstore,
which can accept any function to callback before it delete one space.
WDYT?

pengweisong
pengweisong previously approved these changes Dec 15, 2021
Copy link
Contributor

@pengweisong pengweisong left a comment

Choose a reason for hiding this comment

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

LGTM; Perfect job!

@Nivras
Copy link
Contributor Author

Nivras commented Dec 15, 2021

Mmmm, functional, this PR looks good to me. Also, I suggest not to modify meta client. (why meta client need to know anything about task manager?)

I think it's better to open a add (un)register function in kvstore, which can accept any function to callback before it delete one space.

Thanks~ meta client should not know the taskManger, I will change this PR for this.

liuyu85cn
liuyu85cn previously approved these changes Dec 15, 2021
Copy link
Contributor

@liuyu85cn liuyu85cn left a comment

Choose a reason for hiding this comment

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

good job, LGTM

@Nivras Nivras requested a review from liuyu85cn December 15, 2021 08:48
@critical27 critical27 merged commit 9fbe164 into vesoft-inc:master Dec 15, 2021
meta::cpp2::AdminCmd cmdType() { return ctx_.cmd_; }

public:
std::atomic<size_t> unFinishedSubTask_;
SubTaskQueue subtasks_;
std::atomic<bool> running_{false};
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a enum is better than bool.


protected:
StorageEnv* env_;
TaskContext ctx_;
std::atomic<nebula::cpp2::ErrorCode> rc_{nebula::cpp2::ErrorCode::SUCCEEDED};
std::atomic<bool> canceled_{false};
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants