Skip to content

Commit

Permalink
[BugFix] fix stack use after scope when get extra file size (backport #…
Browse files Browse the repository at this point in the history
…39704) (#39741)

Co-authored-by: Yixin Luo <[email protected]>
  • Loading branch information
mergify[bot] and luohaha authored Jan 23, 2024
1 parent fdcaad5 commit 917d9d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions be/src/storage/tablet_updates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2813,7 +2813,7 @@ size_t TabletUpdates::_get_rowset_num_deletes(const Rowset& rowset) {
}

Status TabletUpdates::_get_extra_file_size(int64_t* pindex_size, int64_t* col_size) const {
const std::string tablet_path = _tablet.schema_hash_path();
std::filesystem::path tablet_path(_tablet.schema_hash_path().c_str());
try {
for (const auto& entry : std::filesystem::directory_iterator(tablet_path)) {
if (entry.is_regular_file()) {
Expand All @@ -2832,13 +2832,13 @@ Status TabletUpdates::_get_extra_file_size(int64_t* pindex_size, int64_t* col_si
}
}
} catch (const std::filesystem::filesystem_error& ex) {
std::string err_msg = "Iterate dir " + tablet_path + " Filesystem error: " + ex.what();
std::string err_msg = "Iterate dir " + tablet_path.string() + " Filesystem error: " + ex.what();
return Status::InternalError(err_msg);
} catch (const std::exception& ex) {
std::string err_msg = "Iterate dir " + tablet_path + " Standard error: " + ex.what();
std::string err_msg = "Iterate dir " + tablet_path.string() + " Standard error: " + ex.what();
return Status::InternalError(err_msg);
} catch (...) {
std::string err_msg = "Iterate dir " + tablet_path + " Unknown exception occurred.";
std::string err_msg = "Iterate dir " + tablet_path.string() + " Unknown exception occurred.";
return Status::InternalError(err_msg);
}
return Status::OK();
Expand Down
4 changes: 4 additions & 0 deletions be/test/storage/tablet_updates_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,10 @@ void TabletUpdatesTest::test_writeread(bool enable_persistent_index) {
ASSERT_EQ(N, read_tablet(_tablet, 3));
ASSERT_EQ(N, read_tablet(_tablet, 2));
ASSERT_TRUE(read_with_cancel(_tablet, 4).is_cancelled());

// get tablet info
TTabletInfo tablet_info;
_tablet->updates()->get_tablet_info_extra(&tablet_info);
}

TEST_F(TabletUpdatesTest, writeread) {
Expand Down

0 comments on commit 917d9d3

Please sign in to comment.