Skip to content

Commit

Permalink
fix bad disk
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Sep 20, 2023
1 parent 6f56748 commit aaf949f
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 6 deletions.
2 changes: 1 addition & 1 deletion be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ DEFINE_mInt32(tablet_lookup_cache_clean_interval, "30");
DEFINE_mInt32(disk_stat_monitor_interval, "5");
DEFINE_mInt32(unused_rowset_monitor_interval, "30");
DEFINE_String(storage_root_path, "${DORIS_HOME}/storage");
DEFINE_String(broken_storage_path, "");
DEFINE_mString(broken_storage_path, "");

// Config is used to check incompatible old format hdr_ format
// whether doris uses strict way. When config is true, process will log fatal
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/rowset/beta_rowset_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Status BetaRowsetReader::_init_iterator() {

Status BetaRowsetReader::next_block(vectorized::Block* block) {
SCOPED_RAW_TIMER(&_stats->block_fetch_ns);
_init_iterator_once();
RETURN_IF_ERROR(_init_iterator_once());
if (_empty) {
return Status::Error<END_OF_FILE>("BetaRowsetReader is empty");
}
Expand All @@ -316,7 +316,7 @@ Status BetaRowsetReader::next_block(vectorized::Block* block) {

Status BetaRowsetReader::next_block_view(vectorized::BlockView* block_view) {
SCOPED_RAW_TIMER(&_stats->block_fetch_ns);
_init_iterator_once();
RETURN_IF_ERROR(_init_iterator_once());
do {
auto s = _iterator->next_block_view(block_view);
if (!s.ok()) {
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/rowset/beta_rowset_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class BetaRowsetReader : public RowsetReader {
RowsetReaderSharedPtr clone() override;

private:
Status _init_iterator_once();
Status _init_iterator();
[[nodiscard]] Status _init_iterator_once();
[[nodiscard]] Status _init_iterator();
bool _should_push_down_value_predicates() const;
bool _is_merge_iterator() const {
return _read_context->need_ordered_result &&
Expand Down
4 changes: 3 additions & 1 deletion be/src/olap/storage_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,9 @@ Status StorageEngine::_persist_broken_paths() {
}

if (config_value.length() > 0) {
return config::set_config("broken_store_path", config_value);
auto st = config::set_config("broken_storage_path", config_value, true);
LOG(INFO) << "persist broken_store_path " << config_value << st;
return st;
}

return Status::OK();
Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/storage_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ class StorageEngine {
bool add_broken_path(std::string path);
bool remove_broken_path(std::string path);

std::set<string> get_broken_paths() { return _broken_paths; }

private:
// Instance should be inited from `static open()`
// MUST NOT be called in other circumstances.
Expand Down
1 change: 1 addition & 0 deletions be/src/service/doris_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ int main(int argc, char** argv) {
if (broken_paths.count(it->path) > 0) {
if (doris::config::ignore_broken_disk) {
LOG(WARNING) << "ignore broken disk, path = " << it->path;
it = paths.erase(it);
} else {
LOG(FATAL) << "a broken disk is found " << it->path;
exit(-1);
Expand Down
87 changes: 87 additions & 0 deletions be/test/olap/storage_engine_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// 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/storage_engine.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 StorageEngineTest : public testing::Test {
public:
virtual void SetUp() {
EngineOptions options;

_storage_engine.reset(new StorageEngine(options));
}

virtual void TearDown() {}

std::unique_ptr<StorageEngine> _storage_engine;
};


TEST_F(StorageEngineTest, TestBrokenDisk) {
std::string path = config::custom_config_dir + "/be_custom.conf";
std::error_code ec;
{
_storage_engine->add_broken_path("broken_path1");
EXPECT_EQ(std::filesystem::exists(path, ec), true);
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path1"), 1);
EXPECT_EQ(config::broken_storage_path, "broken_path1;");
}

{
_storage_engine->add_broken_path("broken_path2");
EXPECT_EQ(std::filesystem::exists(path, ec), true);
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path1"), 1);
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path2"), 1);
EXPECT_EQ(config::broken_storage_path, "broken_path1;broken_path2;");
}

{
_storage_engine->add_broken_path("broken_path2");
EXPECT_EQ(std::filesystem::exists(path, ec), true);
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path1"), 1);
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path2"), 1);
EXPECT_EQ(config::broken_storage_path, "broken_path1;broken_path2;");
}

{
_storage_engine->remove_broken_path("broken_path2");
EXPECT_EQ(std::filesystem::exists(path, ec), true);
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path1"), 1);
EXPECT_EQ(_storage_engine->get_broken_paths().count("broken_path2"), 0);
EXPECT_EQ(config::broken_storage_path, "broken_path1;");
}
}

}

0 comments on commit aaf949f

Please sign in to comment.