Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
[Refactor] Execute 'pick rowsets' before applying for permits for a compaction task#4891
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -29,6 +29,13 @@ BaseCompaction::BaseCompaction(TabletSharedPtr tablet, const std::string& label, | ||
| BaseCompaction::~BaseCompaction() {} | ||
| OLAPStatus BaseCompaction::compact() { | ||
| RETURN_NOT_OK(prepare_compact()); | ||
| RETURN_NOT_OK(execute_compact()); | ||
| return OLAP_SUCCESS; | ||
| } | ||
| OLAPStatus BaseCompaction::prepare_compact() { | ||
| if (!_tablet->init_succeeded()) { | ||
| return OLAP_ERR_INPUT_PARAMETER_ERROR; | ||
| } | ||
| @@ -44,9 +51,28 @@ OLAPStatus BaseCompaction::compact() { | ||
| RETURN_NOT_OK(pick_rowsets_to_compact()); | ||
| TRACE("rowsets picked"); | ||
| TRACE_COUNTER_INCREMENT("input_rowsets_count", _input_rowsets.size()); | ||
| _tablet->set_clone_occurred(false); | ||
| return OLAP_SUCCESS; | ||
| } | ||
| OLAPStatus BaseCompaction::execute_compact() { | ||
| MutexLock lock(_tablet->get_base_lock(), TRY_LOCK); | ||
| if (!lock.own_lock()) { | ||
| LOG(WARNING) << "another base compaction is running. tablet=" << _tablet->full_name(); | ||
| return OLAP_ERR_BE_TRY_BE_LOCK_ERROR; | ||
| } | ||
| TRACE("got base compaction lock"); | ||
| // Clone task may happen after compaction task is submitted to thread pool, and rowsets picked | ||
| // for compaction may change. In this case, current compaction task should not be executed. | ||
| if (_tablet->get_clone_occurred()) { | ||
| _tablet->set_clone_occurred(false); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment to explain why setting clone occurred here. ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. | ||
| return OLAP_ERR_BE_CLONE_OCCURRED; | ||
| } | ||
| // 2. do base compaction, merge rowsets | ||
| int64_t permits = _tablet->calc_compaction_score(CompactionType::BASE_COMPACTION); | ||
| int64_t permits = get_compaction_permits(); | ||
| RETURN_NOT_OK(do_compaction(permits)); | ||
| TRACE("compaction finished"); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who will call
BaseCompaction::compact()now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BaseCompaction::compact()will still be called in "be/src/http/action/compaction_action.cpp" for/api/compaction/run.