get tablet with timeout

This commit is contained in:
hiddenbomb
2022-11-22 09:05:42 +00:00
committed by wangzelin.wzl
parent 16fc3d31e2
commit ed83a15813
3 changed files with 14 additions and 9 deletions

View File

@ -32,7 +32,7 @@ public:
static const int64_t DEFAULT_ITERATOR_TABLET_ID_CNT = 128;
static const int64_t BUCKET_LOCK_BUCKET_CNT = 10243L;
static const int64_t TABLET_ID_SET_BUCKET_CNT = 10243L;
static const int64_t MAX_GET_TABLET_DURATION_US = 1 * 1000 * 1000; // 1s
static const int64_t DEFAULT_GET_TABLET_DURATION_US = 1 * 1000 * 1000; // 1s
static const int64_t FINAL_TX_ID = 0;
};

View File

@ -1358,7 +1358,10 @@ int ObTabletCreateDeleteHelper::tx_end_remove_tablets(
return ret;
}
int ObTabletCreateDeleteHelper::get_tablet(const ObTabletMapKey &key, ObTabletHandle &handle)
int ObTabletCreateDeleteHelper::get_tablet(
const ObTabletMapKey &key,
ObTabletHandle &handle,
const int64_t timeout_us)
{
int ret = OB_SUCCESS;
static const int64_t SLEEP_TIME_US = 10;
@ -1376,9 +1379,9 @@ int ObTabletCreateDeleteHelper::get_tablet(const ObTabletMapKey &key, ObTabletHa
LOG_DEBUG("tablet does not exist", K(ret), K(key));
} else if (OB_ITEM_NOT_SETTED == ret) {
current_time = ObTimeUtility::current_time();
if (current_time - begin_time > ObTabletCommon::MAX_GET_TABLET_DURATION_US) {
LOG_WARN("continuously meet item not set error", K(ret), K(begin_time), K(current_time));
break;
if (current_time - begin_time > timeout_us) {
ret = OB_TABLET_NOT_EXIST;
LOG_WARN("continuously meet item not set error", K(ret), K(begin_time), K(current_time), K(timeout_us));
} else {
ret = OB_SUCCESS;
ob_usleep(SLEEP_TIME_US);
@ -1406,11 +1409,11 @@ int ObTabletCreateDeleteHelper::check_and_get_tablet(
ObTimeGuard time_guard(__func__, 5 * 1000 * 1000); // 5s
// TODO(bowen.gbw): optimize this logic, refactor ObTabletStatusChecker
if (OB_FAIL(get_tablet(key, tablet_handle))) {
if (OB_FAIL(get_tablet(key, tablet_handle, timeout_us))) {
if (OB_TABLET_NOT_EXIST == ret) {
LOG_DEBUG("tablet does not exist", K(ret), K(key));
LOG_DEBUG("tablet does not exist", K(ret), K(key), K(timeout_us));
} else {
LOG_WARN("failed to get tablet", K(ret), K(key));
LOG_WARN("failed to get tablet", K(ret), K(key), K(timeout_us));
}
} else if (FALSE_IT(time_guard.click("DirectGet"))) {
} else if (tablet_handle.get_obj()->is_ls_inner_tablet()) {

View File

@ -21,6 +21,7 @@
#include "storage/memtable/ob_memtable.h"
#include "storage/meta_mem/ob_tablet_handle.h"
#include "storage/tablet/ob_tablet_status.h"
#include "storage/tablet/ob_tablet_common.h"
namespace oceanbase
{
@ -116,7 +117,8 @@ public:
public:
static int get_tablet(
const ObTabletMapKey &key,
ObTabletHandle &handle);
ObTabletHandle &handle,
const int64_t timeout_us = ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US);
static int check_and_get_tablet(
const ObTabletMapKey &key,
ObTabletHandle &handle,