-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[improve](mow) merge and remove old version of delete bitmap when cumulative compaction is done #42479
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
Closed
hust-hhb
wants to merge
4
commits into
apache:branch-2.1
from
hust-hhb:process-compaction-delete-bitmap
Closed
[improve](mow) merge and remove old version of delete bitmap when cumulative compaction is done #42479
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| #include "delete_bitmap_action.h" | ||
|
|
||
| #include <rapidjson/document.h> | ||
| #include <rapidjson/encodings.h> | ||
| #include <rapidjson/prettywriter.h> | ||
| #include <rapidjson/rapidjson.h> | ||
| #include <rapidjson/stringbuffer.h> | ||
|
|
||
| #include <chrono> // IWYU pragma: keep | ||
| #include <exception> | ||
| #include <future> | ||
| #include <memory> | ||
| #include <mutex> | ||
| #include <sstream> | ||
| #include <string> | ||
| #include <thread> | ||
| #include <utility> | ||
|
|
||
| #include "common/logging.h" | ||
| #include "common/status.h" | ||
| #include "gutil/strings/substitute.h" | ||
| #include "http/http_channel.h" | ||
| #include "http/http_headers.h" | ||
| #include "http/http_request.h" | ||
| #include "http/http_status.h" | ||
| #include "olap/olap_define.h" | ||
| #include "olap/storage_engine.h" | ||
| #include "olap/tablet_manager.h" | ||
| #include "util/doris_metrics.h" | ||
| #include "util/stopwatch.hpp" | ||
|
|
||
| namespace doris { | ||
| using namespace ErrorCode; | ||
|
|
||
| namespace { | ||
|
|
||
| constexpr std::string_view HEADER_JSON = "application/json"; | ||
|
|
||
| } // namespace | ||
|
|
||
| DeleteBitmapAction::DeleteBitmapAction(DeleteBitmapActionType ctype, ExecEnv* exec_env, | ||
| TPrivilegeHier::type hier, TPrivilegeType::type ptype) | ||
| : HttpHandlerWithAuth(exec_env, hier, ptype), _delete_bitmap_action_type(ctype) {} | ||
|
|
||
| static Status _check_param(HttpRequest* req, uint64_t* tablet_id) { | ||
| const auto& req_tablet_id = req->param(TABLET_ID_KEY); | ||
| if (req_tablet_id.empty()) { | ||
| return Status::InternalError("tablet id is empty!"); | ||
| } | ||
| try { | ||
| *tablet_id = std::stoull(req_tablet_id); | ||
| } catch (const std::exception& e) { | ||
| return Status::InternalError("convert tablet_id failed, {}", e.what()); | ||
| } | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| Status DeleteBitmapAction::_handle_show_delete_bitmap_count(HttpRequest* req, | ||
| std::string* json_result) { | ||
| uint64_t tablet_id = 0; | ||
| // check & retrieve tablet_id from req if it contains | ||
| RETURN_NOT_OK_STATUS_WITH_WARN(_check_param(req, &tablet_id), "check param failed"); | ||
| if (tablet_id == 0) { | ||
| return Status::InternalError("check param failed: missing tablet_id"); | ||
| } | ||
|
|
||
| TabletSharedPtr tablet = StorageEngine::instance()->tablet_manager()->get_tablet(tablet_id); | ||
| if (tablet == nullptr) { | ||
| return Status::NotFound("Tablet not found. tablet_id={}", tablet_id); | ||
| } | ||
|
|
||
| auto count = tablet->tablet_meta()->delete_bitmap().get_delete_bitmap_count(); | ||
| auto cardinality = tablet->tablet_meta()->delete_bitmap().cardinality(); | ||
| auto size = tablet->tablet_meta()->delete_bitmap().get_size(); | ||
|
|
||
| rapidjson::Document root; | ||
| root.SetObject(); | ||
| root.AddMember("delete_bitmap_count", count, root.GetAllocator()); | ||
| root.AddMember("cardinality", cardinality, root.GetAllocator()); | ||
| root.AddMember("size", size, root.GetAllocator()); | ||
|
|
||
| // to json string | ||
| rapidjson::StringBuffer strbuf; | ||
| rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(strbuf); | ||
| root.Accept(writer); | ||
| *json_result = std::string(strbuf.GetString()); | ||
|
|
||
| return Status::OK(); | ||
| } | ||
|
|
||
| void DeleteBitmapAction::handle(HttpRequest* req) { | ||
| req->add_output_header(HttpHeaders::CONTENT_TYPE, HEADER_JSON.data()); | ||
| if (_delete_bitmap_action_type == DeleteBitmapActionType::COUNT_INFO) { | ||
| std::string json_result; | ||
| Status st = _handle_show_delete_bitmap_count(req, &json_result); | ||
| if (!st.ok()) { | ||
| HttpChannel::send_reply(req, HttpStatus::OK, st.to_json()); | ||
| } else { | ||
| HttpChannel::send_reply(req, HttpStatus::OK, json_result); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } // namespace doris |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||
| // Licensed to the Apache Software Foundation (ASF) under one | ||||
| // or more contributor license agreements. See the NOTICE file | ||||
| // distributed with this work for additional information | ||||
| // regarding copyright ownership. The ASF licenses this file | ||||
| // to you under the Apache License, Version 2.0 (the | ||||
| // "License"); you may not use this file except in compliance | ||||
| // with the License. You may obtain a copy of the License at | ||||
| // | ||||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||||
| // | ||||
| // Unless required by applicable law or agreed to in writing, | ||||
| // software distributed under the License is distributed on an | ||||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||
| // KIND, either express or implied. See the License for the | ||||
| // specific language governing permissions and limitations | ||||
| // under the License. | ||||
|
|
||||
| #pragma once | ||||
|
|
||||
| #include <stdint.h> | ||||
|
|
||||
| #include <string> | ||||
|
|
||||
| #include "common/status.h" | ||||
| #include "http/http_handler_with_auth.h" | ||||
| #include "olap/tablet.h" | ||||
|
|
||||
| namespace doris { | ||||
| class HttpRequest; | ||||
|
|
||||
| class ExecEnv; | ||||
|
|
||||
| enum class DeleteBitmapActionType { COUNT_INFO = 1 }; | ||||
|
|
||||
| /// This action is used for viewing the delete bitmap status | ||||
| class DeleteBitmapAction : public HttpHandlerWithAuth { | ||||
| public: | ||||
| DeleteBitmapAction(DeleteBitmapActionType ctype, ExecEnv* exec_env, TPrivilegeHier::type hier, | ||||
| TPrivilegeType::type ptype); | ||||
|
|
||||
| ~DeleteBitmapAction() override = default; | ||||
|
|
||||
| void handle(HttpRequest* req) override; | ||||
|
|
||||
| private: | ||||
| Status _handle_show_delete_bitmap_count(HttpRequest* req, std::string* json_result); | ||||
|
|
||||
| private: | ||||
|
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. warning: redundant access specifier has the same accessibility as the previous access specifier [readability-redundant-access-specifiers]
Suggested change
Additional contextbe/src/http/action/delete_bitmap_action.h:44: previously declared here private:
^ |
||||
| DeleteBitmapActionType _delete_bitmap_action_type; | ||||
| }; | ||||
| } // namespace doris | ||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead [modernize-deprecated-headers]