[CP] add timeout param for estimation related interfaces

This commit is contained in:
hiddenbomb
2023-11-22 03:10:58 +00:00
committed by ob-robot
parent d0b5d9f336
commit 4531a5b37d
13 changed files with 106 additions and 54 deletions

View File

@ -391,23 +391,25 @@ public:
virtual int get_multi_ranges_cost( virtual int get_multi_ranges_cost(
const share::ObLSID &ls_id, const share::ObLSID &ls_id,
const ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const ObIArray<ObStoreRange> &ranges, const int64_t timeout_us,
const common::ObIArray<ObStoreRange> &ranges,
int64_t &total_size) int64_t &total_size)
{ {
UNUSEDx(ls_id, tablet_id, ranges, total_size); UNUSEDx(ls_id, tablet_id, timeout_us, ranges, total_size);
return OB_SUCCESS; return OB_SUCCESS;
} }
virtual int split_multi_ranges( virtual int split_multi_ranges(
const share::ObLSID &ls_id, const share::ObLSID &ls_id,
const ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const ObIArray<ObStoreRange> &ranges, const int64_t timeout_us,
const common::ObIArray<ObStoreRange> &ranges,
const int64_t expected_task_count, const int64_t expected_task_count,
ObIAllocator &allocator, ObIAllocator &allocator,
ObArrayArray<ObStoreRange> &multi_range_split_array) ObArrayArray<ObStoreRange> &multi_range_split_array)
{ {
UNUSEDx(ls_id, tablet_id, ranges, expected_task_count, allocator, multi_range_split_array); UNUSEDx(ls_id, tablet_id, timeout_us, ranges, expected_task_count, allocator, multi_range_split_array);
return OB_SUCCESS; return OB_SUCCESS;
} }
}; };

View File

@ -49,7 +49,7 @@ OB_SERIALIZE_MEMBER(ObDASEmptyCtDef);
OB_SERIALIZE_MEMBER(ObDASEmptyRtDef); OB_SERIALIZE_MEMBER(ObDASEmptyRtDef);
ObDASSplitRangesOp::ObDASSplitRangesOp(ObIAllocator &op_alloc) ObDASSplitRangesOp::ObDASSplitRangesOp(ObIAllocator &op_alloc)
: ObDASSimpleOp(op_alloc), expected_task_count_(0) {} : ObDASSimpleOp(op_alloc), expected_task_count_(0), timeout_us_(0) {}
int ObDASSplitRangesOp::open_op() int ObDASSplitRangesOp::open_op()
{ {
@ -57,6 +57,7 @@ int ObDASSplitRangesOp::open_op()
ObAccessService *access_service = MTL(ObAccessService *); ObAccessService *access_service = MTL(ObAccessService *);
if (OB_FAIL(access_service->split_multi_ranges(ls_id_, if (OB_FAIL(access_service->split_multi_ranges(ls_id_,
tablet_id_, tablet_id_,
timeout_us_,
ranges_, ranges_,
expected_task_count_, expected_task_count_,
op_alloc_, op_alloc_,
@ -97,10 +98,11 @@ int ObDASSplitRangesOp::decode_task_result(ObIDASTaskResult *task_result)
return ret; return ret;
} }
int ObDASSplitRangesOp::init(const common::ObIArray<ObStoreRange> &ranges, int64_t expected_task_count) int ObDASSplitRangesOp::init(const common::ObIArray<ObStoreRange> &ranges, int64_t expected_task_count, const int64_t timeout_us)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
expected_task_count_ = expected_task_count; expected_task_count_ = expected_task_count;
timeout_us_ = timeout_us;
if (OB_FAIL(ranges_.assign(ranges))) { if (OB_FAIL(ranges_.assign(ranges))) {
LOG_WARN("failed to assign ranges array", K(ret)); LOG_WARN("failed to assign ranges array", K(ret));
} }
@ -109,7 +111,8 @@ int ObDASSplitRangesOp::init(const common::ObIArray<ObStoreRange> &ranges, int64
OB_SERIALIZE_MEMBER((ObDASSplitRangesOp, ObIDASTaskOp), OB_SERIALIZE_MEMBER((ObDASSplitRangesOp, ObIDASTaskOp),
ranges_, ranges_,
expected_task_count_); expected_task_count_,
timeout_us_);
ObDASSplitRangesResult::ObDASSplitRangesResult() ObDASSplitRangesResult::ObDASSplitRangesResult()
: ObIDASTaskResult(), result_alloc_(nullptr) {} : ObIDASTaskResult(), result_alloc_(nullptr) {}
@ -196,7 +199,7 @@ OB_DEF_DESERIALIZE(ObDASSplitRangesResult)
} }
ObDASRangesCostOp::ObDASRangesCostOp(common::ObIAllocator &op_alloc) ObDASRangesCostOp::ObDASRangesCostOp(common::ObIAllocator &op_alloc)
: ObDASSimpleOp(op_alloc), total_size_(0) {} : ObDASSimpleOp(op_alloc), total_size_(0), timeout_us_(0) {}
int ObDASRangesCostOp::open_op() int ObDASRangesCostOp::open_op()
{ {
@ -204,6 +207,7 @@ int ObDASRangesCostOp::open_op()
ObAccessService *access_service = MTL(ObAccessService *); ObAccessService *access_service = MTL(ObAccessService *);
if (OB_FAIL(access_service->get_multi_ranges_cost(ls_id_, if (OB_FAIL(access_service->get_multi_ranges_cost(ls_id_,
tablet_id_, tablet_id_,
timeout_us_,
ranges_, ranges_,
total_size_))) { total_size_))) {
LOG_WARN("failed to get multi ranges cost", K(ret), K_(ls_id), K_(tablet_id)); LOG_WARN("failed to get multi ranges cost", K(ret), K_(ls_id), K_(tablet_id));
@ -240,18 +244,20 @@ int ObDASRangesCostOp::decode_task_result(ObIDASTaskResult *task_result)
return ret; return ret;
} }
int ObDASRangesCostOp::init(const common::ObIArray<ObStoreRange> &ranges) int ObDASRangesCostOp::init(const common::ObIArray<ObStoreRange> &ranges, const int64_t timeout_us)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (OB_FAIL(ranges_.assign(ranges))) { if (OB_FAIL(ranges_.assign(ranges))) {
LOG_WARN("failed to assign ranges array", K(ret)); LOG_WARN("failed to assign ranges array", K(ret));
} }
timeout_us_ = timeout_us;
return ret; return ret;
} }
OB_SERIALIZE_MEMBER((ObDASRangesCostOp, ObIDASTaskOp), OB_SERIALIZE_MEMBER((ObDASRangesCostOp, ObIDASTaskOp),
ranges_, ranges_,
total_size_); total_size_,
timeout_us_);
ObDASRangesCostResult::ObDASRangesCostResult() ObDASRangesCostResult::ObDASRangesCostResult()
: ObIDASTaskResult(), total_size_(0) {} : ObIDASTaskResult(), total_size_(0) {}
@ -291,7 +297,13 @@ int ObDASSimpleUtils::split_multi_ranges(ObExecContext &exec_ctx,
} else { } else {
split_ranges_op = static_cast<ObDASSplitRangesOp*>(task_op); split_ranges_op = static_cast<ObDASSplitRangesOp*>(task_op);
split_ranges_op->set_can_part_retry(GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_2_1_0); split_ranges_op->set_can_part_retry(GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_2_1_0);
if (OB_FAIL(split_ranges_op->init(ranges, expected_task_count))) { ObPhysicalPlanCtx *plan_ctx = nullptr;
if (OB_ISNULL(plan_ctx = exec_ctx.get_physical_plan_ctx())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected nullptr", K(ret));
} else if (OB_FAIL(split_ranges_op->init(ranges,
expected_task_count,
plan_ctx->get_timeout_timestamp() - ObTimeUtility::current_time()))) {
LOG_WARN("failed to init das split ranges op", K(ret)); LOG_WARN("failed to init das split ranges op", K(ret));
} else if (OB_FAIL(das_ref.execute_all_task())) { } else if (OB_FAIL(das_ref.execute_all_task())) {
LOG_WARN("execute das split_multi_ranges task failed", K(ret)); LOG_WARN("execute das split_multi_ranges task failed", K(ret));
@ -340,7 +352,11 @@ int ObDASSimpleUtils::get_multi_ranges_cost(ObExecContext &exec_ctx,
} else { } else {
ranges_cost_op = static_cast<ObDASRangesCostOp*>(task_op); ranges_cost_op = static_cast<ObDASRangesCostOp*>(task_op);
ranges_cost_op->set_can_part_retry(GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_2_1_0); ranges_cost_op->set_can_part_retry(GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_2_1_0);
if (OB_FAIL(ranges_cost_op->init(ranges))) { ObPhysicalPlanCtx *plan_ctx = nullptr;
if (OB_ISNULL(plan_ctx = exec_ctx.get_physical_plan_ctx())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected nullptr", K(ret));
} else if (OB_FAIL(ranges_cost_op->init(ranges, plan_ctx->get_timeout_timestamp() - ObTimeUtility::current_time()))) {
LOG_WARN("failed to init das ranges cost op", K(ret)); LOG_WARN("failed to init das ranges cost op", K(ret));
} else if (OB_FAIL(das_ref.execute_all_task())) { } else if (OB_FAIL(das_ref.execute_all_task())) {
LOG_WARN("execute das get_multi_ranges_cost task failed", K(ret)); LOG_WARN("execute das get_multi_ranges_cost task failed", K(ret));

View File

@ -63,7 +63,7 @@ public:
virtual int open_op() override; virtual int open_op() override;
virtual int fill_task_result(ObIDASTaskResult &task_result, bool &has_more, int64_t &memory_limit) override; virtual int fill_task_result(ObIDASTaskResult &task_result, bool &has_more, int64_t &memory_limit) override;
virtual int decode_task_result(ObIDASTaskResult *task_result) override; virtual int decode_task_result(ObIDASTaskResult *task_result) override;
int init(const common::ObIArray<ObStoreRange> &ranges, int64_t expected_task_count); int init(const common::ObIArray<ObStoreRange> &ranges, int64_t expected_task_count, const int64_t timeout_us);
const ObArrayArray<ObStoreRange> &get_split_array() { return multi_range_split_array_; } const ObArrayArray<ObStoreRange> &get_split_array() { return multi_range_split_array_; }
INHERIT_TO_STRING_KV("parent", ObDASSimpleOp, INHERIT_TO_STRING_KV("parent", ObDASSimpleOp,
K_(ranges), K_(ranges),
@ -73,6 +73,7 @@ private:
common::ObSEArray<ObStoreRange, 16> ranges_; common::ObSEArray<ObStoreRange, 16> ranges_;
int64_t expected_task_count_; int64_t expected_task_count_;
ObArrayArray<ObStoreRange> multi_range_split_array_; ObArrayArray<ObStoreRange> multi_range_split_array_;
int64_t timeout_us_;
}; };
class ObDASSplitRangesResult : public ObIDASTaskResult class ObDASSplitRangesResult : public ObIDASTaskResult
@ -102,7 +103,7 @@ public:
virtual int open_op() override; virtual int open_op() override;
virtual int fill_task_result(ObIDASTaskResult &task_result, bool &has_more, int64_t &memory_limit) override; virtual int fill_task_result(ObIDASTaskResult &task_result, bool &has_more, int64_t &memory_limit) override;
virtual int decode_task_result(ObIDASTaskResult *task_result) override; virtual int decode_task_result(ObIDASTaskResult *task_result) override;
int init(const common::ObIArray<ObStoreRange> &ranges); int init(const common::ObIArray<ObStoreRange> &ranges, const int64_t timeout_us);
int64_t get_total_size() const { return total_size_; } int64_t get_total_size() const { return total_size_; }
INHERIT_TO_STRING_KV("parent", ObDASSimpleOp, INHERIT_TO_STRING_KV("parent", ObDASSimpleOp,
K_(ranges), K_(ranges),
@ -110,6 +111,7 @@ public:
private: private:
common::ObSEArray<ObStoreRange, 16> ranges_; common::ObSEArray<ObStoreRange, 16> ranges_;
int64_t total_size_; int64_t total_size_;
int64_t timeout_us_;
}; };
class ObDASRangesCostResult : public ObIDASTaskResult class ObDASRangesCostResult : public ObIDASTaskResult

View File

@ -12,6 +12,7 @@
#define USING_LOG_PREFIX SQL_OPT #define USING_LOG_PREFIX SQL_OPT
#include "ob_storage_estimator.h" #include "ob_storage_estimator.h"
#include "lib/worker.h"
#include "storage/tx_storage/ob_access_service.h" #include "storage/tx_storage/ob_access_service.h"
#include "storage/access/ob_table_scan_range.h" #include "storage/access/ob_table_scan_range.h"
#include "share/ob_simple_batch.h" #include "share/ob_simple_batch.h"
@ -126,6 +127,7 @@ int ObStorageEstimator::storage_estimate_partition_batch_rowcount(
int64_t rc_logical = 0; int64_t rc_logical = 0;
int64_t rc_physical = 0; int64_t rc_physical = 0;
ObArenaAllocator allocator; ObArenaAllocator allocator;
const int64_t timeout_us = THIS_WORKER.get_timeout_remain();
ObAccessService *access_service = NULL; ObAccessService *access_service = NULL;
storage::ObTableScanRange table_scan_range; storage::ObTableScanRange table_scan_range;
if (OB_ISNULL(access_service = MTL(ObAccessService *))) { if (OB_ISNULL(access_service = MTL(ObAccessService *))) {
@ -135,13 +137,14 @@ int ObStorageEstimator::storage_estimate_partition_batch_rowcount(
STORAGE_LOG(WARN, "Failed to init table scan range", K(ret), K(batch)); STORAGE_LOG(WARN, "Failed to init table scan range", K(ret), K(batch));
} else if (OB_FAIL(access_service->estimate_row_count(table_scan_param, } else if (OB_FAIL(access_service->estimate_row_count(table_scan_param,
table_scan_range, table_scan_range,
timeout_us,
est_records, est_records,
rc_logical, rc_logical,
rc_physical))) { rc_physical))) {
LOG_TRACE("OPT:[STORAGE EST FAILED, USE STAT EST]", "storage_ret", ret); LOG_TRACE("OPT:[STORAGE EST FAILED, USE STAT EST]", "storage_ret", ret);
} else { } else {
LOG_TRACE("storage estimate row count result", K(rc_logical), K(rc_physical), LOG_TRACE("storage estimate row count result", K(rc_logical), K(rc_physical),
K(table_scan_param), K(table_scan_range), K(ret)); K(table_scan_param), K(table_scan_range), K(timeout_us), K(ret));
logical_row_count = rc_logical < 0 ? 1.0 : static_cast<double>(rc_logical); logical_row_count = rc_logical < 0 ? 1.0 : static_cast<double>(rc_logical);
physical_row_count = rc_physical < 0 ? 1.0 : static_cast<double>(rc_physical); physical_row_count = rc_physical < 0 ? 1.0 : static_cast<double>(rc_physical);
} }
@ -172,18 +175,20 @@ int ObStorageEstimator::storage_estimate_block_count_and_row_count(
} else { } else {
const uint64_t tenant_id = arg.tenant_id_; const uint64_t tenant_id = arg.tenant_id_;
MTL_SWITCH(tenant_id) { MTL_SWITCH(tenant_id) {
const int64_t timeout_us = THIS_WORKER.get_timeout_remain();
ObAccessService *access_service = NULL; ObAccessService *access_service = NULL;
if (OB_ISNULL(access_service = MTL(ObAccessService *))) { if (OB_ISNULL(access_service = MTL(ObAccessService *))) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(ret), K(access_service)); LOG_WARN("get unexpected null", K(ret), K(access_service));
} else if (OB_FAIL(access_service->estimate_block_count_and_row_count(arg.ls_id_, } else if (OB_FAIL(access_service->estimate_block_count_and_row_count(arg.ls_id_,
arg.tablet_id_, arg.tablet_id_,
macro_block_count, timeout_us,
micro_block_count, macro_block_count,
sstable_row_count, micro_block_count,
memtable_row_count, sstable_row_count,
cg_macro_cnt_arr, memtable_row_count,
cg_micro_cnt_arr))) { cg_macro_cnt_arr,
cg_micro_cnt_arr))) {
LOG_WARN("OPT:[STORAGE EST BLOCK COUNT FAILED]", "storage_ret", ret); LOG_WARN("OPT:[STORAGE EST BLOCK COUNT FAILED]", "storage_ret", ret);
} else if (OB_UNLIKELY(cg_count != 0 && } else if (OB_UNLIKELY(cg_count != 0 &&
(cg_macro_cnt_arr.count() > cg_count (cg_macro_cnt_arr.count() > cg_count

View File

@ -1245,6 +1245,7 @@ int ObMultipleMerge::refresh_tablet_iter()
LOG_WARN("ls is null", K(ret), K(ls_handle)); LOG_WARN("ls is null", K(ret), K(ls_handle));
} else if (OB_FAIL(ls_handle.get_ls()->get_tablet_svr()->get_read_tables( } else if (OB_FAIL(ls_handle.get_ls()->get_tablet_svr()->get_read_tables(
tablet_id, tablet_id,
ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US,
get_table_param_->sample_info_.is_no_sample() get_table_param_->sample_info_.is_no_sample()
? access_ctx_->store_ctx_->mvcc_acc_ctx_.get_snapshot_version().get_val_for_tx() ? access_ctx_->store_ctx_->mvcc_acc_ctx_.get_snapshot_version().get_val_for_tx()
: INT64_MAX, : INT64_MAX,

View File

@ -172,6 +172,7 @@ int ObUniqueIndexChecker::scan_table_with_column_checksum(
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("error unexpected, ls must not be nullptr", K(ret)); LOG_WARN("error unexpected, ls must not be nullptr", K(ret));
} else if (OB_FAIL(ls_handle.get_ls()->get_tablet_svr()->get_read_tables(tablet_id_, } else if (OB_FAIL(ls_handle.get_ls()->get_tablet_svr()->get_read_tables(tablet_id_,
ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US,
param.snapshot_version_, param.snapshot_version_,
iterator, allow_not_ready))) { iterator, allow_not_ready))) {
if (OB_REPLICA_NOT_READABLE == ret) { if (OB_REPLICA_NOT_READABLE == ret) {

View File

@ -197,6 +197,7 @@ int ObComplementDataParam::split_task_ranges(
if (OB_FAIL(ranges.push_back(range))) { if (OB_FAIL(ranges.push_back(range))) {
LOG_WARN("push back range failed", K(ret)); LOG_WARN("push back range failed", K(ret));
} else if (OB_FAIL(tablet_service->get_multi_ranges_cost(tablet_id, } else if (OB_FAIL(tablet_service->get_multi_ranges_cost(tablet_id,
ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US,
ranges, ranges,
total_size))) { total_size))) {
LOG_WARN("get multi ranges cost failed", K(ret)); LOG_WARN("get multi ranges cost failed", K(ret));
@ -209,6 +210,7 @@ int ObComplementDataParam::split_task_ranges(
expected_task_count))) { expected_task_count))) {
LOG_WARN("compute total task count failed", K(ret)); LOG_WARN("compute total task count failed", K(ret));
} else if (OB_FAIL(tablet_service->split_multi_ranges(tablet_id, } else if (OB_FAIL(tablet_service->split_multi_ranges(tablet_id,
ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US,
ranges, ranges,
min(min(max(expected_task_count, 1), hint_parallelism), ObMacroDataSeq::MAX_PARALLEL_IDX + 1), min(min(max(expected_task_count, 1), hint_parallelism), ObMacroDataSeq::MAX_PARALLEL_IDX + 1),
allocator_, allocator_,
@ -955,7 +957,8 @@ int ObComplementWriteTask::do_local_scan()
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("ls is null", K(ret), K(ls_handle)); LOG_WARN("ls is null", K(ret), K(ls_handle));
} else if (OB_FAIL(ls_handle.get_ls()->get_tablet_svr()->get_read_tables(param_->orig_tablet_id_, } else if (OB_FAIL(ls_handle.get_ls()->get_tablet_svr()->get_read_tables(param_->orig_tablet_id_,
param_->snapshot_version_, iterator, allow_not_ready))) { ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US,
param_->snapshot_version_, iterator, allow_not_ready))) {
if (OB_REPLICA_NOT_READABLE == ret) { if (OB_REPLICA_NOT_READABLE == ret) {
ret = OB_EAGAIN; ret = OB_EAGAIN;
} else { } else {

View File

@ -2262,6 +2262,7 @@ int ObLSTabletService::check_read_info_same(const AllowToReadMgr::AllowToReadInf
int ObLSTabletService::get_read_tables( int ObLSTabletService::get_read_tables(
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
const int64_t snapshot_version, const int64_t snapshot_version,
ObTabletTableIterator &iter, ObTabletTableIterator &iter,
const bool allow_no_ready_read) const bool allow_no_ready_read)
@ -2285,17 +2286,16 @@ int ObLSTabletService::get_read_tables(
LOG_WARN("ls is not allow to read", K(ret), KPC(ls_)); LOG_WARN("ls is not allow to read", K(ret), KPC(ls_));
} else if (FALSE_IT(key.ls_id_ = ls_->get_ls_id())) { } else if (FALSE_IT(key.ls_id_ = ls_->get_ls_id())) {
} else if (OB_FAIL(ObTabletCreateDeleteHelper::check_and_get_tablet(key, handle, } else if (OB_FAIL(ObTabletCreateDeleteHelper::check_and_get_tablet(key, handle,
ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US, timeout_us,
ObMDSGetTabletMode::READ_READABLE_COMMITED, ObMDSGetTabletMode::READ_READABLE_COMMITED,
snapshot_version))) { snapshot_version))) {
if (OB_TABLET_NOT_EXIST != ret) { if (OB_TABLET_NOT_EXIST != ret) {
LOG_WARN("fail to check and get tablet", K(ret), K(key), K(snapshot_version)); LOG_WARN("fail to check and get tablet", K(ret), K(key), K(timeout_us), K(snapshot_version));
} }
} else if (OB_UNLIKELY(!handle.is_valid())) { } else if (OB_UNLIKELY(!handle.is_valid())) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected error, invalid tablet handle", K(ret), K(handle)); LOG_WARN("unexpected error, invalid tablet handle", K(ret), K(handle));
} else if (OB_FAIL(handle.get_obj()->get_read_tables(snapshot_version, iter, } else if (OB_FAIL(handle.get_obj()->get_read_tables(snapshot_version, iter, allow_no_ready_read))) {
allow_no_ready_read))) {
LOG_WARN("fail to get read tables", K(ret), K(handle), K(tablet_id), K(snapshot_version), LOG_WARN("fail to get read tables", K(ret), K(handle), K(tablet_id), K(snapshot_version),
K(iter), K(allow_no_ready_read)); K(iter), K(allow_no_ready_read));
} else { } else {
@ -5609,7 +5609,8 @@ int ObLSTabletService::get_ls_min_end_scn(
} }
int ObLSTabletService::get_multi_ranges_cost( int ObLSTabletService::get_multi_ranges_cost(
const ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
const common::ObIArray<common::ObStoreRange> &ranges, const common::ObIArray<common::ObStoreRange> &ranges,
int64_t &total_size) int64_t &total_size)
{ {
@ -5620,7 +5621,7 @@ int ObLSTabletService::get_multi_ranges_cost(
if (IS_NOT_INIT) { if (IS_NOT_INIT) {
ret = OB_NOT_INIT; ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret)); LOG_WARN("not inited", K(ret));
} else if (OB_FAIL(get_read_tables(tablet_id, max_snapshot_version, iter))) { } else if (OB_FAIL(get_read_tables(tablet_id, timeout_us, max_snapshot_version, iter))) {
LOG_WARN("fail to get all read tables", K(ret), K(tablet_id), K(max_snapshot_version)); LOG_WARN("fail to get all read tables", K(ret), K(tablet_id), K(max_snapshot_version));
} else { } else {
ObPartitionMultiRangeSpliter spliter; ObPartitionMultiRangeSpliter spliter;
@ -5636,7 +5637,8 @@ int ObLSTabletService::get_multi_ranges_cost(
} }
int ObLSTabletService::split_multi_ranges( int ObLSTabletService::split_multi_ranges(
const ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
const ObIArray<ObStoreRange> &ranges, const ObIArray<ObStoreRange> &ranges,
const int64_t expected_task_count, const int64_t expected_task_count,
common::ObIAllocator &allocator, common::ObIAllocator &allocator,
@ -5649,7 +5651,7 @@ int ObLSTabletService::split_multi_ranges(
if (IS_NOT_INIT) { if (IS_NOT_INIT) {
ret = OB_NOT_INIT; ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret)); LOG_WARN("not inited", K(ret));
} else if (OB_FAIL(get_read_tables(tablet_id, max_snapshot_version, iter))) { } else if (OB_FAIL(get_read_tables(tablet_id, timeout_us, max_snapshot_version, iter))) {
LOG_WARN("fail to get all read tables", K(ret), K(tablet_id), K(max_snapshot_version)); LOG_WARN("fail to get all read tables", K(ret), K(tablet_id), K(max_snapshot_version));
} else { } else {
ObPartitionMultiRangeSpliter spliter; ObPartitionMultiRangeSpliter spliter;
@ -5670,7 +5672,8 @@ int ObLSTabletService::split_multi_ranges(
int ObLSTabletService::estimate_row_count( int ObLSTabletService::estimate_row_count(
const ObTableScanParam &param, const ObTableScanParam &param,
const ObTableScanRange &scan_range, const ObTableScanRange &scan_range,
ObIArray<ObEstRowCountRecord> &est_records, const int64_t timeout_us,
common::ObIArray<ObEstRowCountRecord> &est_records,
int64_t &logical_row_count, int64_t &logical_row_count,
int64_t &physical_row_count) int64_t &physical_row_count)
{ {
@ -5689,7 +5692,7 @@ int ObLSTabletService::estimate_row_count(
} else { } else {
const int64_t snapshot_version = -1 == param.frozen_version_ ? const int64_t snapshot_version = -1 == param.frozen_version_ ?
GET_BATCH_ROWS_READ_SNAPSHOT_VERSION : param.frozen_version_; GET_BATCH_ROWS_READ_SNAPSHOT_VERSION : param.frozen_version_;
if (OB_FAIL(get_read_tables(param.tablet_id_, snapshot_version, tablet_iter, false))) { if (OB_FAIL(get_read_tables(param.tablet_id_, timeout_us, snapshot_version, tablet_iter, false))) {
if (OB_TABLET_NOT_EXIST != ret) { if (OB_TABLET_NOT_EXIST != ret) {
LOG_WARN("failed to get tablet_iter", K(ret), K(snapshot_version), K(param)); LOG_WARN("failed to get tablet_iter", K(ret), K(snapshot_version), K(param));
} }
@ -5736,6 +5739,7 @@ int ObLSTabletService::estimate_row_count(
int ObLSTabletService::estimate_block_count_and_row_count( int ObLSTabletService::estimate_block_count_and_row_count(
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
int64_t &macro_block_count, int64_t &macro_block_count,
int64_t &micro_block_count, int64_t &micro_block_count,
int64_t &sstable_row_count, int64_t &sstable_row_count,
@ -5753,7 +5757,7 @@ int ObLSTabletService::estimate_block_count_and_row_count(
if (IS_NOT_INIT) { if (IS_NOT_INIT) {
ret = OB_NOT_INIT; ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret), K_(is_inited)); LOG_WARN("not inited", K(ret), K_(is_inited));
} else if (OB_FAIL(get_read_tables(tablet_id, INT64_MAX, tablet_iter, false/*allow_no_ready_read*/))) { } else if (OB_FAIL(get_read_tables(tablet_id, timeout_us, INT64_MAX, tablet_iter, false/*allow_no_ready_read*/))) {
LOG_WARN("failed to get read tables", K(ret)); LOG_WARN("failed to get read tables", K(ret));
} }

View File

@ -282,6 +282,7 @@ public:
const share::SCN clog_checkpoint_scn = share::SCN::min_scn()); const share::SCN clog_checkpoint_scn = share::SCN::min_scn());
int get_read_tables( int get_read_tables(
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
const int64_t snapshot_version, const int64_t snapshot_version,
ObTabletTableIterator &iter, ObTabletTableIterator &iter,
const bool allow_no_ready_read = false); const bool allow_no_ready_read = false);
@ -373,11 +374,13 @@ public:
const ObLockFlag lock_flag, const ObLockFlag lock_flag,
const bool is_sfu); const bool is_sfu);
int get_multi_ranges_cost( int get_multi_ranges_cost(
const ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
const common::ObIArray<common::ObStoreRange> &ranges, const common::ObIArray<common::ObStoreRange> &ranges,
int64_t &total_size); int64_t &total_size);
int split_multi_ranges( int split_multi_ranges(
const ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
const ObIArray<ObStoreRange> &ranges, const ObIArray<ObStoreRange> &ranges,
const int64_t expected_task_count, const int64_t expected_task_count,
common::ObIAllocator &allocator, common::ObIAllocator &allocator,
@ -385,11 +388,13 @@ public:
int estimate_row_count( int estimate_row_count(
const ObTableScanParam &param, const ObTableScanParam &param,
const ObTableScanRange &scan_range, const ObTableScanRange &scan_range,
ObIArray<ObEstRowCountRecord> &est_records, const int64_t timeout_us,
common::ObIArray<ObEstRowCountRecord> &est_records,
int64_t &logical_row_count, int64_t &logical_row_count,
int64_t &physical_row_count); int64_t &physical_row_count);
int estimate_block_count_and_row_count( int estimate_block_count_and_row_count(
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
int64_t &macro_block_count, int64_t &macro_block_count,
int64_t &micro_block_count, int64_t &micro_block_count,
int64_t &sstable_row_count, int64_t &sstable_row_count,

View File

@ -171,6 +171,7 @@ int ObStorageTableGuard::refresh_and_protect_table(ObRelativeTable &relative_tab
while (OB_SUCC(ret) && need_to_refresh_table(*iter.table_iter())) { while (OB_SUCC(ret) && need_to_refresh_table(*iter.table_iter())) {
if (OB_FAIL(store_ctx_.ls_->get_tablet_svr()->get_read_tables( if (OB_FAIL(store_ctx_.ls_->get_tablet_svr()->get_read_tables(
tablet_id, tablet_id,
ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US,
store_ctx_.mvcc_acc_ctx_.get_snapshot_version().get_val_for_tx(), store_ctx_.mvcc_acc_ctx_.get_snapshot_version().get_val_for_tx(),
iter, iter,
relative_table.allow_not_ready()))) { relative_table.allow_not_ready()))) {

View File

@ -14,6 +14,7 @@
#define OCEANBASE_STORAGE_OB_TABLET_COMMON #define OCEANBASE_STORAGE_OB_TABLET_COMMON
#include <stdint.h> #include <stdint.h>
#include "lib/literals/ob_literals.h"
namespace oceanbase namespace oceanbase
{ {
@ -55,8 +56,8 @@ public:
static const int64_t BUCKET_LOCK_BUCKET_CNT = 10243L; static const int64_t BUCKET_LOCK_BUCKET_CNT = 10243L;
static const int64_t TABLET_ID_SET_BUCKET_CNT = 10243L; static const int64_t TABLET_ID_SET_BUCKET_CNT = 10243L;
static const int64_t DEFAULT_GET_TABLET_NO_WAIT = 0; // 0s static const int64_t DEFAULT_GET_TABLET_NO_WAIT = 0; // 0s
static const int64_t DEFAULT_GET_TABLET_DURATION_US = 1 * 1000 * 1000; // 1s static const int64_t DEFAULT_GET_TABLET_DURATION_US = 1_s;
static const int64_t DEFAULT_GET_TABLET_DURATION_10_S = 10 * 1000 * 1000; // 10s static const int64_t DEFAULT_GET_TABLET_DURATION_10_S = 10_s;
static const int64_t FINAL_TX_ID = 0; static const int64_t FINAL_TX_ID = 0;
}; };
} // namespace storage } // namespace storage

View File

@ -1043,7 +1043,8 @@ int ObAccessService::lock_row(
int ObAccessService::estimate_row_count( int ObAccessService::estimate_row_count(
const ObTableScanParam &param, const ObTableScanParam &param,
const ObTableScanRange &scan_range, const ObTableScanRange &scan_range,
ObIArray<ObEstRowCountRecord> &est_records, const int64_t timeout_us,
common::ObIArray<ObEstRowCountRecord> &est_records,
int64_t &logical_row_count, int64_t &logical_row_count,
int64_t &physical_row_count) const int64_t &physical_row_count) const
{ {
@ -1062,10 +1063,10 @@ int ObAccessService::estimate_row_count(
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("ls is unexpected null", K(ret)); LOG_WARN("ls is unexpected null", K(ret));
} else if (OB_FAIL(ls->get_tablet_svr()->estimate_row_count( } else if (OB_FAIL(ls->get_tablet_svr()->estimate_row_count(
param, scan_range, est_records, param, scan_range, timeout_us, est_records,
logical_row_count, physical_row_count))) { logical_row_count, physical_row_count))) {
if (OB_TABLET_NOT_EXIST != ret) { if (OB_TABLET_NOT_EXIST != ret) {
LOG_WARN("failed to estimate row count", K(ret), K(param)); LOG_WARN("failed to estimate row count", K(ret), K(param), K(scan_range), K(timeout_us));
} }
} }
return ret; return ret;
@ -1074,6 +1075,7 @@ int ObAccessService::estimate_row_count(
int ObAccessService::estimate_block_count_and_row_count( int ObAccessService::estimate_block_count_and_row_count(
const share::ObLSID &ls_id, const share::ObLSID &ls_id,
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
int64_t &macro_block_count, int64_t &macro_block_count,
int64_t &micro_block_count, int64_t &micro_block_count,
int64_t &sstable_row_count, int64_t &sstable_row_count,
@ -1096,9 +1098,11 @@ int ObAccessService::estimate_block_count_and_row_count(
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("ls is unexpected null", K(ret)); LOG_WARN("ls is unexpected null", K(ret));
} else if (OB_FAIL(ls->get_tablet_svr()->estimate_block_count_and_row_count( } else if (OB_FAIL(ls->get_tablet_svr()->estimate_block_count_and_row_count(
tablet_id, macro_block_count, micro_block_count, sstable_row_count, tablet_id, timeout_us,
memtable_row_count, cg_macro_cnt_arr, cg_micro_cnt_arr))) { macro_block_count, micro_block_count,
LOG_WARN("failed to estimate block count and row count", K(ret), K(ls_id), K(tablet_id)); sstable_row_count, memtable_row_count,
cg_macro_cnt_arr, cg_micro_cnt_arr))) {
LOG_WARN("failed to estimate block count and row count", K(ret), K(ls_id), K(tablet_id), K(timeout_us));
} }
return ret; return ret;
} }
@ -1106,6 +1110,7 @@ int ObAccessService::estimate_block_count_and_row_count(
int ObAccessService::get_multi_ranges_cost( int ObAccessService::get_multi_ranges_cost(
const share::ObLSID &ls_id, const share::ObLSID &ls_id,
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
const common::ObIArray<common::ObStoreRange> &ranges, const common::ObIArray<common::ObStoreRange> &ranges,
int64_t &total_size) int64_t &total_size)
{ {
@ -1129,7 +1134,7 @@ int ObAccessService::get_multi_ranges_cost(
} else if (OB_ISNULL(tablet_service = ls->get_tablet_svr())) { } else if (OB_ISNULL(tablet_service = ls->get_tablet_svr())) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_ERROR("tablet service should not be null", K(ret), K(ls_id)); LOG_ERROR("tablet service should not be null", K(ret), K(ls_id));
} else if (OB_FAIL(tablet_service->get_multi_ranges_cost(tablet_id, ranges, total_size))) { } else if (OB_FAIL(tablet_service->get_multi_ranges_cost(tablet_id, timeout_us, ranges, total_size))) {
LOG_WARN("Fail to get multi ranges cost", K(ret), K(ls_id), K(tablet_id)); LOG_WARN("Fail to get multi ranges cost", K(ret), K(ls_id), K(tablet_id));
} }
return ret; return ret;
@ -1186,9 +1191,10 @@ int ObAccessService::revert_scan_iter(ObNewRowIterator *iter)
int ObAccessService::split_multi_ranges( int ObAccessService::split_multi_ranges(
const share::ObLSID &ls_id, const share::ObLSID &ls_id,
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
const ObIArray<ObStoreRange> &ranges, const ObIArray<ObStoreRange> &ranges,
const int64_t expected_task_count, const int64_t expected_task_count,
ObIAllocator &allocator, common::ObIAllocator &allocator,
ObArrayArray<ObStoreRange> &multi_range_split_array) ObArrayArray<ObStoreRange> &multi_range_split_array)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
@ -1212,7 +1218,8 @@ int ObAccessService::split_multi_ranges(
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_ERROR("tablet service should not be null", K(ret), K(ls_id)); LOG_ERROR("tablet service should not be null", K(ret), K(ls_id));
} else if (OB_FAIL(tablet_service->split_multi_ranges( } else if (OB_FAIL(tablet_service->split_multi_ranges(
tablet_id, ranges, expected_task_count, allocator, multi_range_split_array))) { tablet_id, timeout_us, ranges,
expected_task_count, allocator, multi_range_split_array))) {
LOG_WARN("Fail to split multi ranges", K(ret), K(ls_id), K(tablet_id)); LOG_WARN("Fail to split multi ranges", K(ret), K(ls_id), K(tablet_id));
} }
return ret; return ret;

View File

@ -108,15 +108,17 @@ public:
virtual int get_multi_ranges_cost( virtual int get_multi_ranges_cost(
const share::ObLSID &ls_id, const share::ObLSID &ls_id,
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
const common::ObIArray<common::ObStoreRange> &ranges, const common::ObIArray<common::ObStoreRange> &ranges,
int64_t &total_size) override; int64_t &total_size) override;
virtual int split_multi_ranges( virtual int split_multi_ranges(
const share::ObLSID &ls_id, const share::ObLSID &ls_id,
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const ObIArray<ObStoreRange> &ranges, const int64_t timeout_us,
const common::ObIArray<ObStoreRange> &ranges,
const int64_t expected_task_count, const int64_t expected_task_count,
ObIAllocator &allocator, common::ObIAllocator &allocator,
ObArrayArray<ObStoreRange> &multi_range_split_array) override; common::ObArrayArray<ObStoreRange> &multi_range_split_array) override;
// DML interface // DML interface
int delete_rows( int delete_rows(
@ -184,12 +186,14 @@ public:
int estimate_row_count( int estimate_row_count(
const ObTableScanParam &param, const ObTableScanParam &param,
const ObTableScanRange &scan_range, const ObTableScanRange &scan_range,
const int64_t timeout_us,
ObIArray<ObEstRowCountRecord> &est_records, ObIArray<ObEstRowCountRecord> &est_records,
int64_t &logical_row_count, int64_t &logical_row_count,
int64_t &physical_row_count) const; int64_t &physical_row_count) const;
int estimate_block_count_and_row_count( int estimate_block_count_and_row_count(
const share::ObLSID &ls_id, const share::ObLSID &ls_id,
const common::ObTabletID &tablet_id, const common::ObTabletID &tablet_id,
const int64_t timeout_us,
int64_t &macro_block_count, int64_t &macro_block_count,
int64_t &micro_block_count, int64_t &micro_block_count,
int64_t &sstable_row_count, int64_t &sstable_row_count,