Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions be/src/olap/data_dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ void DataDir::perform_path_gc_by_rowsetid() {
RowsetId rowset_id = -1;
bool is_rowset_file = _tablet_manager->get_rowset_id_from_path(path, &rowset_id);
if (is_rowset_file) {
TabletSharedPtr tablet = _tablet_manager->get_tablet(tablet_id, schema_hash, true);
TabletSharedPtr tablet = _tablet_manager->get_tablet(tablet_id, schema_hash);
if (tablet != nullptr) {
bool valid = tablet->check_rowset_id(rowset_id);
if (!valid) {
Expand All @@ -968,13 +968,9 @@ void DataDir::perform_path_gc_by_rowsetid() {
// and the rowsetid is not in committed rowsets
// then delete the path.
if (rowset_id < tablet->initial_end_rowset_id()
&& !StorageEngine::instance()->check_rowset_id_in_unused_rowsets(rowset_id)) {
RowsetMetaSharedPtr rowset_meta = nullptr;
OLAPStatus status = RowsetMetaManager::get_rowset_meta(
_meta, tablet->tablet_uid(), rowset_id, rowset_meta);
if (status == OLAP_ERR_META_KEY_NOT_FOUND) {
_process_garbage_path(path);
}
&& !StorageEngine::instance()->check_rowset_id_in_unused_rowsets(rowset_id)
&& !RowsetMetaManager::check_rowset_meta(_meta, tablet->tablet_uid(), rowset_id)) {
_process_garbage_path(path);
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions be/src/olap/rowset/rowset_meta_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ namespace doris {

const std::string ROWSET_PREFIX = "rst_";

bool RowsetMetaManager::check_rowset_meta(OlapMeta* meta, TabletUid tablet_uid, int64_t rowset_id) {
std::string key = ROWSET_PREFIX + tablet_uid.to_string() + "_" + std::to_string(rowset_id);
std::string value;
OLAPStatus s = meta->get(META_COLUMN_FAMILY_INDEX, key, &value);
if (s != OLAP_SUCCESS) {
return false;
}
return true;
}

OLAPStatus RowsetMetaManager::get_rowset_meta(OlapMeta* meta, TabletUid tablet_uid, int64_t rowset_id, RowsetMetaSharedPtr rowset_meta) {
std::string key = ROWSET_PREFIX + tablet_uid.to_string() + "_" + std::to_string(rowset_id);
std::string value;
Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/rowset/rowset_meta_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace doris {
// Helper class for managing rowset meta of one root path.
class RowsetMetaManager {
public:
static bool check_rowset_meta(OlapMeta* meta, TabletUid tablet_uid, int64_t rowset_id);

static OLAPStatus get_rowset_meta(OlapMeta* meta, TabletUid tablet_uid, int64_t rowset_id, RowsetMetaSharedPtr rowset_meta);

static OLAPStatus get_json_rowset_meta(OlapMeta* meta, TabletUid tablet_uid, int64_t rowset_id, std::string* json_rowset_meta);
Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/tablet_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ TabletSharedPtr TabletManager::_get_tablet(TTabletId tablet_id, SchemaHash schem
tablet = _get_tablet_with_no_lock(tablet_id, schema_hash);
if (tablet == nullptr && include_deleted) {
for (auto& deleted_tablet : _shutdown_tablets) {
CHECK(deleted_tablet != nullptr) << "deleted tablet in nullptr";
if (deleted_tablet->tablet_id() == tablet_id && deleted_tablet->schema_hash() == schema_hash) {
tablet = deleted_tablet;
break;
Expand Down Expand Up @@ -1350,6 +1351,7 @@ TabletSharedPtr TabletManager::_get_tablet_with_no_lock(TTabletId tablet_id, Sch
tablet_map_t::iterator it = _tablet_map.find(tablet_id);
if (it != _tablet_map.end()) {
for (TabletSharedPtr tablet : it->second.table_arr) {
CHECK(tablet != nullptr) << "tablet is nullptr:" << tablet;
if (tablet->equal(tablet_id, schema_hash)) {
VLOG(3) << "get tablet success. tablet_id=" << tablet_id
<< ", schema_hash=" << schema_hash;
Expand Down
3 changes: 3 additions & 0 deletions be/test/olap/rowset/rowset_meta_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ TEST_F(RowsetMetaManagerTest, TestSaveAndGetAndRemove) {
ASSERT_EQ(rowset_meta.rowset_id(), rowset_id);
OLAPStatus status = RowsetMetaManager::save(_meta, _tablet_uid, rowset_id, &rowset_meta);
ASSERT_TRUE(status == OLAP_SUCCESS);
ASSERT_TRUE(RowsetMetaManager::check_rowset_meta(_meta, _tablet_uid, rowset_id));
std::string json_rowset_meta_read;
status = RowsetMetaManager::get_json_rowset_meta(_meta, _tablet_uid, rowset_id, &json_rowset_meta_read);
ASSERT_TRUE(status == OLAP_SUCCESS);
ASSERT_EQ(_json_rowset_meta, json_rowset_meta_read);
status = RowsetMetaManager::remove(_meta, _tablet_uid, rowset_id);
ASSERT_TRUE(status == OLAP_SUCCESS);
ASSERT_FALSE(RowsetMetaManager::check_rowset_meta(_meta, _tablet_uid, rowset_id));
RowsetMetaSharedPtr rowset_meta_read(new RowsetMeta());
status = RowsetMetaManager::get_rowset_meta(_meta, _tablet_uid, rowset_id, rowset_meta_read);
ASSERT_TRUE(status != OLAP_SUCCESS);
Expand All @@ -95,6 +97,7 @@ TEST_F(RowsetMetaManagerTest, TestLoad) {
uint64_t rowset_id = 10000;
OLAPStatus status = RowsetMetaManager::load_json_rowset_meta(_meta, rowset_meta_path);
ASSERT_TRUE(status == OLAP_SUCCESS);
ASSERT_TRUE(RowsetMetaManager::check_rowset_meta(_meta, _tablet_uid, rowset_id));
std::string json_rowset_meta_read;
status = RowsetMetaManager::get_json_rowset_meta(_meta, _tablet_uid, rowset_id, &json_rowset_meta_read);
ASSERT_TRUE(status == OLAP_SUCCESS);
Expand Down