[CP] add retry for direct load if unit has migrated
This commit is contained in:
@ -24,7 +24,7 @@ namespace oceanbase
|
||||
namespace sql
|
||||
{
|
||||
|
||||
int ObLoadDataExecutor::check_is_direct_load(const ObLoadDataHint &load_hint, bool &check_ret)
|
||||
int ObLoadDataExecutor::check_is_direct_load(ObTableDirectInsertCtx &ctx, const ObLoadDataHint &load_hint)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t enable_direct = 0;
|
||||
@ -34,9 +34,9 @@ int ObLoadDataExecutor::check_is_direct_load(const ObLoadDataHint &load_hint, bo
|
||||
} else if (OB_FAIL(load_hint.get_value(ObLoadDataHint::APPEND, append))) {
|
||||
LOG_WARN("fail to get value of APPEND", K(ret));
|
||||
} else if ((enable_direct != 0 || append != 0) && GCONF._ob_enable_direct_load) {
|
||||
check_ret = true;
|
||||
ctx.set_is_direct(true);
|
||||
} else {
|
||||
check_ret = false;
|
||||
ctx.set_is_direct(false);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -44,15 +44,15 @@ int ObLoadDataExecutor::check_is_direct_load(const ObLoadDataHint &load_hint, bo
|
||||
int ObLoadDataExecutor::execute(ObExecContext &ctx, ObLoadDataStmt &stmt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTableDirectInsertCtx &table_direct_insert_ctx = ctx.get_table_direct_insert_ctx();
|
||||
ObLoadDataBase *load_impl = NULL;
|
||||
bool is_direct_load = false;
|
||||
if (!stmt.get_load_arguments().is_csv_format_) {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("invalid resolver results", K(ret));
|
||||
} else if (OB_FAIL(check_is_direct_load(stmt.get_hints(), is_direct_load))) {
|
||||
} else if (OB_FAIL(check_is_direct_load(table_direct_insert_ctx, stmt.get_hints()))) {
|
||||
LOG_WARN("fail to check is load mode", KR(ret));
|
||||
} else {
|
||||
if (!is_direct_load) {
|
||||
if (!table_direct_insert_ctx.get_is_direct()) {
|
||||
if (OB_ISNULL(load_impl = OB_NEWx(ObLoadDataSPImpl, (&ctx.get_allocator())))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("allocate memory failed", K(ret));
|
||||
|
||||
@ -26,7 +26,7 @@ public:
|
||||
|
||||
int execute(ObExecContext &ctx, ObLoadDataStmt &stmt);
|
||||
private:
|
||||
int check_is_direct_load(const ObLoadDataHint &load_hint, bool &check_ret);
|
||||
int check_is_direct_load(ObTableDirectInsertCtx &ctx, const ObLoadDataHint &load_hint);
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObLoadDataExecutor);
|
||||
|
||||
@ -45,6 +45,7 @@ int ObTableDirectInsertCtx::init(ObExecContext *exec_ctx,
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("exec_ctx cannot be null", KR(ret));
|
||||
} else {
|
||||
is_direct_ = true;
|
||||
if (OB_ISNULL(load_exec_ctx_ = OB_NEWx(ObTableLoadSqlExecCtx, &exec_ctx->get_allocator()))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to new ObTableLoadSqlExecCtx", KR(ret));
|
||||
|
||||
@ -32,7 +32,8 @@ public:
|
||||
ObTableDirectInsertCtx()
|
||||
: load_exec_ctx_(nullptr),
|
||||
table_load_instance_(nullptr),
|
||||
is_inited_(false) {}
|
||||
is_inited_(false),
|
||||
is_direct_(false) {}
|
||||
~ObTableDirectInsertCtx();
|
||||
TO_STRING_KV(K_(is_inited));
|
||||
public:
|
||||
@ -40,6 +41,10 @@ public:
|
||||
int commit();
|
||||
int finish();
|
||||
void destroy();
|
||||
|
||||
bool get_is_direct() const { return is_direct_; }
|
||||
void set_is_direct(bool is_direct) { is_direct_ = is_direct; }
|
||||
|
||||
private:
|
||||
int init_store_column_idxs(const uint64_t tenant_id, const uint64_t table_id,
|
||||
common::ObIArray<int64_t> &store_column_idxs);
|
||||
@ -47,6 +52,7 @@ private:
|
||||
observer::ObTableLoadSqlExecCtx *load_exec_ctx_;
|
||||
observer::ObTableLoadInstance *table_load_instance_;
|
||||
bool is_inited_;
|
||||
bool is_direct_; //indict whether the plan is direct load plan including insert into append and load data direct
|
||||
};
|
||||
} // namespace observer
|
||||
} // namespace oceanbase
|
||||
} // namespace oceanbase
|
||||
|
||||
Reference in New Issue
Block a user