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

add tablet erros when close_wait return error #9619

Merged
merged 9 commits into from
May 22, 2022
11 changes: 1 addition & 10 deletions be/src/olap/delta_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ Status DeltaWriter::close() {
}

Status DeltaWriter::close_wait(google::protobuf::RepeatedPtrField<PTabletInfo>* tablet_vec,
google::protobuf::RepeatedPtrField<PTabletError>* tablet_errors,
bool is_broken) {
std::lock_guard<std::mutex> l(_lock);
DCHECK(_is_init)
Expand All @@ -322,15 +321,7 @@ Status DeltaWriter::close_wait(google::protobuf::RepeatedPtrField<PTabletInfo>*
}

// return error if previous flush failed
Status s = _flush_token->wait();
if (!s.ok()) {
#ifndef BE_TEST
PTabletError* tablet_error = tablet_errors->Add();
tablet_error->set_tablet_id(_tablet->tablet_id());
tablet_error->set_msg(s.get_error_msg());
#endif
return s;
}
RETURN_NOT_OK(_flush_token->wait());

// use rowset meta manager to save meta
_cur_rowset = _rowset_writer->build();
Expand Down
3 changes: 1 addition & 2 deletions be/src/olap/delta_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class DeltaWriter {
// wait for all memtables to be flushed.
// mem_consumption() should be 0 after this function returns.
Status close_wait(google::protobuf::RepeatedPtrField<PTabletInfo>* tablet_vec,
google::protobuf::RepeatedPtrField<PTabletError>* tablet_errors,
bool is_broken);

// abandon current memtable and wait for all pending-flushing memtables to be destructed.
Expand Down Expand Up @@ -133,4 +132,4 @@ class DeltaWriter {
int64_t _mem_consumption_snapshot = 0;
};

} // namespace doris
} // namespace doris
11 changes: 9 additions & 2 deletions be/src/runtime/tablets_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,16 @@ Status TabletsChannel::close(int sender_id, int64_t backend_id, bool* finished,
for (auto writer : need_wait_writers) {
// close may return failed, but no need to handle it here.
// tablet_vec will only contains success tablet, and then let FE judge it.
writer->close_wait(
tablet_vec, tablet_errors,
Status st = writer->close_wait(
tablet_vec,
(_broken_tablets.find(writer->tablet_id()) != _broken_tablets.end()));
if (!st.ok()) {
#ifndef BE_TEST
PTabletError* tablet_error = tablet_errors->Add();
Copy link
Contributor

Choose a reason for hiding this comment

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

change the code to a function. and also move

    if (!is_broken) {
        PTabletInfo* tablet_info = tablet_vec->Add();
        tablet_info->set_tablet_id(_tablet->tablet_id());
        tablet_info->set_schema_hash(_tablet->schema_hash());
    }
#endif

to this funciton to remove unless #ifndef

tablet_error->set_tablet_id(writer->tablet_id());
tablet_error->set_msg(st.get_error_msg());
#endif
}
}
}
return Status::OK();
Expand Down
12 changes: 6 additions & 6 deletions be/test/olap/delta_writer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ TEST_F(TestDeltaWriter, open) {
EXPECT_NE(delta_writer, nullptr);
res = delta_writer->close();
EXPECT_EQ(Status::OK(), res);
res = delta_writer->close_wait(nullptr, nullptr, false);
res = delta_writer->close_wait(nullptr, false);
EXPECT_EQ(Status::OK(), res);
SAFE_DELETE(delta_writer);

Expand All @@ -376,7 +376,7 @@ TEST_F(TestDeltaWriter, open) {
EXPECT_NE(delta_writer, nullptr);
res = delta_writer->close();
EXPECT_EQ(Status::OK(), res);
res = delta_writer->close_wait(nullptr, nullptr, false);
res = delta_writer->close_wait(nullptr, false);
EXPECT_EQ(Status::OK(), res);
SAFE_DELETE(delta_writer);

Expand Down Expand Up @@ -475,7 +475,7 @@ TEST_F(TestDeltaWriter, write) {

res = delta_writer->close();
EXPECT_EQ(Status::OK(), res);
res = delta_writer->close_wait(nullptr, nullptr, false);
res = delta_writer->close_wait(nullptr, false);
EXPECT_EQ(Status::OK(), res);

// publish version success
Expand Down Expand Up @@ -609,7 +609,7 @@ TEST_F(TestDeltaWriter, vec_write) {

res = delta_writer->close();
ASSERT_TRUE(res.ok());
res = delta_writer->close_wait(nullptr, nullptr, false);
res = delta_writer->close_wait(nullptr, false);
ASSERT_TRUE(res.ok());

// publish version success
Expand Down Expand Up @@ -687,7 +687,7 @@ TEST_F(TestDeltaWriter, sequence_col) {

res = delta_writer->close();
EXPECT_EQ(Status::OK(), res);
res = delta_writer->close_wait(nullptr, nullptr, false);
res = delta_writer->close_wait(nullptr, false);
EXPECT_EQ(Status::OK(), res);

// publish version success
Expand Down Expand Up @@ -772,7 +772,7 @@ TEST_F(TestDeltaWriter, vec_sequence_col) {

res = delta_writer->close();
ASSERT_TRUE(res.ok());
res = delta_writer->close_wait(nullptr, nullptr, false);
res = delta_writer->close_wait(nullptr, false);
ASSERT_TRUE(res.ok());

// publish version success
Expand Down
2 changes: 1 addition & 1 deletion be/test/olap/engine_storage_migration_task_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ TEST_F(TestEngineStorageMigrationTask, write_and_migration) {

res = delta_writer->close();
EXPECT_EQ(Status::OK(), res);
res = delta_writer->close_wait(nullptr, nullptr, false);
res = delta_writer->close_wait(nullptr, false);
EXPECT_EQ(Status::OK(), res);

// publish version success
Expand Down