Retry set tablet id when 4013

This commit is contained in:
JiahuaChen 2023-01-06 14:45:46 +00:00 committed by ob-robot
parent c8c9318ac5
commit 915e19cc3d
4 changed files with 66 additions and 17 deletions

View File

@ -23,6 +23,7 @@
#include "storage/tablelock/ob_lock_memtable.h"
#include "storage/tablet/ob_tablet_table_store_flag.h"
#include "storage/tablet/ob_tablet_create_delete_helper.h"
#include "storage/tablet/ob_tablet_slog_helper.h"
#include "storage/tablet/ob_tablet_status.h"
#include "mtlenv/mock_tenant_module_env.h"
#include "storage/test_dml_common.h"
@ -933,6 +934,7 @@ TEST_F(TestTenantMetaMemMgr, test_get_tablet_with_allocator)
MockObLogHandler log_handler;
ObFreezer freezer;
ObTableSchema table_schema;
ObTabletCreateSSTableParam param;
prepare_data_schema(table_schema);
ret = freezer.init(&ls);
@ -940,7 +942,38 @@ TEST_F(TestTenantMetaMemMgr, test_get_tablet_with_allocator)
ret = t3m_.acquire_sstable(table_handle);
ASSERT_EQ(common::OB_SUCCESS, ret);
table_handle.get_table()->set_table_type(ObITable::TableType::MAJOR_SSTABLE);
const int64_t multi_version_col_cnt = ObMultiVersionRowkeyHelpper::get_extra_rowkey_col_cnt();
param.table_key_.table_type_ = ObITable::TableType::MAJOR_SSTABLE;
param.table_key_.tablet_id_ = tablet_id;
param.table_key_.version_range_.base_version_ = ObVersionRange::MIN_VERSION;
param.table_key_.version_range_.snapshot_version_ = 1;
param.schema_version_ = table_schema.get_schema_version();
param.create_snapshot_version_ = 0;
param.progressive_merge_round_ = table_schema.get_progressive_merge_round();
param.progressive_merge_step_ = 0;
param.table_mode_ = table_schema.get_table_mode_struct();
param.index_type_ = table_schema.get_index_type();
param.rowkey_column_cnt_ = table_schema.get_rowkey_column_num()
+ ObMultiVersionRowkeyHelpper::get_extra_rowkey_col_cnt();
param.root_block_addr_.set_none_addr();
param.data_block_macro_meta_addr_.set_none_addr();
param.root_row_store_type_ = ObRowStoreType::FLAT_ROW_STORE;
param.data_index_tree_height_ = 0;
param.index_blocks_cnt_ = 0;
param.data_blocks_cnt_ = 0;
param.micro_block_cnt_ = 0;
param.use_old_macro_block_count_ = 0;
param.column_cnt_ = table_schema.get_column_count() + multi_version_col_cnt;
param.data_checksum_ = 0;
param.occupy_size_ = 0;
param.ddl_scn_.set_min();
param.filled_tx_scn_.set_min();
param.original_size_ = 0;
param.compressor_type_ = ObCompressorType::NONE_COMPRESSOR;
param.encrypt_id_ = 0;
param.master_key_id_ = 0;
ASSERT_EQ(OB_SUCCESS, ObSSTableMergeRes::fill_column_checksum_for_empty_major(param.column_cnt_, param.column_checksums_));
ASSERT_EQ(OB_SUCCESS, static_cast<ObSSTable *>(table_handle.get_table())->init(param, &t3m_.get_tenant_allocator()));
share::SCN create_scn;
create_scn.convert_from_ts(ObTimeUtility::fast_current_time());
@ -955,16 +988,13 @@ TEST_F(TestTenantMetaMemMgr, test_get_tablet_with_allocator)
ASSERT_EQ(1, tablet->get_ref());
ObMetaDiskAddr addr;
addr.first_id_ = 1;
addr.second_id_ = 2;
addr.offset_ = 0;
addr.size_ = 4096;
addr.type_ = ObMetaDiskAddr::DiskType::BLOCK;
ret = ObTabletSlogHelper::write_create_tablet_slog(handle, addr);
ASSERT_EQ(common::OB_SUCCESS, ret);
ret = t3m_.compare_and_swap_tablet(key, addr, handle, handle);
ASSERT_EQ(common::OB_SUCCESS, ret);
ASSERT_EQ(1, t3m_.tablet_map_.map_.size());
ASSERT_EQ(1, t3m_.tablet_map_.map_.size());
ASSERT_EQ(1, t3m_.tablet_pool_.inner_used_num_);
handle.reset();
ASSERT_EQ(1, tablet->get_ref());
@ -974,7 +1004,8 @@ TEST_F(TestTenantMetaMemMgr, test_get_tablet_with_allocator)
ASSERT_EQ(0, t3m_.tablet_pool_.inner_used_num_);
common::ObArenaAllocator allocator;
ASSERT_EQ(common::OB_NOT_SUPPORTED, t3m_.get_tablet_with_allocator(WashTabletPriority::WTP_HIGH, key, allocator, handle));
ASSERT_EQ(common::OB_SUCCESS, t3m_.get_tablet_with_allocator(WashTabletPriority::WTP_HIGH, key, allocator, handle));
ASSERT_TRUE(handle.is_valid());
ret = t3m_.tablet_map_.erase(key);
ASSERT_EQ(common::OB_SUCCESS, ret);

View File

@ -102,10 +102,10 @@ int ObLSTabletService::init(
} else if (OB_ISNULL(ls) || OB_ISNULL(rs_reporter)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid args", K(ret), K(ls), KP(rs_reporter));
} else if (OB_FAIL(tablet_id_set_.init(ObTabletCommon::BUCKET_LOCK_BUCKET_CNT))) {
} else if (OB_FAIL(tablet_id_set_.init(ObTabletCommon::BUCKET_LOCK_BUCKET_CNT, MTL_ID()))) {
LOG_WARN("fail to init tablet id set", K(ret));
} else if (OB_FAIL(bucket_lock_.init(ObTabletCommon::BUCKET_LOCK_BUCKET_CNT,
ObLatchIds::TABLET_BUCKET_LOCK))) {
ObLatchIds::TABLET_BUCKET_LOCK, "TabletSvrBucket", MTL_ID()))) {
LOG_WARN("failed to init bucket lock", K(ret));
} else if (OB_FAIL(set_allow_to_read_(ls))) {
LOG_WARN("failed to set allow to read", K(ret));
@ -894,8 +894,24 @@ int ObLSTabletService::refresh_tablet_addr(
if (OB_UNLIKELY(!new_addr.is_valid())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid args", K(ret), K(new_addr));
} else if (OB_FAIL(tablet_id_set_.set(tablet_id))) {
LOG_WARN("fail to set tablet id set", K(ret), K(tablet_id));
}
while (OB_SUCC(ret)) {
ret = tablet_id_set_.set(tablet_id);
if (OB_SUCC(ret)) {
break;
} else if (OB_ALLOCATE_MEMORY_FAILED == ret) {
usleep(100 * 1000);
if (REACH_COUNT_INTERVAL(100)) {
LOG_ERROR("no memory for tablet id set, retry", K(ret), K(tablet_id));
}
ret = OB_SUCCESS;
} else {
LOG_WARN("fail to set tablet id set", K(ret), K(tablet_id));
}
}
if (OB_FAIL(ret)) {
} else if (OB_FAIL(t3m->compare_and_swap_tablet(key, new_addr, tablet_handle, tablet_handle))) {
LOG_WARN("failed to add tablet to meta mem mgr", K(ret), K(key), K(new_addr), K(tablet_handle));
}

View File

@ -33,15 +33,17 @@ ObTabletIDSet::~ObTabletIDSet()
destroy();
}
int ObTabletIDSet::init(const uint64_t bucket_lock_bucket_cnt)
int ObTabletIDSet::init(const uint64_t bucket_lock_bucket_cnt, const uint64_t tenant_id)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(is_inited_)) {
ret = OB_INIT_TWICE;
LOG_WARN("init twice", K(ret), K_(is_inited));
} else if (OB_FAIL(id_set_.create(ObTabletCommon::TABLET_ID_SET_BUCKET_CNT))) {
} else if (OB_FAIL(id_set_.create(ObTabletCommon::TABLET_ID_SET_BUCKET_CNT, "TabletIDSetBkt",
"TabletIDSetNode", tenant_id))) {
LOG_WARN("fail to create tablet id set", K(ret));
} else if (OB_FAIL(bucket_lock_.init(bucket_lock_bucket_cnt))) {
} else if (OB_FAIL(bucket_lock_.init(bucket_lock_bucket_cnt, ObLatchIds::TABLET_BUCKET_LOCK,
"TabletIDSetBkt", tenant_id))) {
LOG_WARN("fail to init bucket lock", K(ret), K(bucket_lock_bucket_cnt));
} else {
is_inited_ = true;
@ -71,4 +73,4 @@ void ObTabletIDSet::destroy()
is_inited_ = false;
}
} // namespace storage
} // namespace oceanbase
} // namespace oceanbase

View File

@ -31,7 +31,7 @@ public:
ObTabletIDSet(const ObTabletIDSet&) = delete;
ObTabletIDSet &operator=(const ObTabletIDSet&) = delete;
public:
int init(const uint64_t bucket_lock_bucket_cnt);
int init(const uint64_t bucket_lock_bucket_cnt, const uint64_t tenant_id);
int set(const common::ObTabletID &tablet_id);
int erase(const common::ObTabletID &tablet_id);
int clear() { return id_set_.clear(); }