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

@ -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(); }