Skip to content

Commit

Permalink
[enhancement](version_graph) print version graph when -230 happens
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Oct 20, 2023
1 parent a42536e commit df31200
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 6 deletions.
7 changes: 5 additions & 2 deletions be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@ Status Tablet::capture_consistent_versions(const Version& spec_version,
LOG(WARNING) << "tablet:" << tablet_id()
<< ", version already has been merged. spec_version: " << spec_version;
}
std::string json;
get_compaction_status(&json);
LOG(WARNING) << status << '\n' << json;
status = Status::Error<VERSION_ALREADY_MERGED>("missed_versions is empty");
} else {
if (version_path != nullptr) {
Expand Down Expand Up @@ -1380,7 +1383,7 @@ std::vector<RowsetSharedPtr> Tablet::pick_candidate_rowsets_to_build_inverted_in
return candidate_rowsets;
}

std::string Tablet::_get_rowset_info_str(RowsetSharedPtr rowset, bool delete_flag) {
std::string Tablet::_get_rowset_info_str(RowsetSharedPtr rowset, bool delete_flag) const {
const Version& ver = rowset->version();
std::string disk_size = PrettyPrinter::print(
static_cast<uint64_t>(rowset->rowset_meta()->total_disk_size()), TUnit::BYTES);
Expand All @@ -1391,7 +1394,7 @@ std::string Tablet::_get_rowset_info_str(RowsetSharedPtr rowset, bool delete_fla
}

// For http compaction action
void Tablet::get_compaction_status(std::string* json_result) {
void Tablet::get_compaction_status(std::string* json_result) const {
rapidjson::Document root;
root.SetObject();

Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/tablet.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class Tablet final : public BaseTablet {
void generate_tablet_meta_copy_unlocked(TabletMetaSharedPtr new_tablet_meta) const;

// return a json string to show the compaction status of this tablet
void get_compaction_status(std::string* json_result);
void get_compaction_status(std::string* json_result) const;

Status prepare_compaction_and_calculate_permits(CompactionType compaction_type,
TabletSharedPtr tablet, int64_t* permits);
Expand Down Expand Up @@ -613,7 +613,7 @@ class Tablet final : public BaseTablet {
////////////////////////////////////////////////////////////////////////////

void _remove_sentinel_mark_from_delete_bitmap(DeleteBitmapPtr delete_bitmap);
std::string _get_rowset_info_str(RowsetSharedPtr rowset, bool delete_flag);
std::string _get_rowset_info_str(RowsetSharedPtr rowset, bool delete_flag) const;

public:
static const int64_t K_INVALID_CUMULATIVE_POINT = -1;
Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/version_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool TimestampedVersionTracker::_find_path_from_stale_map(
return false;
}

void TimestampedVersionTracker::get_stale_version_path_json_doc(rapidjson::Document& path_arr) {
void TimestampedVersionTracker::get_stale_version_path_json_doc(rapidjson::Document& path_arr) const {
auto path_arr_iter = _stale_version_path_map.begin();

// Do loop version path.
Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/version_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class TimestampedVersionTracker {

/// Get json document of _stale_version_path_map. Fill the path_id and version_path
/// list in the document. The parameter path arr is used as return variable.
void get_stale_version_path_json_doc(rapidjson::Document& path_arr);
void get_stale_version_path_json_doc(rapidjson::Document& path_arr) const;

// Return proportion of orphan vertex in VersionGraph's _version_graph.
// If a vertex is no longer the starting point of any edge, then this vertex is defined as orphan vertex
Expand Down
60 changes: 60 additions & 0 deletions be/test/olap/version_graph_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// 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 "olap/version_graph.h"

#include <gmock/gmock-actions.h>
#include <gmock/gmock-matchers.h>
#include <gtest/gtest-message.h>
#include <gtest/gtest-test-part.h>

#include <filesystem>

#include "common/status.h"
#include "gtest/gtest_pred_impl.h"
#include "testutil/test_util.h"

using ::testing::_;
using ::testing::Return;
using ::testing::SetArgPointee;
using std::string;

namespace doris {

class VersionGraphTest : public testing::Test {
public:
virtual void SetUp() {}

virtual void TearDown() {}
};

TEST_F(VersionGraphTest, consistency_version) {
TimestampedVersionTracker version_tracker;
Version version(0, 1);
version_tracker.add_version(version);
for (int i = 1; i <= 518; i++) {
Version version(i, i);
version_tracker.add_version(version);
}

Version spec_version(0, 507);
std::vector<Version> version_graph;
auto status = version_tracker.capture_consistent_versions(spec_version, &version_graph);
EXPECT_TRUE(status.OK());
}

} // namespace doris

0 comments on commit df31200

Please sign in to comment.