Add direct load client service
This commit is contained in:
53
deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h
vendored
53
deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h
vendored
@ -806,34 +806,36 @@ PCODE_DEF(OB_TABLE_TTL, 0x1107)
|
|||||||
PCODE_DEF(OB_TTL_REQUEST, 0x1108)
|
PCODE_DEF(OB_TTL_REQUEST, 0x1108)
|
||||||
PCODE_DEF(OB_TTL_RESPONSE, 0x1109)
|
PCODE_DEF(OB_TTL_RESPONSE, 0x1109)
|
||||||
|
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_BEGIN, 0x110A)
|
// PCODE_DEF(OB_TABLE_API_LOAD_BEGIN, 0x110A) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_FINISH, 0x110B)
|
// PCODE_DEF(OB_TABLE_API_LOAD_FINISH, 0x110B) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_COMMIT, 0x110C)
|
// PCODE_DEF(OB_TABLE_API_LOAD_COMMIT, 0x110C) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_ABORT, 0x110D)
|
// PCODE_DEF(OB_TABLE_API_LOAD_ABORT, 0x110D) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_GET_STATUS, 0x110E)
|
// PCODE_DEF(OB_TABLE_API_LOAD_GET_STATUS, 0x110E) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD, 0x110F)
|
// PCODE_DEF(OB_TABLE_API_LOAD, 0x110F) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_START_TRANS, 0x1110)
|
// PCODE_DEF(OB_TABLE_API_LOAD_START_TRANS, 0x1110) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_FINISH_TRANS, 0x1111)
|
// PCODE_DEF(OB_TABLE_API_LOAD_FINISH_TRANS, 0x1111) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_ABANDON_TRANS, 0x1112)
|
// PCODE_DEF(OB_TABLE_API_LOAD_ABANDON_TRANS, 0x1112) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_GET_TRANS_STATUS, 0x1113)
|
// PCODE_DEF(OB_TABLE_API_LOAD_GET_TRANS_STATUS, 0x1113) // not supported on 4.2
|
||||||
|
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_PRE_BEGIN_PEER, 0x1114)
|
// PCODE_DEF(OB_TABLE_API_LOAD_PRE_BEGIN_PEER, 0x1114) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_CONFIRM_BEGIN_PEER, 0x1115)
|
// PCODE_DEF(OB_TABLE_API_LOAD_CONFIRM_BEGIN_PEER, 0x1115) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_PRE_MERGE_PEER, 0x1116)
|
// PCODE_DEF(OB_TABLE_API_LOAD_PRE_MERGE_PEER, 0x1116) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_START_MERGE_PEER, 0x1117)
|
// PCODE_DEF(OB_TABLE_API_LOAD_START_MERGE_PEER, 0x1117) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_COMMIT_PEER, 0x1118)
|
// PCODE_DEF(OB_TABLE_API_LOAD_COMMIT_PEER, 0x1118) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_ABORT_PEER, 0x1119)
|
// PCODE_DEF(OB_TABLE_API_LOAD_ABORT_PEER, 0x1119) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_GET_STATUS_PEER, 0x111A)
|
// PCODE_DEF(OB_TABLE_API_LOAD_GET_STATUS_PEER, 0x111A) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_PEER, 0x111B)
|
// PCODE_DEF(OB_TABLE_API_LOAD_PEER, 0x111B) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_PRE_START_TRANS_PEER, 0x111C)
|
// PCODE_DEF(OB_TABLE_API_LOAD_PRE_START_TRANS_PEER, 0x111C) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_CONFIRM_START_TRANS_PEER, 0x111D)
|
// PCODE_DEF(OB_TABLE_API_LOAD_CONFIRM_START_TRANS_PEER, 0x111D) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_PRE_FINISH_TRANS_PEER, 0x111E)
|
// PCODE_DEF(OB_TABLE_API_LOAD_PRE_FINISH_TRANS_PEER, 0x111E) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_CONFIRM_FINISH_TRANS_PEER, 0x111F)
|
// PCODE_DEF(OB_TABLE_API_LOAD_CONFIRM_FINISH_TRANS_PEER, 0x111F) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_ABANDON_TRANS_PEER, 0x1120)
|
// PCODE_DEF(OB_TABLE_API_LOAD_ABANDON_TRANS_PEER, 0x1120) // not supported on 4.2
|
||||||
PCODE_DEF(OB_TABLE_API_LOAD_GET_TRANS_STATUS_PEER, 0x1121)
|
// PCODE_DEF(OB_TABLE_API_LOAD_GET_TRANS_STATUS_PEER, 0x1121) // not supported on 4.2
|
||||||
|
|
||||||
PCODE_DEF(OB_TABLE_API_EXECUTE_GROUP_UPDATE, 0x1122)
|
PCODE_DEF(OB_TABLE_API_EXECUTE_GROUP_UPDATE, 0x1122)
|
||||||
|
|
||||||
|
PCODE_DEF(OB_TABLE_API_DIRECT_LOAD, 0x1123)
|
||||||
|
|
||||||
// Event Job API
|
// Event Job API
|
||||||
PCODE_DEF(OB_RUN_EVENT_JOB, 0x1201)
|
PCODE_DEF(OB_RUN_EVENT_JOB, 0x1201)
|
||||||
PCODE_DEF(OB_CREATE_EVENT_JOB, 0x1202)
|
PCODE_DEF(OB_CREATE_EVENT_JOB, 0x1202)
|
||||||
@ -1000,3 +1002,6 @@ PCODE_DEF(OB_INNER_CREATE_TENANT_SNAPSHOT, 0x1601)
|
|||||||
// drop tenant snapshot
|
// drop tenant snapshot
|
||||||
PCODE_DEF(OB_DROP_TENANT_SNAPSHOT, 0x1602)
|
PCODE_DEF(OB_DROP_TENANT_SNAPSHOT, 0x1602)
|
||||||
PCODE_DEF(OB_INNER_DROP_TENANT_SNAPSHOT, 0x1603)
|
PCODE_DEF(OB_INNER_DROP_TENANT_SNAPSHOT, 0x1603)
|
||||||
|
|
||||||
|
// for direct load
|
||||||
|
PCODE_DEF(OB_DIRECT_LOAD_CONTROL, 0x1604)
|
||||||
|
|||||||
@ -154,22 +154,25 @@ ob_set_subtarget(ob_server table
|
|||||||
table/ob_table_session_pool.cpp
|
table/ob_table_session_pool.cpp
|
||||||
table/ob_table_op_wrapper.cpp
|
table/ob_table_op_wrapper.cpp
|
||||||
table/ob_table_query_common.cpp
|
table/ob_table_query_common.cpp
|
||||||
|
table/ob_table_direct_load_processor.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
ob_set_subtarget(ob_server table_load
|
ob_set_subtarget(ob_server table_load
|
||||||
table_load/ob_table_load_abort_processor.cpp
|
table_load/client/ob_table_direct_load_rpc_executor.cpp
|
||||||
|
table_load/client/ob_table_direct_load_rpc_proxy.cpp
|
||||||
|
table_load/client/ob_table_direct_load_rpc_struct.cpp
|
||||||
|
table_load/control/ob_table_load_control_rpc_executor.cpp
|
||||||
|
table_load/control/ob_table_load_control_rpc_proxy.cpp
|
||||||
|
table_load/control/ob_table_load_control_rpc_struct.cpp
|
||||||
table_load/ob_table_load_autoinc_nextval.cpp
|
table_load/ob_table_load_autoinc_nextval.cpp
|
||||||
table_load/ob_table_load_begin_processor.cpp
|
|
||||||
table_load/ob_table_load_bucket.cpp
|
table_load/ob_table_load_bucket.cpp
|
||||||
table_load/ob_table_load_commit_processor.cpp
|
table_load/ob_table_load_client_service.cpp
|
||||||
|
table_load/ob_table_load_client_task.cpp
|
||||||
table_load/ob_table_load_coordinator_ctx.cpp
|
table_load/ob_table_load_coordinator_ctx.cpp
|
||||||
table_load/ob_table_load_coordinator_trans.cpp
|
table_load/ob_table_load_coordinator_trans.cpp
|
||||||
table_load/ob_table_load_coordinator.cpp
|
table_load/ob_table_load_coordinator.cpp
|
||||||
table_load/ob_table_load_csv_parser.cpp
|
|
||||||
table_load/ob_table_load_error_row_handler.cpp
|
table_load/ob_table_load_error_row_handler.cpp
|
||||||
table_load/ob_table_load_finish_processor.cpp
|
|
||||||
table_load/ob_table_load_general_table_compactor.cpp
|
table_load/ob_table_load_general_table_compactor.cpp
|
||||||
table_load/ob_table_load_get_status_processor.cpp
|
|
||||||
table_load/ob_table_load_manager.cpp
|
table_load/ob_table_load_manager.cpp
|
||||||
table_load/ob_table_load_merger.cpp
|
table_load/ob_table_load_merger.cpp
|
||||||
table_load/ob_table_load_obj_cast.cpp
|
table_load/ob_table_load_obj_cast.cpp
|
||||||
@ -177,7 +180,7 @@ ob_set_subtarget(ob_server table_load
|
|||||||
table_load/ob_table_load_parallel_merge_table_compactor.cpp
|
table_load/ob_table_load_parallel_merge_table_compactor.cpp
|
||||||
table_load/ob_table_load_partition_calc.cpp
|
table_load/ob_table_load_partition_calc.cpp
|
||||||
table_load/ob_table_load_partition_location.cpp
|
table_load/ob_table_load_partition_location.cpp
|
||||||
table_load/ob_table_load_processor.cpp
|
table_load/ob_table_load_rpc_processor.cpp
|
||||||
table_load/ob_table_load_schema.cpp
|
table_load/ob_table_load_schema.cpp
|
||||||
table_load/ob_table_load_service.cpp
|
table_load/ob_table_load_service.cpp
|
||||||
table_load/ob_table_load_store_ctx.cpp
|
table_load/ob_table_load_store_ctx.cpp
|
||||||
@ -190,7 +193,6 @@ ob_set_subtarget(ob_server table_load
|
|||||||
table_load/ob_table_load_time_convert.cpp
|
table_load/ob_table_load_time_convert.cpp
|
||||||
table_load/ob_table_load_trans_bucket_writer.cpp
|
table_load/ob_table_load_trans_bucket_writer.cpp
|
||||||
table_load/ob_table_load_trans_ctx.cpp
|
table_load/ob_table_load_trans_ctx.cpp
|
||||||
table_load/ob_table_load_trans_processor.cpp
|
|
||||||
table_load/ob_table_load_trans_store.cpp
|
table_load/ob_table_load_trans_store.cpp
|
||||||
table_load/ob_table_load_utils.cpp
|
table_load/ob_table_load_utils.cpp
|
||||||
table_load/ob_table_load_mem_compactor.cpp
|
table_load/ob_table_load_mem_compactor.cpp
|
||||||
|
|||||||
@ -46,19 +46,14 @@
|
|||||||
#include "observer/table/ob_table_query_processor.h"
|
#include "observer/table/ob_table_query_processor.h"
|
||||||
#include "observer/table/ob_table_query_and_mutate_processor.h"
|
#include "observer/table/ob_table_query_and_mutate_processor.h"
|
||||||
#include "observer/table/ob_table_query_sync_processor.h"
|
#include "observer/table/ob_table_query_sync_processor.h"
|
||||||
|
#include "observer/table/ob_table_direct_load_processor.h"
|
||||||
#include "storage/ob_storage_rpc.h"
|
#include "storage/ob_storage_rpc.h"
|
||||||
|
|
||||||
#include "logservice/restoreservice/ob_log_restore_rpc_define.h"
|
#include "logservice/restoreservice/ob_log_restore_rpc_define.h"
|
||||||
#include "rootserver/freeze/ob_major_freeze_rpc_define.h" // ObTenantMajorFreezeP
|
#include "rootserver/freeze/ob_major_freeze_rpc_define.h" // ObTenantMajorFreezeP
|
||||||
#include "storage/tx/ob_xa_rpc.h"
|
#include "storage/tx/ob_xa_rpc.h"
|
||||||
|
|
||||||
#include "observer/table_load/ob_table_load_abort_processor.h"
|
#include "observer/table_load/ob_table_load_rpc_processor.h"
|
||||||
#include "observer/table_load/ob_table_load_begin_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_commit_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_finish_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_get_status_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_trans_processor.h"
|
|
||||||
#include "observer/net/ob_net_endpoint_ingress_rpc_processor.h"
|
#include "observer/net/ob_net_endpoint_ingress_rpc_processor.h"
|
||||||
|
|
||||||
using namespace oceanbase;
|
using namespace oceanbase;
|
||||||
@ -192,33 +187,7 @@ void oceanbase::observer::init_srv_xlator_for_others(ObSrvRpcXlator *xlator) {
|
|||||||
RPC_PROCESSOR(ObTableQueryP, gctx_);
|
RPC_PROCESSOR(ObTableQueryP, gctx_);
|
||||||
RPC_PROCESSOR(ObTableQueryAndMutateP, gctx_);
|
RPC_PROCESSOR(ObTableQueryAndMutateP, gctx_);
|
||||||
RPC_PROCESSOR(ObTableQuerySyncP, gctx_);
|
RPC_PROCESSOR(ObTableQuerySyncP, gctx_);
|
||||||
|
RPC_PROCESSOR(ObTableDirectLoadP, gctx_);
|
||||||
// table load api
|
|
||||||
RPC_PROCESSOR(ObTableLoadBeginP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadFinishP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadCommitP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadAbortP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadGetStatusP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadStartTransP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadFinishTransP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadAbandonTransP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadGetTransStatusP, gctx_);
|
|
||||||
|
|
||||||
RPC_PROCESSOR(ObTableLoadPreBeginPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadConfirmBeginPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadPreMergePeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadStartMergePeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadCommitPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadAbortPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadGetStatusPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadPreStartTransPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadConfirmStartTransPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadPreFinishTransPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadConfirmFinishTransPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadAbandonTransPeerP, gctx_);
|
|
||||||
RPC_PROCESSOR(ObTableLoadGetTransStatusPeerP, gctx_);
|
|
||||||
|
|
||||||
// HA GTS
|
// HA GTS
|
||||||
RPC_PROCESSOR(ObHaGtsPingRequestP, gctx_);
|
RPC_PROCESSOR(ObHaGtsPingRequestP, gctx_);
|
||||||
@ -307,4 +276,7 @@ void oceanbase::observer::init_srv_xlator_for_others(ObSrvRpcXlator *xlator) {
|
|||||||
// session info verification
|
// session info verification
|
||||||
RPC_PROCESSOR(ObSessInfoVerificationP, gctx_);
|
RPC_PROCESSOR(ObSessInfoVerificationP, gctx_);
|
||||||
RPC_PROCESSOR(ObBroadcastConsensusVersionP, gctx_);
|
RPC_PROCESSOR(ObBroadcastConsensusVersionP, gctx_);
|
||||||
|
|
||||||
|
// direct load
|
||||||
|
RPC_PROCESSOR(ObDirectLoadControlP, gctx_);
|
||||||
}
|
}
|
||||||
|
|||||||
69
src/observer/table/ob_table_direct_load_processor.cpp
Normal file
69
src/observer/table/ob_table_direct_load_processor.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "ob_table_direct_load_processor.h"
|
||||||
|
#include "observer/table_load/ob_table_load_client_service.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
using namespace table;
|
||||||
|
|
||||||
|
ObTableDirectLoadP::ObTableDirectLoadP(const ObGlobalContext &gctx)
|
||||||
|
: ObTableRpcProcessor(gctx),
|
||||||
|
allocator_(ObModIds::TABLE_PROC, OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID()),
|
||||||
|
exec_ctx_(allocator_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadP::check_arg()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(arg_.operation_type_ == ObTableDirectLoadOperationType::MAX_TYPE ||
|
||||||
|
arg_.arg_content_.empty())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadP::try_process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
exec_ctx_.set_tenant_id(credential_.tenant_id_);
|
||||||
|
exec_ctx_.set_user_id(credential_.user_id_);
|
||||||
|
exec_ctx_.set_database_id(credential_.database_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadClientService::direct_load_operate(exec_ctx_, arg_, result_))) {
|
||||||
|
LOG_WARN("fail to do direct load operate", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObTableAPITransCb *ObTableDirectLoadP::new_callback(rpc::ObRequest *req)
|
||||||
|
{
|
||||||
|
UNUSED(req);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ObTableDirectLoadP::get_request_checksum()
|
||||||
|
{
|
||||||
|
uint64_t checksum = 0;
|
||||||
|
checksum = ob_crc64(checksum, &result_.operation_type_, sizeof(result_.operation_type_));
|
||||||
|
checksum = ob_crc64(checksum, result_.res_content_.ptr(), result_.res_content_.length());
|
||||||
|
return checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
42
src/observer/table/ob_table_direct_load_processor.h
Normal file
42
src/observer/table/ob_table_direct_load_processor.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "observer/table_load/client/ob_table_direct_load_exec_context.h"
|
||||||
|
#include "observer/table/ob_table_rpc_processor.h"
|
||||||
|
#include "share/table/ob_table_rpc_proxy.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
|
||||||
|
/// @see RPC_S(PR5 direct_load, obrpc::OB_TABLE_API_DIRECT_LOAD, (table::ObTableDirectLoadRequest), table::ObTableDirectLoadResult);
|
||||||
|
class ObTableDirectLoadP : public ObTableRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_DIRECT_LOAD>>
|
||||||
|
{
|
||||||
|
typedef ObTableRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_DIRECT_LOAD>> ParentType;
|
||||||
|
public:
|
||||||
|
explicit ObTableDirectLoadP(const ObGlobalContext &gctx);
|
||||||
|
virtual ~ObTableDirectLoadP() = default;
|
||||||
|
protected:
|
||||||
|
int check_arg() override;
|
||||||
|
int try_process() override;
|
||||||
|
table::ObTableAPITransCb *new_callback(rpc::ObRequest *req) override;
|
||||||
|
uint64_t get_request_checksum() override;
|
||||||
|
private:
|
||||||
|
common::ObArenaAllocator allocator_;
|
||||||
|
ObTableDirectLoadExecContext exec_ctx_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -821,6 +821,7 @@ template class oceanbase::observer::ObTableRpcProcessor<ObTableRpcProxy::ObRpc<O
|
|||||||
template class oceanbase::observer::ObTableRpcProcessor<ObTableRpcProxy::ObRpc<OB_TABLE_API_EXECUTE_QUERY> >;
|
template class oceanbase::observer::ObTableRpcProcessor<ObTableRpcProxy::ObRpc<OB_TABLE_API_EXECUTE_QUERY> >;
|
||||||
template class oceanbase::observer::ObTableRpcProcessor<ObTableRpcProxy::ObRpc<OB_TABLE_API_QUERY_AND_MUTATE> >;
|
template class oceanbase::observer::ObTableRpcProcessor<ObTableRpcProxy::ObRpc<OB_TABLE_API_QUERY_AND_MUTATE> >;
|
||||||
template class oceanbase::observer::ObTableRpcProcessor<ObTableRpcProxy::ObRpc<OB_TABLE_API_EXECUTE_QUERY_SYNC> >;
|
template class oceanbase::observer::ObTableRpcProcessor<ObTableRpcProxy::ObRpc<OB_TABLE_API_EXECUTE_QUERY_SYNC> >;
|
||||||
|
template class oceanbase::observer::ObTableRpcProcessor<ObTableRpcProxy::ObRpc<OB_TABLE_API_DIRECT_LOAD> >;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
int ObTableRpcProcessor<T>::deserialize()
|
int ObTableRpcProcessor<T>::deserialize()
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "lib/allocator/ob_allocator.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
|
||||||
|
class ObTableDirectLoadExecContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ObTableDirectLoadExecContext(common::ObIAllocator &allocator)
|
||||||
|
: allocator_(allocator), tenant_id_(0), user_id_(0), database_id_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~ObTableDirectLoadExecContext() = default;
|
||||||
|
common::ObIAllocator &get_allocator() { return allocator_; }
|
||||||
|
void set_tenant_id(uint64_t tenant_id) { tenant_id_ = tenant_id; }
|
||||||
|
uint64_t get_tenant_id() const { return tenant_id_; }
|
||||||
|
void set_user_id(uint64_t user_id) { user_id_ = user_id; }
|
||||||
|
uint64_t get_user_id() const { return user_id_; }
|
||||||
|
void set_database_id(uint64_t database_id) { database_id_ = database_id; }
|
||||||
|
uint64_t get_database_id() const { return database_id_; }
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ObTableDirectLoadExecContext);
|
||||||
|
private:
|
||||||
|
common::ObIAllocator &allocator_;
|
||||||
|
uint64_t tenant_id_;
|
||||||
|
uint64_t user_id_;
|
||||||
|
uint64_t database_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,463 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "ob_table_direct_load_rpc_executor.h"
|
||||||
|
#include "observer/omt/ob_multi_tenant.h"
|
||||||
|
#include "observer/omt/ob_tenant.h"
|
||||||
|
#include "observer/table_load/ob_table_load_client_service.h"
|
||||||
|
#include "observer/table_load/ob_table_load_client_task.h"
|
||||||
|
#include "observer/table_load/ob_table_load_coordinator.h"
|
||||||
|
#include "observer/table_load/ob_table_load_redef_table.h"
|
||||||
|
#include "observer/table_load/ob_table_load_schema.h"
|
||||||
|
#include "observer/table_load/ob_table_load_service.h"
|
||||||
|
#include "observer/table_load/ob_table_load_table_ctx.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
using namespace omt;
|
||||||
|
using namespace share::schema;
|
||||||
|
using namespace sql;
|
||||||
|
using namespace table;
|
||||||
|
|
||||||
|
// begin
|
||||||
|
ObTableDirectLoadBeginExecutor::ObTableDirectLoadBeginExecutor(
|
||||||
|
ObTableDirectLoadExecContext &ctx, const ObTableDirectLoadRequest &request,
|
||||||
|
ObTableDirectLoadResult &result)
|
||||||
|
: ParentType(ctx, request, result), client_task_(nullptr), table_ctx_(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ObTableDirectLoadBeginExecutor::~ObTableDirectLoadBeginExecutor()
|
||||||
|
{
|
||||||
|
if (nullptr != client_task_) {
|
||||||
|
ObTableLoadClientService::revert_task(client_task_);
|
||||||
|
client_task_ = nullptr;
|
||||||
|
}
|
||||||
|
if (nullptr != table_ctx_) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx_);
|
||||||
|
table_ctx_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadBeginExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(arg_.table_name_.empty() || arg_.parallel_ <= 0 ||
|
||||||
|
arg_.dup_action_ == ObLoadDupActionType::LOAD_INVALID_MODE ||
|
||||||
|
arg_.timeout_ <= 0)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadBeginExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
LOG_INFO("table direct load begin", K_(arg));
|
||||||
|
const uint64_t tenant_id = ctx_.get_tenant_id();
|
||||||
|
const uint64_t database_id = ctx_.get_database_id();
|
||||||
|
uint64_t table_id = 0;
|
||||||
|
|
||||||
|
THIS_WORKER.set_timeout_ts(ObTimeUtil::current_time() + arg_.timeout_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadSchema::get_table_id(tenant_id, database_id, arg_.table_name_,
|
||||||
|
table_id))) {
|
||||||
|
LOG_WARN("fail to get table id", KR(ret), K(tenant_id), K(database_id), K_(arg));
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the existing client task if it exists
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadKey key(tenant_id, table_id);
|
||||||
|
if (OB_FAIL(ObTableLoadClientService::get_task(key, client_task_))) {
|
||||||
|
if (OB_UNLIKELY(OB_ENTRY_NOT_EXIST != ret)) {
|
||||||
|
LOG_WARN("fail to get client task", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ret = OB_SUCCESS;
|
||||||
|
client_task_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create new client task if it does not exist
|
||||||
|
if (OB_SUCC(ret) && nullptr == client_task_) {
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_support_direct_load(table_id))) {
|
||||||
|
LOG_WARN("fail to check support direct load", KR(ret), K(table_id));
|
||||||
|
}
|
||||||
|
// create client task
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (OB_ISNULL(client_task_ = ObTableLoadClientService::alloc_task())) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("fail to alloc client task", KR(ret));
|
||||||
|
} else if (OB_FAIL(
|
||||||
|
client_task_->init(tenant_id, ctx_.get_user_id(), table_id, arg_.timeout_))) {
|
||||||
|
LOG_WARN("fail to init client task", KR(ret));
|
||||||
|
} else {
|
||||||
|
// create table ctx
|
||||||
|
if (OB_FAIL(create_table_ctx())) {
|
||||||
|
LOG_WARN("fail to create table ctx", KR(ret));
|
||||||
|
} else {
|
||||||
|
client_task_->ddl_param_ = table_ctx_->ddl_param_;
|
||||||
|
if (OB_FAIL(client_task_->set_table_ctx(table_ctx_))) {
|
||||||
|
LOG_WARN("fail to set table ctx", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
int tmp_ret = OB_SUCCESS;
|
||||||
|
if (OB_TMP_FAIL(ObTableLoadService::remove_ctx(table_ctx_))) {
|
||||||
|
LOG_WARN("fail to remove ctx", KR(tmp_ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// begin
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (OB_FAIL(do_begin())) {
|
||||||
|
LOG_WARN("fail to do begin", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (OB_FAIL(ObTableLoadClientService::add_task(client_task_))) {
|
||||||
|
LOG_WARN("fail to add client task", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
if (nullptr != table_ctx_) {
|
||||||
|
ObTableLoadCoordinator::abort_ctx(table_ctx_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill res
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
res_.table_id_ = client_task_->table_id_;
|
||||||
|
res_.task_id_ = client_task_->ddl_param_.task_id_;
|
||||||
|
if (OB_FAIL(res_.column_names_.assign(client_task_->column_names_))) {
|
||||||
|
LOG_WARN("fail to assign column names", KR(ret));
|
||||||
|
} else {
|
||||||
|
client_task_->get_status(res_.status_, res_.error_code_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadBeginExecutor::create_table_ctx()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
const uint64_t tenant_id = client_task_->tenant_id_;
|
||||||
|
const uint64_t table_id = client_task_->table_id_;
|
||||||
|
ObTableLoadDDLParam ddl_param;
|
||||||
|
ObTableLoadParam param;
|
||||||
|
// start redef table
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadRedefTableStartArg start_arg;
|
||||||
|
ObTableLoadRedefTableStartRes start_res;
|
||||||
|
uint64_t data_version = 0;
|
||||||
|
start_arg.tenant_id_ = tenant_id;
|
||||||
|
start_arg.table_id_ = table_id;
|
||||||
|
start_arg.parallelism_ = arg_.parallel_;
|
||||||
|
if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, data_version))) {
|
||||||
|
LOG_WARN("fail to get tenant data version", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadRedefTable::start(start_arg, start_res,
|
||||||
|
*client_task_->get_session_info()))) {
|
||||||
|
LOG_WARN("fail to start redef table", KR(ret), K(start_arg));
|
||||||
|
} else {
|
||||||
|
ddl_param.dest_table_id_ = start_res.dest_table_id_;
|
||||||
|
ddl_param.task_id_ = start_res.task_id_;
|
||||||
|
ddl_param.schema_version_ = start_res.schema_version_;
|
||||||
|
ddl_param.snapshot_version_ = start_res.snapshot_version_;
|
||||||
|
ddl_param.data_version_ = data_version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// init param
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTenant *tenant = nullptr;
|
||||||
|
if (OB_FAIL(GCTX.omt_->get_tenant(tenant_id, tenant))) {
|
||||||
|
LOG_WARN("fail to get tenant", KR(ret), K(tenant_id));
|
||||||
|
} else {
|
||||||
|
param.tenant_id_ = tenant_id;
|
||||||
|
param.table_id_ = table_id;
|
||||||
|
param.batch_size_ = 100;
|
||||||
|
param.parallel_ = arg_.parallel_;
|
||||||
|
param.session_count_ = MIN(arg_.parallel_, (int32_t)tenant->unit_max_cpu() * 2);
|
||||||
|
param.max_error_row_count_ = arg_.max_error_row_count_;
|
||||||
|
param.column_count_ = client_task_->column_names_.count();
|
||||||
|
param.need_sort_ = true;
|
||||||
|
param.px_mode_ = false;
|
||||||
|
param.online_opt_stat_gather_ = false;
|
||||||
|
param.dup_action_ = arg_.dup_action_;
|
||||||
|
if (OB_FAIL(param.normalize())) {
|
||||||
|
LOG_WARN("fail to normalize param", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (OB_ISNULL(table_ctx_ = ObTableLoadService::alloc_ctx())) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("fail to alloc table ctx", KR(ret), K(param));
|
||||||
|
} else if (OB_FAIL(table_ctx_->init(param, ddl_param, client_task_->get_session_info()))) {
|
||||||
|
LOG_WARN("fail to init table ctx", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadCoordinator::init_ctx(table_ctx_, client_task_->column_idxs_,
|
||||||
|
client_task_->get_exec_ctx()))) {
|
||||||
|
LOG_WARN("fail to coordinator init ctx", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadService::add_ctx(table_ctx_))) {
|
||||||
|
LOG_WARN("fail to add ctx", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
int tmp_ret = OB_SUCCESS;
|
||||||
|
if (ddl_param.is_valid()) {
|
||||||
|
ObTableLoadRedefTableAbortArg abort_arg;
|
||||||
|
abort_arg.tenant_id_ = param.tenant_id_;
|
||||||
|
abort_arg.task_id_ = ddl_param.task_id_;
|
||||||
|
if (OB_TMP_FAIL(
|
||||||
|
ObTableLoadRedefTable::abort(abort_arg, *client_task_->get_session_info()))) {
|
||||||
|
LOG_WARN("fail to abort redef table", KR(tmp_ret), K(abort_arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nullptr != table_ctx_) {
|
||||||
|
ObTableLoadService::free_ctx(table_ctx_);
|
||||||
|
table_ctx_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadBeginExecutor::do_begin()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadCoordinator coordinator(table_ctx_);
|
||||||
|
if (OB_FAIL(coordinator.init())) {
|
||||||
|
LOG_WARN("fail to init coordinator", KR(ret));
|
||||||
|
} else if (OB_FAIL(coordinator.begin())) {
|
||||||
|
LOG_WARN("fail to coordinator begin", KR(ret));
|
||||||
|
}
|
||||||
|
// start trans
|
||||||
|
for (int64_t i = 1; OB_SUCC(ret) && i <= table_ctx_->param_.session_count_; ++i) {
|
||||||
|
ObTableLoadSegmentID segment_id(i);
|
||||||
|
ObTableLoadTransId trans_id;
|
||||||
|
if (OB_FAIL(coordinator.start_trans(segment_id, trans_id))) {
|
||||||
|
LOG_WARN("fail to start trans", KR(ret), K(i));
|
||||||
|
} else if (OB_FAIL(client_task_->add_trans_id(trans_id))) {
|
||||||
|
LOG_WARN("fail to add trans id", KR(ret), K(trans_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (OB_FAIL(client_task_->set_status_running())) {
|
||||||
|
LOG_WARN("fail to set status running", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
client_task_->set_status_error(ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit
|
||||||
|
|
||||||
|
int ObTableDirectLoadCommitExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadCommitExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
LOG_INFO("table direct load commit", K_(arg));
|
||||||
|
ObTableLoadClientTask *client_task = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadClientService::get_task(key, client_task))) {
|
||||||
|
LOG_WARN("fail to get client task", KR(ret), K(key));
|
||||||
|
} else if (OB_FAIL(client_task->check_status(ObTableLoadClientStatus::RUNNING))) {
|
||||||
|
LOG_WARN("fail to check status", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadClientService::commit_task(client_task))) {
|
||||||
|
LOG_WARN("fail to commit client task", KR(ret));
|
||||||
|
}
|
||||||
|
if (nullptr != client_task) {
|
||||||
|
ObTableLoadClientService::revert_task(client_task);
|
||||||
|
client_task = nullptr;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// abort
|
||||||
|
|
||||||
|
int ObTableDirectLoadAbortExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadAbortExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
LOG_INFO("table direct load abort", K_(arg));
|
||||||
|
ObTableLoadClientTask *client_task = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadClientService::get_task(key, client_task))) {
|
||||||
|
LOG_WARN("fail to get client task", KR(ret), K(key));
|
||||||
|
} else if (OB_FAIL(ObTableLoadClientService::abort_task(client_task))) {
|
||||||
|
LOG_WARN("fail to abort client task", KR(ret));
|
||||||
|
}
|
||||||
|
if (nullptr != client_task) {
|
||||||
|
ObTableLoadClientService::revert_task(client_task);
|
||||||
|
client_task = nullptr;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get_status
|
||||||
|
|
||||||
|
int ObTableDirectLoadGetStatusExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadGetStatusExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
LOG_INFO("table direct load get status", K_(arg));
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
ObTableLoadClientTask *client_task = nullptr;
|
||||||
|
ObTableLoadClientTaskBrief *client_task_brief = nullptr;
|
||||||
|
if (OB_FAIL(ObTableLoadClientService::get_task(key, client_task))) {
|
||||||
|
if (OB_UNLIKELY(OB_ENTRY_NOT_EXIST != ret)) {
|
||||||
|
LOG_WARN("fail to get client task", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadClientService::get_task_brief(key, client_task_brief))) {
|
||||||
|
if (OB_UNLIKELY(OB_ENTRY_NOT_EXIST != ret)) {
|
||||||
|
LOG_WARN("fail to get client task brief", KR(ret), K(key));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res_.status_ = client_task_brief->client_status_;
|
||||||
|
res_.error_code_ = client_task_brief->error_code_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client_task->get_status(res_.status_, res_.error_code_);
|
||||||
|
}
|
||||||
|
if (nullptr != client_task) {
|
||||||
|
ObTableLoadClientService::revert_task(client_task);
|
||||||
|
client_task = nullptr;
|
||||||
|
}
|
||||||
|
if (nullptr != client_task_brief) {
|
||||||
|
ObTableLoadClientService::revert_task_brief(client_task_brief);
|
||||||
|
client_task_brief = nullptr;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert
|
||||||
|
|
||||||
|
int ObTableDirectLoadInsertExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_ || arg_.payload_.empty())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadInsertExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
LOG_DEBUG("table direct load insert", K_(arg));
|
||||||
|
ObTableLoadObjRowArray obj_rows;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
ObTableLoadClientTask *client_task = nullptr;
|
||||||
|
if (OB_FAIL(decode_payload(arg_.payload_, obj_rows))) {
|
||||||
|
LOG_WARN("fail to decode payload", KR(ret), K_(arg));
|
||||||
|
} else if (OB_FAIL(ObTableLoadClientService::get_task(key, client_task))) {
|
||||||
|
LOG_WARN("fail to get client task", KR(ret), K(key));
|
||||||
|
} else if (OB_FAIL(client_task->check_status(ObTableLoadClientStatus::RUNNING))) {
|
||||||
|
LOG_WARN("fail to check status", KR(ret));
|
||||||
|
} else {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
if (OB_FAIL(client_task->get_table_ctx(table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret));
|
||||||
|
} else {
|
||||||
|
ObTableLoadCoordinator coordinator(table_ctx);
|
||||||
|
ObTableLoadTransId trans_id;
|
||||||
|
if (OB_FAIL(client_task->get_next_trans_id(trans_id))) {
|
||||||
|
LOG_WARN("fail to get next trans id", KR(ret));
|
||||||
|
} else if (OB_FAIL(coordinator.init())) {
|
||||||
|
LOG_WARN("fail to init coordinator", KR(ret));
|
||||||
|
} else if (OB_FAIL(coordinator.write(trans_id, obj_rows))) {
|
||||||
|
LOG_WARN("fail to coordinator write", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nullptr != table_ctx) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
client_task->set_status_error(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nullptr != client_task) {
|
||||||
|
ObTableLoadClientService::revert_task(client_task);
|
||||||
|
client_task = nullptr;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableDirectLoadInsertExecutor::decode_payload(const ObString &payload,
|
||||||
|
ObTableLoadObjRowArray &obj_row_array)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(payload.empty())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(payload));
|
||||||
|
} else {
|
||||||
|
ObTableLoadSharedAllocatorHandle allocator_handle =
|
||||||
|
ObTableLoadSharedAllocatorHandle::make_handle();
|
||||||
|
const int64_t data_len = payload.length();
|
||||||
|
char *buf = nullptr;
|
||||||
|
int64_t pos = 0;
|
||||||
|
if (OB_ISNULL(buf = static_cast<char *>(allocator_handle->alloc(data_len)))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("fail to allocate memory", KR(ret), K(data_len));
|
||||||
|
} else {
|
||||||
|
MEMCPY(buf, payload.ptr(), data_len);
|
||||||
|
obj_row_array.set_allocator(allocator_handle);
|
||||||
|
if (OB_FAIL(obj_row_array.deserialize(buf, data_len, pos))) {
|
||||||
|
LOG_WARN("failed to deserialize obj rows", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,164 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ob_table_direct_load_exec_context.h"
|
||||||
|
#include "ob_table_direct_load_rpc_proxy.h"
|
||||||
|
#include "share/table/ob_table_load_row_array.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
class ObTableLoadClientTask;
|
||||||
|
class ObTableLoadTableCtx;
|
||||||
|
|
||||||
|
template <table::ObTableDirectLoadOperationType pcode>
|
||||||
|
class ObTableDirectLoadRpcExecutor
|
||||||
|
: public ObTableLoadRpcExecutor<ObTableDirectLoadRpcProxy::ObTableDirectLoadRpc<pcode>>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadRpcExecutor<ObTableDirectLoadRpcProxy::ObTableDirectLoadRpc<pcode>> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadRpcExecutor(ObTableDirectLoadExecContext &ctx,
|
||||||
|
const table::ObTableDirectLoadRequest &request,
|
||||||
|
table::ObTableDirectLoadResult &result)
|
||||||
|
: ParentType(request, result), ctx_(ctx)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObTableDirectLoadRpcExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int deserialize() override { return this->request_.get_arg(this->arg_); }
|
||||||
|
int serialize() override
|
||||||
|
{
|
||||||
|
this->result_.operation_type_ = pcode;
|
||||||
|
return this->result_.set_res(this->res_, ctx_.get_allocator());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ObTableDirectLoadExecContext &ctx_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// begin
|
||||||
|
class ObTableDirectLoadBeginExecutor
|
||||||
|
: public ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::BEGIN>
|
||||||
|
{
|
||||||
|
typedef ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::BEGIN> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadBeginExecutor(ObTableDirectLoadExecContext &ctx,
|
||||||
|
const table::ObTableDirectLoadRequest &request,
|
||||||
|
table::ObTableDirectLoadResult &result);
|
||||||
|
virtual ~ObTableDirectLoadBeginExecutor();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int create_table_ctx();
|
||||||
|
int do_begin();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ObTableLoadClientTask *client_task_;
|
||||||
|
ObTableLoadTableCtx *table_ctx_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// commit
|
||||||
|
class ObTableDirectLoadCommitExecutor
|
||||||
|
: public ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::COMMIT>
|
||||||
|
{
|
||||||
|
typedef ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::COMMIT> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadCommitExecutor(ObTableDirectLoadExecContext &ctx,
|
||||||
|
const table::ObTableDirectLoadRequest &request,
|
||||||
|
table::ObTableDirectLoadResult &result)
|
||||||
|
: ParentType(ctx, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObTableDirectLoadCommitExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// abort
|
||||||
|
class ObTableDirectLoadAbortExecutor
|
||||||
|
: public ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::ABORT>
|
||||||
|
{
|
||||||
|
typedef ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::ABORT> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadAbortExecutor(ObTableDirectLoadExecContext &ctx,
|
||||||
|
const table::ObTableDirectLoadRequest &request,
|
||||||
|
table::ObTableDirectLoadResult &result)
|
||||||
|
: ParentType(ctx, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObTableDirectLoadAbortExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// get_status
|
||||||
|
class ObTableDirectLoadGetStatusExecutor
|
||||||
|
: public ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::GET_STATUS>
|
||||||
|
{
|
||||||
|
typedef ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::GET_STATUS>
|
||||||
|
ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadGetStatusExecutor(ObTableDirectLoadExecContext &ctx,
|
||||||
|
const table::ObTableDirectLoadRequest &request,
|
||||||
|
table::ObTableDirectLoadResult &result)
|
||||||
|
: ParentType(ctx, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObTableDirectLoadGetStatusExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// insert
|
||||||
|
class ObTableDirectLoadInsertExecutor
|
||||||
|
: public ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::INSERT>
|
||||||
|
{
|
||||||
|
typedef ObTableDirectLoadRpcExecutor<table::ObTableDirectLoadOperationType::INSERT> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadInsertExecutor(ObTableDirectLoadExecContext &ctx,
|
||||||
|
const table::ObTableDirectLoadRequest &request,
|
||||||
|
table::ObTableDirectLoadResult &result)
|
||||||
|
: ParentType(ctx, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObTableDirectLoadInsertExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static int decode_payload(const common::ObString &payload,
|
||||||
|
table::ObTableLoadObjRowArray &obj_row_array);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "ob_table_direct_load_rpc_proxy.h"
|
||||||
|
#include "ob_table_direct_load_rpc_executor.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
using namespace table;
|
||||||
|
|
||||||
|
int ObTableDirectLoadRpcProxy::dispatch(ObTableDirectLoadExecContext &ctx,
|
||||||
|
const ObTableDirectLoadRequest &request,
|
||||||
|
ObTableDirectLoadResult &result)
|
||||||
|
{
|
||||||
|
#define OB_TABLE_DIRECT_LOAD_RPC_DISPATCH(pcode) \
|
||||||
|
case pcode: \
|
||||||
|
OB_TABLE_LOAD_RPC_PROCESS(ObTableDirectLoadRpc, pcode, request, result, ctx); \
|
||||||
|
break;
|
||||||
|
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
switch (request.operation_type_) {
|
||||||
|
OB_TABLE_DIRECT_LOAD_RPC_DISPATCH(ObTableDirectLoadOperationType::BEGIN);
|
||||||
|
OB_TABLE_DIRECT_LOAD_RPC_DISPATCH(ObTableDirectLoadOperationType::COMMIT);
|
||||||
|
OB_TABLE_DIRECT_LOAD_RPC_DISPATCH(ObTableDirectLoadOperationType::ABORT);
|
||||||
|
OB_TABLE_DIRECT_LOAD_RPC_DISPATCH(ObTableDirectLoadOperationType::GET_STATUS);
|
||||||
|
OB_TABLE_DIRECT_LOAD_RPC_DISPATCH(ObTableDirectLoadOperationType::INSERT);
|
||||||
|
default:
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
SERVER_LOG(WARN, "unexpected command type", K(ret), K(request));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
160
src/observer/table_load/client/ob_table_direct_load_rpc_proxy.h
Normal file
160
src/observer/table_load/client/ob_table_direct_load_rpc_proxy.h
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ob_table_direct_load_rpc_struct.h"
|
||||||
|
#include "observer/table_load/ob_table_load_rpc_executor.h"
|
||||||
|
#include "share/table/ob_table_rpc_proxy.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
class ObTableDirectLoadExecContext;
|
||||||
|
class ObTableDirectLoadBeginExecutor;
|
||||||
|
class ObTableDirectLoadCommitExecutor;
|
||||||
|
class ObTableDirectLoadAbortExecutor;
|
||||||
|
class ObTableDirectLoadGetStatusExecutor;
|
||||||
|
class ObTableDirectLoadInsertExecutor;
|
||||||
|
|
||||||
|
class ObTableDirectLoadRpcProxy
|
||||||
|
{
|
||||||
|
static const int64_t DEFAULT_TIMEOUT_US = 10LL * 1000 * 1000; // 10s
|
||||||
|
public:
|
||||||
|
template <table::ObTableDirectLoadOperationType pcode, typename IGNORE = void>
|
||||||
|
struct ObTableDirectLoadRpc
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_DIRECT_LOAD_RPC_CALL_1(name, pcode, Arg) \
|
||||||
|
int name(const Arg &arg) \
|
||||||
|
{ \
|
||||||
|
int ret = OB_SUCCESS; \
|
||||||
|
table::ObTableDirectLoadRequest request; \
|
||||||
|
table::ObTableDirectLoadResult result; \
|
||||||
|
request.credential_ = credential_; \
|
||||||
|
request.operation_type_ = pcode; \
|
||||||
|
if (OB_FAIL(request.set_arg(arg, allocator_))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to set arg", K(ret), K(arg)); \
|
||||||
|
} else if (OB_FAIL(rpc_proxy_.to(addr_) \
|
||||||
|
.timeout(timeout_) \
|
||||||
|
.by(tenant_id_) \
|
||||||
|
.direct_load(request, result))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to rpc call direct load", K(ret), K_(addr), K(request)); \
|
||||||
|
} else if (OB_UNLIKELY(result.operation_type_ != pcode)) { \
|
||||||
|
ret = OB_ERR_UNEXPECTED; \
|
||||||
|
SERVER_LOG(WARN, "unexpected operation type", K(ret), K(request), K(result)); \
|
||||||
|
} else if (OB_UNLIKELY(!result.res_content_.empty())) { \
|
||||||
|
ret = OB_ERR_UNEXPECTED; \
|
||||||
|
SERVER_LOG(WARN, "unexpected non empty res content", K(ret), K(result)); \
|
||||||
|
} \
|
||||||
|
return ret; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_DIRECT_LOAD_RPC_CALL_2(name, pcode, Arg, Res) \
|
||||||
|
int name(const Arg &arg, Res &res) \
|
||||||
|
{ \
|
||||||
|
int ret = OB_SUCCESS; \
|
||||||
|
table::ObTableDirectLoadRequest request; \
|
||||||
|
table::ObTableDirectLoadResult result; \
|
||||||
|
request.credential_ = credential_; \
|
||||||
|
request.operation_type_ = pcode; \
|
||||||
|
if (OB_FAIL(request.set_arg(arg, allocator_))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to set arg", K(ret), K(arg)); \
|
||||||
|
} else if (OB_FAIL(rpc_proxy_.to(addr_) \
|
||||||
|
.timeout(timeout_) \
|
||||||
|
.by(tenant_id_) \
|
||||||
|
.direct_load(request, result))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to rpc call direct load", K(ret), K_(addr), K(request)); \
|
||||||
|
} else if (OB_UNLIKELY(result.operation_type_ != pcode)) { \
|
||||||
|
ret = OB_ERR_UNEXPECTED; \
|
||||||
|
SERVER_LOG(WARN, "unexpected operation type", K(ret), K(request), K(result)); \
|
||||||
|
} else if (OB_FAIL(result.get_res(res))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to get res", K(ret), K(result)); \
|
||||||
|
} \
|
||||||
|
return ret; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_DIRECT_LOAD_RPC_CALL(name, pcode, ...) \
|
||||||
|
CONCAT(OB_DEFINE_TABLE_DIRECT_LOAD_RPC_CALL_, ARGS_NUM(__VA_ARGS__))(name, pcode, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_DIRECT_LOAD_RPC(name, pcode, Processor, ...) \
|
||||||
|
OB_DEFINE_TABLE_LOAD_RPC(ObTableDirectLoadRpc, pcode, Processor, \
|
||||||
|
table::ObTableDirectLoadRequest, table::ObTableDirectLoadResult, \
|
||||||
|
__VA_ARGS__) \
|
||||||
|
OB_DEFINE_TABLE_DIRECT_LOAD_RPC_CALL(name, pcode, __VA_ARGS__)
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadRpcProxy(obrpc::ObTableRpcProxy &rpc_proxy)
|
||||||
|
: rpc_proxy_(rpc_proxy),
|
||||||
|
allocator_("TLD_RpcProxy"),
|
||||||
|
timeout_(DEFAULT_TIMEOUT_US),
|
||||||
|
tenant_id_(MTL_ID())
|
||||||
|
{
|
||||||
|
allocator_.set_tenant_id(MTL_ID());
|
||||||
|
}
|
||||||
|
|
||||||
|
ObTableDirectLoadRpcProxy &to(ObAddr addr)
|
||||||
|
{
|
||||||
|
addr_ = addr;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ObTableDirectLoadRpcProxy &timeout(int64_t timeout)
|
||||||
|
{
|
||||||
|
timeout_ = timeout;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ObTableDirectLoadRpcProxy &by(uint64_t tenant_id)
|
||||||
|
{
|
||||||
|
tenant_id_ = tenant_id;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ObTableDirectLoadRpcProxy &set_credential(const ObString &credential)
|
||||||
|
{
|
||||||
|
credential_ = credential;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dispatch(ObTableDirectLoadExecContext &ctx,
|
||||||
|
const table::ObTableDirectLoadRequest &request,
|
||||||
|
table::ObTableDirectLoadResult &result);
|
||||||
|
|
||||||
|
// begin
|
||||||
|
OB_DEFINE_TABLE_DIRECT_LOAD_RPC(begin, table::ObTableDirectLoadOperationType::BEGIN,
|
||||||
|
ObTableDirectLoadBeginExecutor, ObTableDirectLoadBeginArg,
|
||||||
|
ObTableDirectLoadBeginRes);
|
||||||
|
// commit
|
||||||
|
OB_DEFINE_TABLE_DIRECT_LOAD_RPC(commit, table::ObTableDirectLoadOperationType::COMMIT,
|
||||||
|
ObTableDirectLoadCommitExecutor, ObTableDirectLoadCommitArg);
|
||||||
|
// abort
|
||||||
|
OB_DEFINE_TABLE_DIRECT_LOAD_RPC(abort, table::ObTableDirectLoadOperationType::ABORT,
|
||||||
|
ObTableDirectLoadAbortExecutor, ObTableDirectLoadAbortArg);
|
||||||
|
// get_status
|
||||||
|
OB_DEFINE_TABLE_DIRECT_LOAD_RPC(get_status, table::ObTableDirectLoadOperationType::GET_STATUS,
|
||||||
|
ObTableDirectLoadGetStatusExecutor, ObTableDirectLoadGetStatusArg,
|
||||||
|
ObTableDirectLoadGetStatusRes);
|
||||||
|
// insert
|
||||||
|
OB_DEFINE_TABLE_DIRECT_LOAD_RPC(insert, table::ObTableDirectLoadOperationType::INSERT,
|
||||||
|
ObTableDirectLoadInsertExecutor, ObTableDirectLoadInsertArg);
|
||||||
|
|
||||||
|
private:
|
||||||
|
obrpc::ObTableRpcProxy &rpc_proxy_;
|
||||||
|
ObArenaAllocator allocator_;
|
||||||
|
ObAddr addr_;
|
||||||
|
int64_t timeout_;
|
||||||
|
uint64_t tenant_id_;
|
||||||
|
ObString credential_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "ob_table_direct_load_rpc_struct.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
|
||||||
|
// begin
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObTableDirectLoadBeginArg,
|
||||||
|
table_name_,
|
||||||
|
parallel_,
|
||||||
|
max_error_row_count_,
|
||||||
|
dup_action_,
|
||||||
|
timeout_);
|
||||||
|
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObTableDirectLoadBeginRes,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
column_names_,
|
||||||
|
status_,
|
||||||
|
error_code_);
|
||||||
|
|
||||||
|
// commit
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObTableDirectLoadCommitArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_);
|
||||||
|
|
||||||
|
// abort
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObTableDirectLoadAbortArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_);
|
||||||
|
|
||||||
|
// get_status
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObTableDirectLoadGetStatusArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_);
|
||||||
|
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObTableDirectLoadGetStatusRes,
|
||||||
|
status_,
|
||||||
|
error_code_);
|
||||||
|
|
||||||
|
// insert
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObTableDirectLoadInsertArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
payload_);
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
125
src/observer/table_load/client/ob_table_direct_load_rpc_struct.h
Normal file
125
src/observer/table_load/client/ob_table_direct_load_rpc_struct.h
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "lib/container/ob_array_serialization.h"
|
||||||
|
#include "lib/utility/ob_print_utils.h"
|
||||||
|
#include "lib/utility/ob_unify_serialize.h"
|
||||||
|
#include "share/table/ob_table_load_define.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
|
||||||
|
struct ObTableDirectLoadBeginArg
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadBeginArg()
|
||||||
|
: parallel_(0),
|
||||||
|
max_error_row_count_(0),
|
||||||
|
dup_action_(sql::ObLoadDupActionType::LOAD_INVALID_MODE),
|
||||||
|
timeout_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(table_name), K_(parallel), K_(max_error_row_count), K_(dup_action), K_(timeout));
|
||||||
|
public:
|
||||||
|
ObString table_name_;
|
||||||
|
int64_t parallel_;
|
||||||
|
uint64_t max_error_row_count_;
|
||||||
|
sql::ObLoadDupActionType dup_action_;
|
||||||
|
int64_t timeout_;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObTableDirectLoadBeginRes
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadBeginRes()
|
||||||
|
: table_id_(common::OB_INVALID_ID),
|
||||||
|
task_id_(0),
|
||||||
|
status_(table::ObTableLoadClientStatus::MAX_STATUS),
|
||||||
|
error_code_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), K_(column_names), K_(status), K_(error_code));
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
common::ObSArray<ObString> column_names_;
|
||||||
|
table::ObTableLoadClientStatus status_;
|
||||||
|
int32_t error_code_;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObTableDirectLoadCommitArg
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadCommitArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id));
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObTableDirectLoadAbortArg
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadAbortArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id));
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObTableDirectLoadGetStatusArg
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadGetStatusArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id));
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObTableDirectLoadGetStatusRes
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadGetStatusRes()
|
||||||
|
: status_(table::ObTableLoadClientStatus::MAX_STATUS), error_code_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(status), K_(error_code));
|
||||||
|
public:
|
||||||
|
table::ObTableLoadClientStatus status_;
|
||||||
|
int32_t error_code_;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObTableDirectLoadInsertArg
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadInsertArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), "payload", common::ObHexStringWrap(payload_));
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
ObString payload_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,636 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "ob_table_load_control_rpc_executor.h"
|
||||||
|
#include "observer/table_load/ob_table_load_service.h"
|
||||||
|
#include "observer/table_load/ob_table_load_store.h"
|
||||||
|
#include "observer/table_load/ob_table_load_table_ctx.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
using namespace table;
|
||||||
|
|
||||||
|
// pre_begin
|
||||||
|
int ObDirectLoadControlPreBeginExecutor::deserialize()
|
||||||
|
{
|
||||||
|
arg_.partition_id_array_.set_allocator(allocator_);
|
||||||
|
arg_.target_partition_id_array_.set_allocator(allocator_);
|
||||||
|
return ParentType::deserialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlPreBeginExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlPreBeginExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadParam param;
|
||||||
|
param.tenant_id_ = MTL_ID();
|
||||||
|
param.table_id_ = arg_.table_id_;
|
||||||
|
param.batch_size_ = arg_.config_.batch_size_;
|
||||||
|
param.parallel_ = arg_.config_.parallel_;
|
||||||
|
param.session_count_ = arg_.config_.parallel_;
|
||||||
|
param.max_error_row_count_ = arg_.config_.max_error_row_count_;
|
||||||
|
param.column_count_ = arg_.column_count_;
|
||||||
|
param.need_sort_ = arg_.config_.is_need_sort_;
|
||||||
|
param.px_mode_ = arg_.px_mode_;
|
||||||
|
param.online_opt_stat_gather_ = arg_.online_opt_stat_gather_;
|
||||||
|
param.dup_action_ = arg_.dup_action_;
|
||||||
|
ObTableLoadDDLParam ddl_param;
|
||||||
|
uint64_t data_version = 0;
|
||||||
|
ddl_param.dest_table_id_ = arg_.dest_table_id_;
|
||||||
|
ddl_param.task_id_ = arg_.task_id_;
|
||||||
|
ddl_param.schema_version_ = arg_.schema_version_;
|
||||||
|
ddl_param.snapshot_version_ = arg_.snapshot_version_;
|
||||||
|
ddl_param.data_version_ = arg_.data_version_;
|
||||||
|
if (OB_FAIL(create_table_ctx(param, ddl_param, table_ctx))) {
|
||||||
|
LOG_WARN("fail to create table ctx", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.pre_begin())) {
|
||||||
|
LOG_WARN("fail to store pre begin", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlPreBeginExecutor::create_table_ctx(const ObTableLoadParam ¶m,
|
||||||
|
const ObTableLoadDDLParam &ddl_param,
|
||||||
|
ObTableLoadTableCtx *&table_ctx)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
table_ctx = nullptr;
|
||||||
|
if (OB_ISNULL(table_ctx = ObTableLoadService::alloc_ctx())) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("fail to alloc table ctx", KR(ret), K(param));
|
||||||
|
} else if (OB_FAIL(table_ctx->init(param, ddl_param, arg_.session_info_))) {
|
||||||
|
LOG_WARN("fail to init table ctx", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadStore::init_ctx(table_ctx, arg_.partition_id_array_,
|
||||||
|
arg_.target_partition_id_array_))) {
|
||||||
|
LOG_WARN("fail to store init ctx", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadService::add_ctx(table_ctx))) {
|
||||||
|
LOG_WARN("fail to add ctx", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
if (nullptr != table_ctx) {
|
||||||
|
ObTableLoadService::free_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// confirm_begin
|
||||||
|
int ObDirectLoadControlConfirmBeginExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlConfirmBeginExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.confirm_begin())) {
|
||||||
|
LOG_WARN("fail to store confirm begin", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pre_merge
|
||||||
|
int ObDirectLoadControlPreMergeExecutor::deserialize()
|
||||||
|
{
|
||||||
|
arg_.committed_trans_id_array_.set_allocator(allocator_);
|
||||||
|
return ParentType::deserialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlPreMergeExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlPreMergeExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.pre_merge(arg_.committed_trans_id_array_))) {
|
||||||
|
LOG_WARN("fail to store pre merge", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// start_merge
|
||||||
|
int ObDirectLoadControlStartMergeExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlStartMergeExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.start_merge())) {
|
||||||
|
LOG_WARN("fail to store start merge", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit
|
||||||
|
int ObDirectLoadControlCommitExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlCommitExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.commit(res_.result_info_, res_.sql_statistics_))) {
|
||||||
|
LOG_WARN("fail to store commit", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadService::remove_ctx(table_ctx))) {
|
||||||
|
LOG_WARN("fail to remove table ctx", KR(ret), K(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// abort
|
||||||
|
int ObDirectLoadControlAbortExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlAbortExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
if (OB_UNLIKELY(OB_ENTRY_NOT_EXIST == ret)) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(ObTableLoadService::remove_ctx(table_ctx))) {
|
||||||
|
LOG_WARN("fail to remove table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore::abort_ctx(table_ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get_status
|
||||||
|
int ObDirectLoadControlGetStatusExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlGetStatusExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.get_status(res_.status_, res_.error_code_))) {
|
||||||
|
LOG_WARN("fail to store get status", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// trans
|
||||||
|
// pre_start_trans
|
||||||
|
int ObDirectLoadControlPreStartTransExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_ ||
|
||||||
|
!arg_.trans_id_.is_valid())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlPreStartTransExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.pre_start_trans(arg_.trans_id_))) {
|
||||||
|
LOG_WARN("fail to store pre start trans", KR(ret), K(arg_.trans_id_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// confirm_start_trans
|
||||||
|
int ObDirectLoadControlConfirmStartTransExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_ ||
|
||||||
|
!arg_.trans_id_.is_valid())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlConfirmStartTransExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.confirm_start_trans(arg_.trans_id_))) {
|
||||||
|
LOG_WARN("fail to store confirm start trans", KR(ret), K(arg_.trans_id_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pre_finish_trans
|
||||||
|
int ObDirectLoadControlPreFinishTransExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_ ||
|
||||||
|
!arg_.trans_id_.is_valid())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlPreFinishTransExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.pre_finish_trans(arg_.trans_id_))) {
|
||||||
|
LOG_WARN("fail to store pre finish trans", KR(ret), K(arg_.trans_id_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// confirm_finish_trans
|
||||||
|
int ObDirectLoadControlConfirmFinishTransExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_ ||
|
||||||
|
!arg_.trans_id_.is_valid())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlConfirmFinishTransExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.confirm_finish_trans(arg_.trans_id_))) {
|
||||||
|
LOG_WARN("fail to store confirm finish trans", KR(ret), K(arg_.trans_id_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// abandon_trans
|
||||||
|
int ObDirectLoadControlAbandonTransExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_ ||
|
||||||
|
!arg_.trans_id_.is_valid())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlAbandonTransExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.abandon_trans(arg_.trans_id_))) {
|
||||||
|
LOG_WARN("fail to store abandon trans", KR(ret), K(arg_.trans_id_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get_trans_status
|
||||||
|
int ObDirectLoadControlGetTransStatusExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_ ||
|
||||||
|
!arg_.trans_id_.is_valid())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlGetTransStatusExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(
|
||||||
|
store.get_trans_status(arg_.trans_id_, res_.trans_status_, res_.error_code_))) {
|
||||||
|
LOG_WARN("fail to store get trans status", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert_trans
|
||||||
|
int ObDirectLoadControlInsertTransExecutor::check_args()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_INVALID_ID == arg_.table_id_ || 0 == arg_.task_id_ ||
|
||||||
|
!arg_.trans_id_.is_valid())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObDirectLoadControlInsertTransExecutor::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
||||||
|
ObTableLoadSharedAllocatorHandle allocator_handle =
|
||||||
|
ObTableLoadSharedAllocatorHandle::make_handle();
|
||||||
|
int64_t data_len = arg_.payload_.length();
|
||||||
|
char *buf = nullptr;
|
||||||
|
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
||||||
|
} else if (!allocator_handle) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("failed to make allocator handle", KR(ret));
|
||||||
|
} else if (OB_ISNULL(buf = static_cast<char *>(allocator_handle->alloc(data_len)))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("failed to allocate memory", KR(ret));
|
||||||
|
} else {
|
||||||
|
int64_t pos = 0;
|
||||||
|
ObTableLoadStore store(table_ctx);
|
||||||
|
ObTableLoadTabletObjRowArray row_array;
|
||||||
|
row_array.set_allocator(allocator_handle);
|
||||||
|
MEMCPY(buf, arg_.payload_.ptr(), data_len);
|
||||||
|
if (OB_FAIL(row_array.deserialize(buf, data_len, pos))) {
|
||||||
|
LOG_WARN("failed to deserialize obj rows", KR(ret));
|
||||||
|
} else if (OB_FAIL(store.init())) {
|
||||||
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
|
} else if (OB_FAIL(
|
||||||
|
store.write(arg_.trans_id_, arg_.session_id_, arg_.sequence_no_, row_array))) {
|
||||||
|
LOG_WARN("fail to store write", KR(ret), K_(arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(table_ctx)) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,345 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ob_table_load_control_rpc_proxy.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
class ObTableLoadParam;
|
||||||
|
class ObTableLoadDDLParam;
|
||||||
|
class ObTableLoadTableCtx;
|
||||||
|
|
||||||
|
template <ObDirectLoadControlCommandType pcode>
|
||||||
|
class ObTableLoadControlRpcExecutor
|
||||||
|
: public ObTableLoadRpcExecutor<ObTableLoadControlRpcProxy::ObTableLoadControlRpc<pcode>>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadRpcExecutor<ObTableLoadControlRpcProxy::ObTableLoadControlRpc<pcode>>
|
||||||
|
ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableLoadControlRpcExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(request, result), allocator_(allocator)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObTableLoadControlRpcExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int deserialize() override { return this->request_.get_arg(this->arg_); }
|
||||||
|
int serialize() override
|
||||||
|
{
|
||||||
|
this->result_.command_type_ = pcode;
|
||||||
|
return this->result_.set_res(this->res_, allocator_);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
common::ObIAllocator &allocator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// pre_begin
|
||||||
|
class ObDirectLoadControlPreBeginExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::PRE_BEGIN>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::PRE_BEGIN> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlPreBeginExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlPreBeginExecutor() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int create_table_ctx(const ObTableLoadParam ¶m, const ObTableLoadDDLParam &ddl_param,
|
||||||
|
ObTableLoadTableCtx *&table_ctx);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int deserialize() override;
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// confirm_begin
|
||||||
|
class ObDirectLoadControlConfirmBeginExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::CONFIRM_BEGIN>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::CONFIRM_BEGIN> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlConfirmBeginExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlConfirmBeginExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// pre_merge
|
||||||
|
class ObDirectLoadControlPreMergeExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::PRE_MERGE>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::PRE_MERGE> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlPreMergeExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlPreMergeExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int deserialize() override;
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// start_merge
|
||||||
|
class ObDirectLoadControlStartMergeExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::START_MERGE>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::START_MERGE> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlStartMergeExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlStartMergeExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// commit
|
||||||
|
class ObDirectLoadControlCommitExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::COMMIT>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::COMMIT> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlCommitExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlCommitExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// abort
|
||||||
|
class ObDirectLoadControlAbortExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::ABORT>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::ABORT> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlAbortExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlAbortExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// get_status
|
||||||
|
class ObDirectLoadControlGetStatusExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::GET_STATUS>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::GET_STATUS> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlGetStatusExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlGetStatusExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// trans
|
||||||
|
// pre_start_trans
|
||||||
|
class ObDirectLoadControlPreStartTransExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::PRE_START_TRANS>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::PRE_START_TRANS> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlPreStartTransExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlPreStartTransExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// confirm_start_trans
|
||||||
|
class ObDirectLoadControlConfirmStartTransExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::CONFIRM_START_TRANS>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::CONFIRM_START_TRANS>
|
||||||
|
ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlConfirmStartTransExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlConfirmStartTransExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// pre_finish_trans
|
||||||
|
class ObDirectLoadControlPreFinishTransExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::PRE_FINISH_TRANS>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::PRE_FINISH_TRANS>
|
||||||
|
ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlPreFinishTransExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlPreFinishTransExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// confirm_finish_trans
|
||||||
|
class ObDirectLoadControlConfirmFinishTransExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::CONFIRM_FINISH_TRANS>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::CONFIRM_FINISH_TRANS>
|
||||||
|
ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlConfirmFinishTransExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlConfirmFinishTransExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// abandon_trans
|
||||||
|
class ObDirectLoadControlAbandonTransExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::ABANDON_TRANS>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::ABANDON_TRANS> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlAbandonTransExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlAbandonTransExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// get_trans_status
|
||||||
|
class ObDirectLoadControlGetTransStatusExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::GET_TRANS_STATUS>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::GET_TRANS_STATUS>
|
||||||
|
ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlGetTransStatusExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlGetTransStatusExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
// insert_trans
|
||||||
|
class ObDirectLoadControlInsertTransExecutor
|
||||||
|
: public ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::INSERT_TRANS>
|
||||||
|
{
|
||||||
|
typedef ObTableLoadControlRpcExecutor<ObDirectLoadControlCommandType::INSERT_TRANS> ParentType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlInsertTransExecutor(common::ObIAllocator &allocator,
|
||||||
|
const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result)
|
||||||
|
: ParentType(allocator, request, result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObDirectLoadControlInsertTransExecutor() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int check_args() override;
|
||||||
|
int process() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "ob_table_load_control_rpc_proxy.h"
|
||||||
|
#include "ob_table_load_control_rpc_executor.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
using namespace common;
|
||||||
|
|
||||||
|
int ObTableLoadControlRpcProxy::dispatch(const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result, ObIAllocator &allocator)
|
||||||
|
{
|
||||||
|
#define OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(pcode) \
|
||||||
|
case pcode: \
|
||||||
|
OB_TABLE_LOAD_RPC_PROCESS(ObTableLoadControlRpc, pcode, request, result, allocator); \
|
||||||
|
break;
|
||||||
|
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
switch (request.command_type_) {
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::PRE_BEGIN);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::CONFIRM_BEGIN);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::PRE_MERGE);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::START_MERGE);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::COMMIT);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::ABORT);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::GET_STATUS);
|
||||||
|
/// trans
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::PRE_START_TRANS);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::CONFIRM_START_TRANS);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::PRE_FINISH_TRANS);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::CONFIRM_FINISH_TRANS);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::ABANDON_TRANS);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::GET_TRANS_STATUS);
|
||||||
|
OB_TABLE_LOAD_CONTROL_RPC_DISPATCH(ObDirectLoadControlCommandType::INSERT_TRANS);
|
||||||
|
default:
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
SERVER_LOG(WARN, "unexpected command type", K(ret), K(request));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,204 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ob_table_load_control_rpc_struct.h"
|
||||||
|
#include "observer/table_load/ob_table_load_rpc_executor.h"
|
||||||
|
#include "share/ob_srv_rpc_proxy.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
class ObDirectLoadControlPreBeginExecutor;
|
||||||
|
class ObDirectLoadControlConfirmBeginExecutor;
|
||||||
|
class ObDirectLoadControlPreMergeExecutor;
|
||||||
|
class ObDirectLoadControlStartMergeExecutor;
|
||||||
|
class ObDirectLoadControlCommitExecutor;
|
||||||
|
class ObDirectLoadControlAbortExecutor;
|
||||||
|
class ObDirectLoadControlGetStatusExecutor;
|
||||||
|
/// trans
|
||||||
|
class ObDirectLoadControlPreStartTransExecutor;
|
||||||
|
class ObDirectLoadControlConfirmStartTransExecutor;
|
||||||
|
class ObDirectLoadControlPreFinishTransExecutor;
|
||||||
|
class ObDirectLoadControlConfirmFinishTransExecutor;
|
||||||
|
class ObDirectLoadControlAbandonTransExecutor;
|
||||||
|
class ObDirectLoadControlGetTransStatusExecutor;
|
||||||
|
class ObDirectLoadControlInsertTransExecutor;
|
||||||
|
|
||||||
|
class ObTableLoadControlRpcProxy
|
||||||
|
{
|
||||||
|
static const int64_t DEFAULT_TIMEOUT_US = 10LL * 1000 * 1000; // 10s
|
||||||
|
public:
|
||||||
|
template <ObDirectLoadControlCommandType pcode, typename IGNORE = void>
|
||||||
|
struct ObTableLoadControlRpc
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_LOAD_CONTROL_RPC_CALL_1(name, pcode, Arg) \
|
||||||
|
int name(const Arg &arg) \
|
||||||
|
{ \
|
||||||
|
int ret = OB_SUCCESS; \
|
||||||
|
ObDirectLoadControlRequest request; \
|
||||||
|
ObDirectLoadControlResult result; \
|
||||||
|
request.command_type_ = pcode; \
|
||||||
|
if (OB_FAIL(request.set_arg(arg, allocator_))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to set arg", K(ret), K(arg)); \
|
||||||
|
} else if (OB_FAIL(rpc_proxy_.to(addr_) \
|
||||||
|
.timeout(timeout_) \
|
||||||
|
.by(tenant_id_) \
|
||||||
|
.direct_load_control(request, result))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to rpc call direct load control", K(ret), K_(addr), K(request)); \
|
||||||
|
} else if (OB_UNLIKELY(result.command_type_ != pcode)) { \
|
||||||
|
ret = OB_ERR_UNEXPECTED; \
|
||||||
|
SERVER_LOG(WARN, "unexpected command type", K(ret), K(request), K(result)); \
|
||||||
|
} else if (OB_UNLIKELY(!result.res_content_.empty())) { \
|
||||||
|
ret = OB_ERR_UNEXPECTED; \
|
||||||
|
SERVER_LOG(WARN, "unexpected non empty res content", K(ret), K(result)); \
|
||||||
|
} \
|
||||||
|
return ret; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_LOAD_CONTROL_RPC_CALL_2(name, pcode, Arg, Res) \
|
||||||
|
int name(const Arg &arg, Res &res) \
|
||||||
|
{ \
|
||||||
|
int ret = OB_SUCCESS; \
|
||||||
|
ObDirectLoadControlRequest request; \
|
||||||
|
ObDirectLoadControlResult result; \
|
||||||
|
request.command_type_ = pcode; \
|
||||||
|
if (OB_FAIL(request.set_arg(arg, allocator_))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to set arg", K(ret), K(arg)); \
|
||||||
|
} else if (OB_FAIL(rpc_proxy_.to(addr_) \
|
||||||
|
.timeout(timeout_) \
|
||||||
|
.by(tenant_id_) \
|
||||||
|
.direct_load_control(request, result))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to rpc call direct load control", K(ret), K_(addr), K(request)); \
|
||||||
|
} else if (OB_UNLIKELY(result.command_type_ != pcode)) { \
|
||||||
|
ret = OB_ERR_UNEXPECTED; \
|
||||||
|
SERVER_LOG(WARN, "unexpected command type", K(ret), K(request), K(result)); \
|
||||||
|
} else if (OB_FAIL(result.get_res(res))) { \
|
||||||
|
SERVER_LOG(WARN, "fail to get res", K(ret), K(result)); \
|
||||||
|
} \
|
||||||
|
return ret; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_LOAD_CONTROL_RPC_CALL(name, pcode, ...) \
|
||||||
|
CONCAT(OB_DEFINE_TABLE_LOAD_CONTROL_RPC_CALL_, ARGS_NUM(__VA_ARGS__))(name, pcode, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_LOAD_CONTROL_RPC(name, pcode, Processor, ...) \
|
||||||
|
OB_DEFINE_TABLE_LOAD_RPC(ObTableLoadControlRpc, pcode, Processor, ObDirectLoadControlRequest, \
|
||||||
|
ObDirectLoadControlResult, __VA_ARGS__) \
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC_CALL(name, pcode, __VA_ARGS__)
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableLoadControlRpcProxy(obrpc::ObSrvRpcProxy &rpc_proxy)
|
||||||
|
: rpc_proxy_(rpc_proxy),
|
||||||
|
allocator_("TLD_RpcProxy"),
|
||||||
|
timeout_(DEFAULT_TIMEOUT_US),
|
||||||
|
tenant_id_(MTL_ID())
|
||||||
|
{
|
||||||
|
allocator_.set_tenant_id(MTL_ID());
|
||||||
|
}
|
||||||
|
|
||||||
|
ObTableLoadControlRpcProxy &to(ObAddr addr)
|
||||||
|
{
|
||||||
|
addr_ = addr;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ObTableLoadControlRpcProxy &timeout(int64_t timeout)
|
||||||
|
{
|
||||||
|
timeout_ = timeout;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
ObTableLoadControlRpcProxy &by(uint64_t tenant_id)
|
||||||
|
{
|
||||||
|
tenant_id_ = tenant_id;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dispatch(const ObDirectLoadControlRequest &request, ObDirectLoadControlResult &result,
|
||||||
|
common::ObIAllocator &allocator);
|
||||||
|
|
||||||
|
// pre_begin
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(pre_begin, ObDirectLoadControlCommandType::PRE_BEGIN,
|
||||||
|
ObDirectLoadControlPreBeginExecutor,
|
||||||
|
ObDirectLoadControlPreBeginArg);
|
||||||
|
// confirm_begin
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(confirm_begin, ObDirectLoadControlCommandType::CONFIRM_BEGIN,
|
||||||
|
ObDirectLoadControlConfirmBeginExecutor,
|
||||||
|
ObDirectLoadControlConfirmBeginArg);
|
||||||
|
// pre_merge
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(pre_merge, ObDirectLoadControlCommandType::PRE_MERGE,
|
||||||
|
ObDirectLoadControlPreMergeExecutor,
|
||||||
|
ObDirectLoadControlPreMergeArg);
|
||||||
|
// start_merge
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(start_merge, ObDirectLoadControlCommandType::START_MERGE,
|
||||||
|
ObDirectLoadControlStartMergeExecutor,
|
||||||
|
ObDirectLoadControlStartMergeArg);
|
||||||
|
// commit
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(commit, ObDirectLoadControlCommandType::COMMIT,
|
||||||
|
ObDirectLoadControlCommitExecutor, ObDirectLoadControlCommitArg,
|
||||||
|
ObDirectLoadControlCommitRes);
|
||||||
|
// abort
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(abort, ObDirectLoadControlCommandType::ABORT,
|
||||||
|
ObDirectLoadControlAbortExecutor, ObDirectLoadControlAbortArg);
|
||||||
|
// get_status
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(get_status, ObDirectLoadControlCommandType::GET_STATUS,
|
||||||
|
ObDirectLoadControlGetStatusExecutor,
|
||||||
|
ObDirectLoadControlGetStatusArg,
|
||||||
|
ObDirectLoadControlGetStatusRes);
|
||||||
|
|
||||||
|
/// trans
|
||||||
|
// pre_start_trans
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(pre_start_trans, ObDirectLoadControlCommandType::PRE_START_TRANS,
|
||||||
|
ObDirectLoadControlPreStartTransExecutor,
|
||||||
|
ObDirectLoadControlPreStartTransArg);
|
||||||
|
// confirm_start_trans
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(confirm_start_trans,
|
||||||
|
ObDirectLoadControlCommandType::CONFIRM_START_TRANS,
|
||||||
|
ObDirectLoadControlConfirmStartTransExecutor,
|
||||||
|
ObDirectLoadControlConfirmStartTransArg);
|
||||||
|
// pre_finish_trans
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(pre_finish_trans,
|
||||||
|
ObDirectLoadControlCommandType::PRE_FINISH_TRANS,
|
||||||
|
ObDirectLoadControlPreFinishTransExecutor,
|
||||||
|
ObDirectLoadControlPreFinishTransArg);
|
||||||
|
// confirm_finish_trans
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(confirm_finish_trans,
|
||||||
|
ObDirectLoadControlCommandType::CONFIRM_FINISH_TRANS,
|
||||||
|
ObDirectLoadControlConfirmFinishTransExecutor,
|
||||||
|
ObDirectLoadControlConfirmFinishTransArg);
|
||||||
|
// abandon_trans
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(abandon_trans, ObDirectLoadControlCommandType::ABANDON_TRANS,
|
||||||
|
ObDirectLoadControlAbandonTransExecutor,
|
||||||
|
ObDirectLoadControlAbandonTransArg);
|
||||||
|
// get_trans_status
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(get_trans_status,
|
||||||
|
ObDirectLoadControlCommandType::GET_TRANS_STATUS,
|
||||||
|
ObDirectLoadControlGetTransStatusExecutor,
|
||||||
|
ObDirectLoadControlGetTransStatusArg,
|
||||||
|
ObDirectLoadControlGetTransStatusRes);
|
||||||
|
OB_DEFINE_TABLE_LOAD_CONTROL_RPC(insert_trans, ObDirectLoadControlCommandType::INSERT_TRANS,
|
||||||
|
ObDirectLoadControlInsertTransExecutor,
|
||||||
|
ObDirectLoadControlInsertTransArg);
|
||||||
|
|
||||||
|
private:
|
||||||
|
obrpc::ObSrvRpcProxy &rpc_proxy_;
|
||||||
|
ObArenaAllocator allocator_;
|
||||||
|
ObAddr addr_;
|
||||||
|
int64_t timeout_;
|
||||||
|
uint64_t tenant_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,233 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "ob_table_load_control_rpc_struct.h"
|
||||||
|
#include "observer/table_load/ob_table_load_utils.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
using namespace sql;
|
||||||
|
using namespace table;
|
||||||
|
|
||||||
|
OB_SERIALIZE_MEMBER(ObDirectLoadControlRequest,
|
||||||
|
command_type_,
|
||||||
|
arg_content_);
|
||||||
|
|
||||||
|
OB_SERIALIZE_MEMBER(ObDirectLoadControlResult,
|
||||||
|
command_type_,
|
||||||
|
res_content_);
|
||||||
|
|
||||||
|
// pre_begin
|
||||||
|
ObDirectLoadControlPreBeginArg::ObDirectLoadControlPreBeginArg()
|
||||||
|
: table_id_(common::OB_INVALID_ID),
|
||||||
|
column_count_(0),
|
||||||
|
dup_action_(ObLoadDupActionType::LOAD_INVALID_MODE),
|
||||||
|
px_mode_(false),
|
||||||
|
online_opt_stat_gather_(false),
|
||||||
|
dest_table_id_(common::OB_INVALID_ID),
|
||||||
|
task_id_(0),
|
||||||
|
schema_version_(0),
|
||||||
|
snapshot_version_(0),
|
||||||
|
data_version_(0),
|
||||||
|
session_info_(nullptr)
|
||||||
|
{
|
||||||
|
free_session_ctx_.sessid_ = ObSQLSessionInfo::INVALID_SESSID;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObDirectLoadControlPreBeginArg::~ObDirectLoadControlPreBeginArg()
|
||||||
|
{
|
||||||
|
if (nullptr != session_info_) {
|
||||||
|
if (free_session_ctx_.sessid_ != ObSQLSessionInfo::INVALID_SESSID) {
|
||||||
|
ObTableLoadUtils::free_session_info(session_info_, free_session_ctx_);
|
||||||
|
}
|
||||||
|
session_info_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OB_DEF_SERIALIZE_SIMPLE(ObDirectLoadControlPreBeginArg)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
LST_DO_CODE(OB_UNIS_ENCODE,
|
||||||
|
table_id_,
|
||||||
|
config_,
|
||||||
|
column_count_,
|
||||||
|
dup_action_,
|
||||||
|
px_mode_,
|
||||||
|
online_opt_stat_gather_,
|
||||||
|
dest_table_id_,
|
||||||
|
task_id_,
|
||||||
|
schema_version_,
|
||||||
|
snapshot_version_,
|
||||||
|
data_version_,
|
||||||
|
partition_id_array_,
|
||||||
|
target_partition_id_array_);
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (OB_ISNULL(session_info_)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("session info is null", KR(ret));
|
||||||
|
} else {
|
||||||
|
OB_UNIS_ENCODE(*session_info_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
OB_DEF_DESERIALIZE_SIMPLE(ObDirectLoadControlPreBeginArg)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
LST_DO_CODE(OB_UNIS_DECODE,
|
||||||
|
table_id_,
|
||||||
|
config_,
|
||||||
|
column_count_,
|
||||||
|
dup_action_,
|
||||||
|
px_mode_,
|
||||||
|
online_opt_stat_gather_,
|
||||||
|
dest_table_id_,
|
||||||
|
task_id_,
|
||||||
|
schema_version_,
|
||||||
|
snapshot_version_,
|
||||||
|
data_version_,
|
||||||
|
partition_id_array_,
|
||||||
|
target_partition_id_array_);
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (OB_FAIL(ObTableLoadUtils::create_session_info(session_info_, free_session_ctx_))) {
|
||||||
|
LOG_WARN("fail to init session info", KR(ret));
|
||||||
|
} else {
|
||||||
|
OB_UNIS_DECODE(*session_info_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
OB_DEF_SERIALIZE_SIZE_SIMPLE(ObDirectLoadControlPreBeginArg)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
int64_t len = 0;
|
||||||
|
LST_DO_CODE(OB_UNIS_ADD_LEN,
|
||||||
|
table_id_,
|
||||||
|
config_,
|
||||||
|
column_count_,
|
||||||
|
dup_action_,
|
||||||
|
px_mode_,
|
||||||
|
online_opt_stat_gather_,
|
||||||
|
dest_table_id_,
|
||||||
|
task_id_,
|
||||||
|
schema_version_,
|
||||||
|
snapshot_version_,
|
||||||
|
data_version_,
|
||||||
|
partition_id_array_,
|
||||||
|
target_partition_id_array_);
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (OB_ISNULL(session_info_)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("session info is null", KR(ret));
|
||||||
|
} else {
|
||||||
|
OB_UNIS_ADD_LEN(*session_info_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
// confirm_begin
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlConfirmBeginArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_);
|
||||||
|
|
||||||
|
// pre_merge
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlPreMergeArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
committed_trans_id_array_);
|
||||||
|
|
||||||
|
// start_merge
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlStartMergeArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_);
|
||||||
|
|
||||||
|
// commit
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlCommitArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_);
|
||||||
|
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlCommitRes,
|
||||||
|
result_info_,
|
||||||
|
sql_statistics_);
|
||||||
|
|
||||||
|
// abort
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlAbortArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_);
|
||||||
|
|
||||||
|
// get_status
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlGetStatusArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_);
|
||||||
|
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlGetStatusRes,
|
||||||
|
status_,
|
||||||
|
error_code_);
|
||||||
|
|
||||||
|
// pre_start_trans
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlPreStartTransArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
trans_id_);
|
||||||
|
|
||||||
|
// confirm_start_trans
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlConfirmStartTransArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
trans_id_);
|
||||||
|
|
||||||
|
// pre_finish_trans
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlPreFinishTransArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
trans_id_);
|
||||||
|
|
||||||
|
// confirm_finish_trans
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlConfirmFinishTransArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
trans_id_);
|
||||||
|
|
||||||
|
// abandon_trans
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlAbandonTransArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
trans_id_);
|
||||||
|
|
||||||
|
// get_trans_status
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlGetTransStatusArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
trans_id_);
|
||||||
|
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlGetTransStatusRes,
|
||||||
|
trans_status_,
|
||||||
|
error_code_);
|
||||||
|
|
||||||
|
// insert_trans
|
||||||
|
OB_SERIALIZE_MEMBER_SIMPLE(ObDirectLoadControlInsertTransArg,
|
||||||
|
table_id_,
|
||||||
|
task_id_,
|
||||||
|
trans_id_,
|
||||||
|
session_id_,
|
||||||
|
sequence_no_,
|
||||||
|
payload_);
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -0,0 +1,402 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "lib/container/ob_array_serialization.h"
|
||||||
|
#include "lib/utility/ob_print_utils.h"
|
||||||
|
#include "lib/utility/ob_unify_serialize.h"
|
||||||
|
#include "share/table/ob_table_load_array.h"
|
||||||
|
#include "share/table/ob_table_load_define.h"
|
||||||
|
#include "share/table/ob_table_load_sql_statistics.h"
|
||||||
|
#include "sql/session/ob_sql_session_mgr.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
enum class ObDirectLoadControlCommandType
|
||||||
|
{
|
||||||
|
PRE_BEGIN = 0,
|
||||||
|
CONFIRM_BEGIN = 1,
|
||||||
|
PRE_MERGE = 2,
|
||||||
|
START_MERGE = 3,
|
||||||
|
COMMIT = 4,
|
||||||
|
ABORT = 5,
|
||||||
|
GET_STATUS = 6,
|
||||||
|
|
||||||
|
// trans command
|
||||||
|
PRE_START_TRANS = 7,
|
||||||
|
CONFIRM_START_TRANS = 8,
|
||||||
|
PRE_FINISH_TRANS = 9,
|
||||||
|
CONFIRM_FINISH_TRANS = 10,
|
||||||
|
ABANDON_TRANS = 11,
|
||||||
|
GET_TRANS_STATUS = 12,
|
||||||
|
INSERT_TRANS = 13,
|
||||||
|
|
||||||
|
MAX_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObDirectLoadControlRequest
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlRequest() : command_type_(observer::ObDirectLoadControlCommandType::MAX_TYPE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
template <class Arg>
|
||||||
|
int set_arg(const Arg &arg, common::ObIAllocator &allocator)
|
||||||
|
{
|
||||||
|
int ret = common::OB_SUCCESS;
|
||||||
|
const int64_t size = arg.get_serialize_size();
|
||||||
|
char *buf = nullptr;
|
||||||
|
int64_t pos = 0;
|
||||||
|
if (OB_ISNULL(buf = static_cast<char *>(allocator.alloc(size)))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
SERVER_LOG(WARN, "fail to alloc memory", KR(ret), K(size));
|
||||||
|
} else if (OB_FAIL(arg.serialize(buf, size, pos))) {
|
||||||
|
SERVER_LOG(WARN, "fail to serialize arg", KR(ret), K(arg));
|
||||||
|
} else {
|
||||||
|
arg_content_.assign_ptr(buf, size);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template <class Arg>
|
||||||
|
int get_arg(Arg &arg) const
|
||||||
|
{
|
||||||
|
int ret = common::OB_SUCCESS;
|
||||||
|
int64_t pos = 0;
|
||||||
|
if (OB_UNLIKELY(arg_content_.empty())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
SERVER_LOG(WARN, "invalid args", KR(ret), KPC(this));
|
||||||
|
} else if (OB_FAIL(arg.deserialize(arg_content_.ptr(), arg_content_.length(), pos))) {
|
||||||
|
SERVER_LOG(WARN, "fail to deserialize arg content", KR(ret), KPC(this));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(command_type), "arg_content", common::ObHexStringWrap(arg_content_));
|
||||||
|
|
||||||
|
public:
|
||||||
|
observer::ObDirectLoadControlCommandType command_type_;
|
||||||
|
ObString arg_content_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlResult
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlResult() : command_type_(observer::ObDirectLoadControlCommandType::MAX_TYPE) {}
|
||||||
|
template <class Res>
|
||||||
|
int set_res(const Res &res, common::ObIAllocator &allocator)
|
||||||
|
{
|
||||||
|
int ret = common::OB_SUCCESS;
|
||||||
|
const int64_t size = res.get_serialize_size();
|
||||||
|
if (size > 0) {
|
||||||
|
char *buf = nullptr;
|
||||||
|
int64_t pos = 0;
|
||||||
|
if (OB_ISNULL(buf = static_cast<char *>(allocator.alloc(size)))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
SERVER_LOG(WARN, "fail to alloc memory", KR(ret), K(size));
|
||||||
|
} else if (OB_FAIL(res.serialize(buf, size, pos))) {
|
||||||
|
SERVER_LOG(WARN, "fail to serialize res", KR(ret), K(res));
|
||||||
|
} else {
|
||||||
|
res_content_.assign_ptr(buf, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template <class Res>
|
||||||
|
int get_res(Res &res) const
|
||||||
|
{
|
||||||
|
int ret = common::OB_SUCCESS;
|
||||||
|
int64_t pos = 0;
|
||||||
|
if (OB_UNLIKELY(res_content_.empty())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
SERVER_LOG(WARN, "invalid args", KR(ret), KPC(this));
|
||||||
|
} else if (OB_FAIL(res.deserialize(res_content_.ptr(), res_content_.length(), pos))) {
|
||||||
|
SERVER_LOG(WARN, "fail to deserialize res content", KR(ret), KPC(this));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(command_type), "res_content", common::ObHexStringWrap(res_content_));
|
||||||
|
|
||||||
|
public:
|
||||||
|
observer::ObDirectLoadControlCommandType command_type_;
|
||||||
|
ObString res_content_;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class ObDirectLoadControlPreBeginArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlPreBeginArg();
|
||||||
|
~ObDirectLoadControlPreBeginArg();
|
||||||
|
TO_STRING_KV(K_(table_id), K_(config), K_(column_count), K_(dup_action), K_(px_mode),
|
||||||
|
K_(online_opt_stat_gather), K_(dest_table_id), K_(task_id), K_(schema_version),
|
||||||
|
K_(snapshot_version), K_(data_version), K_(partition_id_array),
|
||||||
|
K_(target_partition_id_array));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
table::ObTableLoadConfig config_;
|
||||||
|
uint64_t column_count_;
|
||||||
|
sql::ObLoadDupActionType dup_action_;
|
||||||
|
bool px_mode_;
|
||||||
|
bool online_opt_stat_gather_;
|
||||||
|
// ddl param
|
||||||
|
uint64_t dest_table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
int64_t schema_version_;
|
||||||
|
int64_t snapshot_version_;
|
||||||
|
int64_t data_version_;
|
||||||
|
// partition info
|
||||||
|
table::ObTableLoadArray<table::ObTableLoadLSIdAndPartitionId> partition_id_array_; // origin table
|
||||||
|
table::ObTableLoadArray<table::ObTableLoadLSIdAndPartitionId> target_partition_id_array_; // target table
|
||||||
|
sql::ObSQLSessionInfo *session_info_;
|
||||||
|
sql::ObFreeSessionCtx free_session_ctx_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlConfirmBeginArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlConfirmBeginArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlPreMergeArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlPreMergeArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), K_(committed_trans_id_array));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
table::ObTableLoadArray<table::ObTableLoadTransId> committed_trans_id_array_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlStartMergeArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlStartMergeArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlCommitArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlCommitArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlCommitRes final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlCommitRes() {}
|
||||||
|
TO_STRING_KV(K_(result_info), K_(sql_statistics))
|
||||||
|
public:
|
||||||
|
table::ObTableLoadResultInfo result_info_;
|
||||||
|
table::ObTableLoadSqlStatistics sql_statistics_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlAbortArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlAbortArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlGetStatusArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlGetStatusArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlGetStatusRes final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlGetStatusRes()
|
||||||
|
: status_(table::ObTableLoadStatusType::NONE), error_code_(common::OB_SUCCESS)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(status), K_(error_code))
|
||||||
|
public:
|
||||||
|
table::ObTableLoadStatusType status_;
|
||||||
|
int32_t error_code_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlPreStartTransArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlPreStartTransArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
table::ObTableLoadTransId trans_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlConfirmStartTransArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlConfirmStartTransArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
table::ObTableLoadTransId trans_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlPreFinishTransArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlPreFinishTransArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
table::ObTableLoadTransId trans_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlConfirmFinishTransArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlConfirmFinishTransArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
table::ObTableLoadTransId trans_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlAbandonTransArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlAbandonTransArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
table::ObTableLoadTransId trans_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlGetTransStatusArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlGetTransStatusArg() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
table::ObTableLoadTransId trans_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlGetTransStatusRes final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlGetTransStatusRes()
|
||||||
|
: trans_status_(table::ObTableLoadTransStatusType::NONE), error_code_(common::OB_SUCCESS)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(trans_status), K_(error_code))
|
||||||
|
public:
|
||||||
|
table::ObTableLoadTransStatusType trans_status_;
|
||||||
|
int32_t error_code_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObDirectLoadControlInsertTransArg final
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlInsertTransArg()
|
||||||
|
: table_id_(common::OB_INVALID_ID),
|
||||||
|
task_id_(0),
|
||||||
|
session_id_(0),
|
||||||
|
sequence_no_(common::OB_INVALID_ID)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id), K_(session_id), K_(sequence_no));
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
table::ObTableLoadTransId trans_id_;
|
||||||
|
int32_t session_id_; // 从1开始
|
||||||
|
uint64_t sequence_no_; // 从1开始
|
||||||
|
ObString payload_; //里面包的是ObTableLoadObjArray
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -1,93 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#define USING_LOG_PREFIX SERVER
|
|
||||||
|
|
||||||
#include "observer/table_load/ob_table_load_abort_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_coordinator.h"
|
|
||||||
#include "observer/table_load/ob_table_load_service.h"
|
|
||||||
#include "observer/table_load/ob_table_load_store.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
using namespace table;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadAbortP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadAbortP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
if (OB_UNLIKELY(OB_ENTRY_NOT_EXIST == ret)) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ret = OB_SUCCESS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (OB_FAIL(ObTableLoadService::remove_ctx(table_ctx))) {
|
|
||||||
LOG_WARN("fail to remove table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadCoordinator::abort_ctx(table_ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadAbortP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadAbortPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadAbortPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
if (OB_UNLIKELY(OB_ENTRY_NOT_EXIST == ret)) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (OB_FAIL(ObTableLoadService::remove_ctx(table_ctx))) {
|
|
||||||
LOG_WARN("fail to remove table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore::abort_ctx(table_ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadAbortPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "observer/table/ob_table_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_proxy.h"
|
|
||||||
#include "share/table/ob_table_rpc_proxy.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
|
|
||||||
class ObTableLoadAbortP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_ABORT> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadAbortP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadAbortP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadAbortP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadAbortPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_ABORT_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadAbortPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadAbortPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadAbortPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,404 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#define USING_LOG_PREFIX SERVER
|
|
||||||
|
|
||||||
#include "observer/table_load/ob_table_load_begin_processor.h"
|
|
||||||
#include "observer/omt/ob_multi_tenant.h"
|
|
||||||
#include "observer/omt/ob_tenant.h"
|
|
||||||
#include "observer/table_load/ob_table_load_coordinator.h"
|
|
||||||
#include "observer/table_load/ob_table_load_redef_table.h"
|
|
||||||
#include "observer/table_load/ob_table_load_schema.h"
|
|
||||||
#include "observer/table_load/ob_table_load_service.h"
|
|
||||||
#include "observer/table_load/ob_table_load_store.h"
|
|
||||||
#include "observer/table_load/ob_table_load_table_ctx.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
using namespace table;
|
|
||||||
using namespace sql;
|
|
||||||
using namespace omt;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadBeginP
|
|
||||||
*/
|
|
||||||
|
|
||||||
ObTableLoadBeginP::ObTableLoadBeginP(const ObGlobalContext &gctx) : gctx_(gctx), table_ctx_(nullptr)
|
|
||||||
{
|
|
||||||
allocator_.set_tenant_id(MTL_ID());
|
|
||||||
}
|
|
||||||
|
|
||||||
ObTableLoadBeginP::~ObTableLoadBeginP()
|
|
||||||
{
|
|
||||||
if (OB_NOT_NULL(table_ctx_)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx_);
|
|
||||||
table_ctx_ = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadBeginP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
uint64_t table_id = OB_INVALID_ID;
|
|
||||||
ObTableLoadArray<ObString> column_names;
|
|
||||||
bool is_new = false;
|
|
||||||
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret), K_(arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
ObSchemaGetterGuard schema_guard;
|
|
||||||
const ObTableSchema *table_schema = nullptr;
|
|
||||||
if (OB_FAIL(ObTableLoadSchema::get_table_schema(credential_.tenant_id_,
|
|
||||||
credential_.database_id_, arg_.table_name_,
|
|
||||||
schema_guard, table_schema))) {
|
|
||||||
LOG_WARN("fail to get table schema", KR(ret), K_(arg));
|
|
||||||
} else {
|
|
||||||
table_id = table_schema->get_table_id();
|
|
||||||
if (OB_FAIL(ObTableLoadSchema::get_column_names(table_schema, allocator_, column_names))) {
|
|
||||||
LOG_WARN("fail to get column name", KR(ret), K_(arg));
|
|
||||||
} else if (OB_UNLIKELY(column_names.empty())) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("unexpected empty column names", KR(ret), K_(arg));
|
|
||||||
} else if (OB_FAIL(init_idx_array(table_schema))) {
|
|
||||||
LOG_WARN("failed to init idx array", K(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the existing table ctx if it exists
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
ObTableLoadKey key(credential_.tenant_id_, table_id);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx_))) {
|
|
||||||
if (OB_UNLIKELY(OB_ENTRY_NOT_EXIST != ret)) {
|
|
||||||
LOG_WARN("fail to get ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ret = OB_SUCCESS;
|
|
||||||
table_ctx_ = nullptr;
|
|
||||||
}
|
|
||||||
} else if (OB_UNLIKELY(!ObTableLoadCoordinator::is_ctx_inited(table_ctx_))) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("unexpected uninited coordinator ctx", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create new table ctx if it does not exist
|
|
||||||
if (OB_SUCC(ret) && nullptr == table_ctx_) {
|
|
||||||
ObTenant *tenant = nullptr;
|
|
||||||
sql::ObSQLSessionInfo *session_info = nullptr;
|
|
||||||
sql::ObFreeSessionCtx free_session_ctx;
|
|
||||||
free_session_ctx.sessid_ = ObSQLSessionInfo::INVALID_SESSID;
|
|
||||||
if (arg_.config_.flag_.data_type_ >=
|
|
||||||
static_cast<uint64_t>(ObTableLoadDataType::MAX_DATA_TYPE)) {
|
|
||||||
ret = OB_INVALID_ARGUMENT;
|
|
||||||
LOG_WARN("data type is error", KR(ret), K(arg_.config_.flag_.data_type_));
|
|
||||||
} else if (OB_FAIL(GCTX.omt_->get_tenant(credential_.tenant_id_, tenant))) {
|
|
||||||
LOG_WARN("fail to get tenant handle", KR(ret), K(credential_.tenant_id_));
|
|
||||||
} else if (OB_FAIL(ObTableLoadUtils::create_session_info(credential_.user_id_, session_info, free_session_ctx))) {
|
|
||||||
LOG_WARN("fail to init session info", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadParam param;
|
|
||||||
param.tenant_id_ = credential_.tenant_id_;
|
|
||||||
param.table_id_ = table_id;
|
|
||||||
param.batch_size_ = arg_.config_.batch_size_;
|
|
||||||
param.parallel_ = arg_.config_.session_count_;
|
|
||||||
param.session_count_ = MIN(arg_.config_.session_count_, (int32_t)tenant->unit_max_cpu() * 2);
|
|
||||||
param.max_error_row_count_ = arg_.config_.max_error_row_count_;
|
|
||||||
param.column_count_ = column_names.count();
|
|
||||||
param.need_sort_ = arg_.config_.flag_.is_need_sort_;
|
|
||||||
param.px_mode_ = false;
|
|
||||||
param.online_opt_stat_gather_ = false;
|
|
||||||
param.data_type_ = static_cast<ObTableLoadDataType>(arg_.config_.flag_.data_type_);
|
|
||||||
param.dup_action_ = static_cast<ObLoadDupActionType>(arg_.config_.flag_.dup_action_);
|
|
||||||
if (OB_FAIL(param.normalize())) {
|
|
||||||
LOG_WARN("fail to normalize param", KR(ret));
|
|
||||||
}
|
|
||||||
// check support
|
|
||||||
else if (OB_FAIL(ObTableLoadService::check_support_direct_load(table_id))) {
|
|
||||||
LOG_WARN("fail to check support direct load", KR(ret), K(table_id));
|
|
||||||
}
|
|
||||||
// create table ctx
|
|
||||||
else if (OB_FAIL(create_table_ctx(param, idx_array_, *session_info, table_ctx_))) {
|
|
||||||
LOG_WARN("fail to create table ctx", KR(ret));
|
|
||||||
} else {
|
|
||||||
is_new = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (session_info != nullptr) {
|
|
||||||
ObTableLoadUtils::free_session_info(session_info, free_session_ctx);
|
|
||||||
session_info = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
ObTableLoadCoordinator coordinator(table_ctx_);
|
|
||||||
if (OB_FAIL(coordinator.init())) {
|
|
||||||
LOG_WARN("fail to init coordinator", KR(ret));
|
|
||||||
} else if (is_new && OB_FAIL(coordinator.begin())) { // 新建的ctx需要begin
|
|
||||||
LOG_WARN("fail to coordinator begin", KR(ret));
|
|
||||||
} else if (OB_FAIL(coordinator.get_status(result_.status_, result_.error_code_))) {
|
|
||||||
LOG_WARN("fail to coordinator get status", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
result_.table_id_ = table_id;
|
|
||||||
result_.task_id_ = table_ctx_->ddl_param_.task_id_;
|
|
||||||
result_.column_names_ = column_names;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_FAIL(ret)) {
|
|
||||||
if (nullptr != table_ctx_) {
|
|
||||||
ObTableLoadService::remove_ctx(table_ctx_);
|
|
||||||
ObTableLoadCoordinator::abort_ctx(table_ctx_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadBeginP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadBeginP::init_idx_array(const ObTableSchema *table_schema)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
ObSEArray<ObColDesc, 64> column_descs;
|
|
||||||
if (OB_FAIL(table_schema->get_column_ids(column_descs, false))) {
|
|
||||||
LOG_WARN("fail to get column ids", KR(ret));
|
|
||||||
} else {
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && (i < column_descs.count()); ++i) {
|
|
||||||
ObColDesc &col_desc = column_descs.at(i);
|
|
||||||
const ObColumnSchemaV2 *column_schema = table_schema->get_column_schema(col_desc.col_id_);
|
|
||||||
if (!column_schema->is_hidden()) {
|
|
||||||
int64_t idx = col_desc.col_id_ - OB_APP_MIN_COLUMN_ID;
|
|
||||||
if (OB_FAIL(idx_array_.push_back(idx))) {
|
|
||||||
LOG_WARN("failed to push back idx to array", K(ret), K(idx));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadBeginP::create_table_ctx(const ObTableLoadParam ¶m,
|
|
||||||
const ObIArray<int64_t> &idx_array,
|
|
||||||
ObSQLSessionInfo &session_info,
|
|
||||||
ObTableLoadTableCtx *&table_ctx)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
table_ctx = nullptr;
|
|
||||||
ObTableLoadDDLParam ddl_param;
|
|
||||||
// start redef table
|
|
||||||
ObTableLoadRedefTableStartArg start_arg;
|
|
||||||
ObTableLoadRedefTableStartRes start_res;
|
|
||||||
uint64_t data_version = 0;
|
|
||||||
start_arg.tenant_id_ = param.tenant_id_;
|
|
||||||
start_arg.table_id_ = param.table_id_;
|
|
||||||
start_arg.parallelism_ = param.parallel_;
|
|
||||||
if (OB_FAIL(GET_MIN_DATA_VERSION(param.tenant_id_, data_version))) {
|
|
||||||
LOG_WARN("fail to get tenant data version", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadRedefTable::start(start_arg, start_res, session_info))) {
|
|
||||||
LOG_WARN("fail to start redef table", KR(ret), K(start_arg));
|
|
||||||
} else {
|
|
||||||
ddl_param.dest_table_id_ = start_res.dest_table_id_;
|
|
||||||
ddl_param.task_id_ = start_res.task_id_;
|
|
||||||
ddl_param.schema_version_ = start_res.schema_version_;
|
|
||||||
ddl_param.snapshot_version_ = start_res.snapshot_version_;
|
|
||||||
ddl_param.data_version_ = data_version;
|
|
||||||
}
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
const int64_t origin_timeout_ts = THIS_WORKER.get_timeout_ts();
|
|
||||||
THIS_WORKER.set_timeout_ts(ObTimeUtil::current_time() + arg_.timeout_);
|
|
||||||
if (OB_ISNULL(table_ctx = ObTableLoadService::alloc_ctx())) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
LOG_WARN("fail to alloc table ctx", KR(ret), K(param));
|
|
||||||
} else if (OB_FAIL(table_ctx->init(param, ddl_param, &session_info))) {
|
|
||||||
LOG_WARN("fail to init table ctx", KR(ret));
|
|
||||||
} else if (OB_FAIL(table_ctx->init_client_exec_ctx())) {
|
|
||||||
LOG_WARN("fail to init client exec ctx", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadCoordinator::init_ctx(table_ctx, idx_array_,
|
|
||||||
session_info.get_priv_user_id(),
|
|
||||||
table_ctx->client_exec_ctx_))) {
|
|
||||||
LOG_WARN("fail to coordinator init ctx", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::add_ctx(table_ctx))) {
|
|
||||||
LOG_WARN("fail to add ctx", KR(ret));
|
|
||||||
}
|
|
||||||
THIS_WORKER.set_timeout_ts(origin_timeout_ts);
|
|
||||||
}
|
|
||||||
if (OB_FAIL(ret)) {
|
|
||||||
int tmp_ret = OB_SUCCESS;
|
|
||||||
if (ddl_param.is_valid()) {
|
|
||||||
ObTableLoadRedefTableAbortArg abort_arg;
|
|
||||||
abort_arg.tenant_id_ = param.tenant_id_;
|
|
||||||
abort_arg.task_id_ = ddl_param.task_id_;
|
|
||||||
if (OB_TMP_FAIL(ObTableLoadRedefTable::abort(abort_arg, session_info))) {
|
|
||||||
LOG_WARN("fail to abort redef table", KR(tmp_ret), K(abort_arg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nullptr != table_ctx) {
|
|
||||||
ObTableLoadService::free_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadPreBeginPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadPreBeginPeerP::deserialize()
|
|
||||||
{
|
|
||||||
arg_.partition_id_array_.set_allocator(allocator_);
|
|
||||||
arg_.target_partition_id_array_.set_allocator(allocator_);
|
|
||||||
return ParentType::deserialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadPreBeginPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret), K_(arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadParam param;
|
|
||||||
param.tenant_id_ = credential_.tenant_id_;
|
|
||||||
param.table_id_ = arg_.table_id_;
|
|
||||||
param.batch_size_ = arg_.config_.batch_size_;
|
|
||||||
param.parallel_ = arg_.config_.session_count_;
|
|
||||||
param.session_count_ = arg_.config_.session_count_;
|
|
||||||
param.max_error_row_count_ = arg_.config_.max_error_row_count_;
|
|
||||||
param.column_count_ = arg_.column_count_;
|
|
||||||
param.need_sort_ = arg_.config_.flag_.is_need_sort_;
|
|
||||||
param.px_mode_ = arg_.px_mode_;
|
|
||||||
param.online_opt_stat_gather_ = arg_.online_opt_stat_gather_;
|
|
||||||
param.dup_action_ = arg_.dup_action_;
|
|
||||||
ObTableLoadDDLParam ddl_param;
|
|
||||||
uint64_t data_version = 0;
|
|
||||||
ddl_param.dest_table_id_ = arg_.dest_table_id_;
|
|
||||||
ddl_param.task_id_ = arg_.task_id_;
|
|
||||||
ddl_param.schema_version_ = arg_.schema_version_;
|
|
||||||
ddl_param.snapshot_version_ = arg_.snapshot_version_;
|
|
||||||
ddl_param.data_version_ = arg_.data_version_;
|
|
||||||
if (OB_FAIL(create_table_ctx(param, ddl_param, table_ctx))) {
|
|
||||||
LOG_WARN("fail to create table ctx", KR(ret));
|
|
||||||
}
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.pre_begin())) {
|
|
||||||
LOG_WARN("fail to store pre begin", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadPreBeginPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadPreBeginPeerP::create_table_ctx(const ObTableLoadParam ¶m,
|
|
||||||
const ObTableLoadDDLParam &ddl_param,
|
|
||||||
ObTableLoadTableCtx *&table_ctx)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
table_ctx = nullptr;
|
|
||||||
if (OB_ISNULL(table_ctx = ObTableLoadService::alloc_ctx())) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
LOG_WARN("fail to alloc table ctx", KR(ret), K(param));
|
|
||||||
} else if (OB_FAIL(table_ctx->init(param, ddl_param, arg_.session_info_))) {
|
|
||||||
LOG_WARN("fail to init table ctx", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadStore::init_ctx(table_ctx,
|
|
||||||
arg_.partition_id_array_,
|
|
||||||
arg_.target_partition_id_array_))) {
|
|
||||||
LOG_WARN("fail to store init ctx", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::add_ctx(table_ctx))) {
|
|
||||||
LOG_WARN("fail to add ctx", KR(ret));
|
|
||||||
}
|
|
||||||
if (OB_FAIL(ret)) {
|
|
||||||
if (nullptr != table_ctx) {
|
|
||||||
ObTableLoadService::free_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadConfirmBeginPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadConfirmBeginPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret), K_(arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.confirm_begin())) {
|
|
||||||
LOG_WARN("fail to store confirm begin", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadConfirmBeginPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,89 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "observer/table/ob_table_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_proxy.h"
|
|
||||||
#include "share/table/ob_table_rpc_proxy.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
class ObTableLoadParam;
|
|
||||||
class ObTableLoadDDLParam;
|
|
||||||
class ObTableLoadTableCtx;
|
|
||||||
|
|
||||||
class ObTableLoadBeginP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_BEGIN> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadBeginP(const ObGlobalContext &gctx);
|
|
||||||
virtual ~ObTableLoadBeginP();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
int init_idx_array(const ObTableSchema *table_schema);
|
|
||||||
int create_table_ctx(const ObTableLoadParam ¶m, const common::ObIArray<int64_t> &idx_array,
|
|
||||||
sql::ObSQLSessionInfo &session_info, ObTableLoadTableCtx *&table_ctx);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadBeginP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
common::ObArenaAllocator allocator_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
common::ObArray<int64_t> idx_array_;
|
|
||||||
ObTableLoadTableCtx *table_ctx_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreBeginPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_PRE_BEGIN_PEER> >
|
|
||||||
{
|
|
||||||
typedef obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_PRE_BEGIN_PEER> > ParentType;
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadPreBeginPeerP(const ObGlobalContext &gctx) : gctx_(gctx)
|
|
||||||
{
|
|
||||||
allocator_.set_tenant_id(MTL_ID());
|
|
||||||
}
|
|
||||||
virtual ~ObTableLoadPreBeginPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int deserialize() override;
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
int create_table_ctx(const ObTableLoadParam ¶m, const ObTableLoadDDLParam &ddl_param,
|
|
||||||
ObTableLoadTableCtx *&table_ctx);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadPreBeginPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
common::ObArenaAllocator allocator_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadConfirmBeginPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_CONFIRM_BEGIN_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadConfirmBeginPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadConfirmBeginPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadConfirmBeginPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
862
src/observer/table_load/ob_table_load_client_service.cpp
Normal file
862
src/observer/table_load/ob_table_load_client_service.cpp
Normal file
@ -0,0 +1,862 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "observer/table_load/ob_table_load_client_service.h"
|
||||||
|
#include "observer/table_load/ob_table_load_client_task.h"
|
||||||
|
#include "observer/table_load/ob_table_load_coordinator.h"
|
||||||
|
#include "observer/table_load/ob_table_load_service.h"
|
||||||
|
#include "observer/table_load/ob_table_load_table_ctx.h"
|
||||||
|
#include "observer/table_load/ob_table_load_task.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
using namespace common;
|
||||||
|
using namespace table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CommitTaskProcessor
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ObTableLoadClientService::CommitTaskProcessor : public ObITableLoadTaskProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CommitTaskProcessor(ObTableLoadTask &task, ObTableLoadClientTask *client_task)
|
||||||
|
: ObITableLoadTaskProcessor(task), client_task_(client_task), table_ctx_(nullptr)
|
||||||
|
{
|
||||||
|
client_task_->inc_ref_count();
|
||||||
|
}
|
||||||
|
virtual ~CommitTaskProcessor()
|
||||||
|
{
|
||||||
|
ObTableLoadClientService::revert_task(client_task_);
|
||||||
|
if (nullptr != table_ctx_) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int process() override
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(init())) {
|
||||||
|
LOG_WARN("fail to init", KR(ret));
|
||||||
|
}
|
||||||
|
// 1. finish all trans
|
||||||
|
else if (OB_FAIL(finish_all_trans())) {
|
||||||
|
LOG_WARN("fail to finish all trans", KR(ret));
|
||||||
|
}
|
||||||
|
// 2. check all trans commit
|
||||||
|
else if (OB_FAIL(check_all_trans_commit())) {
|
||||||
|
LOG_WARN("fail to check all trans commit", KR(ret));
|
||||||
|
}
|
||||||
|
// 3. finish
|
||||||
|
else if (OB_FAIL(finish())) {
|
||||||
|
LOG_WARN("fail to finish table load", KR(ret));
|
||||||
|
}
|
||||||
|
// 4. check merged
|
||||||
|
else if (OB_FAIL(check_merged())) {
|
||||||
|
LOG_WARN("fail to check merged", KR(ret));
|
||||||
|
}
|
||||||
|
// 5. commit
|
||||||
|
else if (OB_FAIL(commit())) {
|
||||||
|
LOG_WARN("fail to commit table load", KR(ret));
|
||||||
|
}
|
||||||
|
// end
|
||||||
|
else if (OB_FAIL(client_task_->set_status_commit())) {
|
||||||
|
LOG_WARN("fail to set status commit", KR(ret));
|
||||||
|
}
|
||||||
|
// auto abort
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
int tmp_ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(OB_TMP_FAIL(ObTableLoadClientService::abort_task(client_task_)))) {
|
||||||
|
LOG_WARN("fail to abort client task", KR(tmp_ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
int init()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(client_task_->check_status(ObTableLoadClientStatus::COMMITTING))) {
|
||||||
|
LOG_WARN("fail to check status", KR(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(client_task_->get_table_ctx(table_ctx_))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
client_task_->set_status_error(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int finish_all_trans()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(client_task_->check_status(ObTableLoadClientStatus::COMMITTING))) {
|
||||||
|
LOG_WARN("fail to check status", KR(ret));
|
||||||
|
} else {
|
||||||
|
const ObIArray<ObTableLoadTransId> &trans_ids = client_task_->get_trans_ids();
|
||||||
|
ObTableLoadCoordinator coordinator(table_ctx_);
|
||||||
|
if (OB_FAIL(coordinator.init())) {
|
||||||
|
LOG_WARN("fail to init coordinator", KR(ret));
|
||||||
|
}
|
||||||
|
for (int64_t i = 0; OB_SUCC(ret) && i < trans_ids.count(); ++i) {
|
||||||
|
const ObTableLoadTransId &trans_id = trans_ids.at(i);
|
||||||
|
if (OB_FAIL(coordinator.finish_trans(trans_id))) {
|
||||||
|
LOG_WARN("fail to coordinator finish trans", KR(ret), K(i), K(trans_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
client_task_->set_status_error(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int check_all_trans_commit()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
const ObIArray<ObTableLoadTransId> &trans_ids = client_task_->get_trans_ids();
|
||||||
|
while (OB_SUCC(ret)) {
|
||||||
|
if (OB_FAIL(client_task_->check_status(ObTableLoadClientStatus::COMMITTING))) {
|
||||||
|
LOG_WARN("fail to check status", KR(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(client_task_->get_exec_ctx()->check_status())) {
|
||||||
|
LOG_WARN("fail to check exec status", KR(ret));
|
||||||
|
} else {
|
||||||
|
bool all_commit = true;
|
||||||
|
ObTableLoadCoordinator coordinator(table_ctx_);
|
||||||
|
if (OB_FAIL(coordinator.init())) {
|
||||||
|
LOG_WARN("fail to init coordinator", KR(ret));
|
||||||
|
}
|
||||||
|
for (int64_t i = 0; OB_SUCC(ret) && i < trans_ids.count(); ++i) {
|
||||||
|
const ObTableLoadTransId &trans_id = trans_ids.at(i);
|
||||||
|
ObTableLoadTransStatusType trans_status = ObTableLoadTransStatusType::NONE;
|
||||||
|
int error_code = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(coordinator.get_trans_status(trans_id, trans_status, error_code))) {
|
||||||
|
LOG_WARN("fail to coordinator get status", KR(ret), K(i), K(trans_id));
|
||||||
|
} else {
|
||||||
|
switch (trans_status) {
|
||||||
|
case ObTableLoadTransStatusType::FROZEN:
|
||||||
|
all_commit = false;
|
||||||
|
break;
|
||||||
|
case ObTableLoadTransStatusType::COMMIT:
|
||||||
|
break;
|
||||||
|
case ObTableLoadTransStatusType::ERROR:
|
||||||
|
ret = error_code;
|
||||||
|
LOG_WARN("trans has error", KR(ret));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected trans status", KR(ret), K(trans_status));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (all_commit) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
ob_usleep(1000 * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
client_task_->set_status_error(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int finish()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(client_task_->check_status(ObTableLoadClientStatus::COMMITTING))) {
|
||||||
|
LOG_WARN("fail to check status", KR(ret));
|
||||||
|
} else {
|
||||||
|
ObTableLoadCoordinator coordinator(table_ctx_);
|
||||||
|
if (OB_FAIL(coordinator.init())) {
|
||||||
|
LOG_WARN("fail to init coordinator", KR(ret));
|
||||||
|
} else if (OB_FAIL(coordinator.finish())) {
|
||||||
|
LOG_WARN("fail to coordinator finish", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
client_task_->set_status_error(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int check_merged()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
while (OB_SUCC(ret)) {
|
||||||
|
if (OB_FAIL(client_task_->check_status(ObTableLoadClientStatus::COMMITTING))) {
|
||||||
|
LOG_WARN("fail to check status", KR(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(client_task_->get_exec_ctx()->check_status())) {
|
||||||
|
LOG_WARN("fail to check exec status", KR(ret));
|
||||||
|
} else {
|
||||||
|
bool is_merged = false;
|
||||||
|
ObTableLoadStatusType status = ObTableLoadStatusType::NONE;
|
||||||
|
int error_code = OB_SUCCESS;
|
||||||
|
ObTableLoadCoordinator coordinator(table_ctx_);
|
||||||
|
if (OB_FAIL(coordinator.init())) {
|
||||||
|
LOG_WARN("fail to init coordinator", KR(ret));
|
||||||
|
} else if (OB_FAIL(coordinator.get_status(status, error_code))) {
|
||||||
|
LOG_WARN("fail to coordinator get status", KR(ret));
|
||||||
|
} else {
|
||||||
|
switch (status) {
|
||||||
|
case ObTableLoadStatusType::FROZEN:
|
||||||
|
case ObTableLoadStatusType::MERGING:
|
||||||
|
is_merged = false;
|
||||||
|
break;
|
||||||
|
case ObTableLoadStatusType::MERGED:
|
||||||
|
is_merged = true;
|
||||||
|
break;
|
||||||
|
case ObTableLoadStatusType::ERROR:
|
||||||
|
ret = error_code;
|
||||||
|
LOG_WARN("table load has error", KR(ret));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected status", KR(ret), K(status));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
if (is_merged) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
ob_usleep(1000 * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
client_task_->set_status_error(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int commit()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(client_task_->check_status(ObTableLoadClientStatus::COMMITTING))) {
|
||||||
|
LOG_WARN("fail to check status", KR(ret));
|
||||||
|
} else {
|
||||||
|
ObTableLoadCoordinator coordinator(table_ctx_);
|
||||||
|
if (OB_FAIL(coordinator.init())) {
|
||||||
|
LOG_WARN("fail to init coordinator", KR(ret));
|
||||||
|
} else if (OB_FAIL(coordinator.commit(client_task_->result_info_))) {
|
||||||
|
LOG_WARN("fail to coordinator commit", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
client_task_->set_status_error(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
ObTableLoadClientTask *client_task_;
|
||||||
|
ObTableLoadTableCtx *table_ctx_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbortTaskProcessor
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ObTableLoadClientService::AbortTaskProcessor : public ObITableLoadTaskProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AbortTaskProcessor(ObTableLoadTask &task, ObTableLoadClientTask *client_task)
|
||||||
|
: ObITableLoadTaskProcessor(task), client_task_(client_task)
|
||||||
|
{
|
||||||
|
client_task_->inc_ref_count();
|
||||||
|
}
|
||||||
|
virtual ~AbortTaskProcessor()
|
||||||
|
{
|
||||||
|
ObTableLoadClientService::revert_task(client_task_);
|
||||||
|
}
|
||||||
|
int process() override
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(client_task_->check_status(ObTableLoadClientStatus::ABORT))) {
|
||||||
|
LOG_WARN("fail to check status", KR(ret));
|
||||||
|
} else {
|
||||||
|
ObTableLoadTableCtx *table_ctx = nullptr;
|
||||||
|
if (OB_FAIL(client_task_->get_table_ctx(table_ctx))) {
|
||||||
|
LOG_WARN("fail to get table ctx", KR(ret));
|
||||||
|
} else {
|
||||||
|
ObTableLoadCoordinator::abort_ctx(table_ctx);
|
||||||
|
}
|
||||||
|
if (nullptr != table_ctx) {
|
||||||
|
ObTableLoadService::put_ctx(table_ctx);
|
||||||
|
table_ctx = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
ObTableLoadClientTask *client_task_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CommonTaskCallback
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ObTableLoadClientService::CommonTaskCallback : public ObITableLoadTaskCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CommonTaskCallback(ObTableLoadClientTask *client_task) : client_task_(client_task)
|
||||||
|
{
|
||||||
|
client_task_->inc_ref_count();
|
||||||
|
}
|
||||||
|
virtual ~CommonTaskCallback()
|
||||||
|
{
|
||||||
|
ObTableLoadClientService::revert_task(client_task_);
|
||||||
|
}
|
||||||
|
void callback(int ret_code, ObTableLoadTask *task) override
|
||||||
|
{
|
||||||
|
client_task_->free_task(task);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
ObTableLoadClientTask *client_task_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClientTaskBriefEraseIfExpired
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool ObTableLoadClientService::ClientTaskBriefEraseIfExpired::operator()(
|
||||||
|
const ObTableLoadUniqueKey &key, ObTableLoadClientTaskBrief *client_task_brief) const
|
||||||
|
{
|
||||||
|
return client_task_brief->active_time_ < expired_ts_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ObTableLoadClientService
|
||||||
|
*/
|
||||||
|
|
||||||
|
ObTableLoadClientService::ObTableLoadClientService() : is_inited_(false) {}
|
||||||
|
|
||||||
|
ObTableLoadClientService::~ObTableLoadClientService() {}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::init()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
const int64_t bucket_num = 1024;
|
||||||
|
if (IS_INIT) {
|
||||||
|
ret = OB_INIT_TWICE;
|
||||||
|
LOG_WARN("ObTableLoadClientService init twice", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(
|
||||||
|
client_task_map_.create(bucket_num, "TLD_ClientTask", "TLD_ClientTask", MTL_ID()))) {
|
||||||
|
LOG_WARN("fail to create hashmap", KR(ret), K(bucket_num));
|
||||||
|
} else if (OB_FAIL(client_task_index_map_.create(bucket_num, "TLD_ClientTask", "TLD_ClientTask",
|
||||||
|
MTL_ID()))) {
|
||||||
|
LOG_WARN("fail to create hashmap", KR(ret), K(bucket_num));
|
||||||
|
} else if (OB_FAIL(client_task_brief_map_.init("TLD_ClientBrief", MTL_ID()))) {
|
||||||
|
LOG_WARN("fail to init link hashmap", KR(ret));
|
||||||
|
} else {
|
||||||
|
is_inited_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObTableLoadClientService *ObTableLoadClientService::get_client_service()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadService *service = nullptr;
|
||||||
|
ObTableLoadClientService *client_service = nullptr;
|
||||||
|
if (OB_ISNULL(service = MTL(ObTableLoadService *))) {
|
||||||
|
ret = OB_ERR_SYS;
|
||||||
|
LOG_WARN("null table load service", KR(ret));
|
||||||
|
} else {
|
||||||
|
client_service = &service->get_client_service();
|
||||||
|
}
|
||||||
|
return client_service;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObTableLoadClientTask *ObTableLoadClientService::alloc_task()
|
||||||
|
{
|
||||||
|
ObTableLoadClientTask *client_task =
|
||||||
|
OB_NEW(ObTableLoadClientTask, ObMemAttr(MTL_ID(), "TLD_ClientTask"));
|
||||||
|
if (nullptr != client_task) {
|
||||||
|
client_task->inc_ref_count();
|
||||||
|
}
|
||||||
|
return client_task;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableLoadClientService::free_task(ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
if (OB_NOT_NULL(client_task)) {
|
||||||
|
OB_ASSERT(0 == client_task->get_ref_count());
|
||||||
|
OB_DELETE(ObTableLoadClientTask, "TLD_ClientTask", client_task);
|
||||||
|
client_task = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableLoadClientService::revert_task(ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_ISNULL(client_task)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), KP(client_task));
|
||||||
|
} else {
|
||||||
|
const int64_t ref_count = client_task->dec_ref_count();
|
||||||
|
OB_ASSERT(ref_count >= 0);
|
||||||
|
if (0 == ref_count) {
|
||||||
|
const uint64_t tenant_id = client_task->tenant_id_;
|
||||||
|
const uint64_t table_id = client_task->table_id_;
|
||||||
|
const uint64_t hidden_table_id = client_task->ddl_param_.dest_table_id_;
|
||||||
|
const int64_t task_id = client_task->ddl_param_.task_id_;
|
||||||
|
LOG_INFO("free client task", K(tenant_id), K(table_id), K(hidden_table_id), K(task_id),
|
||||||
|
KP(client_task));
|
||||||
|
free_task(client_task);
|
||||||
|
client_task = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::add_task(ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadService *service = nullptr;
|
||||||
|
if (OB_ISNULL(service = MTL(ObTableLoadService *))) {
|
||||||
|
ret = OB_ERR_SYS;
|
||||||
|
LOG_WARN("null table load service", KR(ret));
|
||||||
|
} else {
|
||||||
|
ObTableLoadUniqueKey key(client_task->table_id_, client_task->ddl_param_.task_id_);
|
||||||
|
ret = service->get_client_service().add_client_task(key, client_task);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::remove_task(ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadService *service = nullptr;
|
||||||
|
if (OB_ISNULL(service = MTL(ObTableLoadService *))) {
|
||||||
|
ret = OB_ERR_SYS;
|
||||||
|
LOG_WARN("null table load service", KR(ret));
|
||||||
|
} else {
|
||||||
|
ObTableLoadUniqueKey key(client_task->table_id_, client_task->ddl_param_.task_id_);
|
||||||
|
ret = service->get_client_service().remove_client_task(key, client_task);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::get_task(const ObTableLoadUniqueKey &key,
|
||||||
|
ObTableLoadClientTask *&client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadService *service = nullptr;
|
||||||
|
if (OB_ISNULL(service = MTL(ObTableLoadService *))) {
|
||||||
|
ret = OB_ERR_SYS;
|
||||||
|
LOG_WARN("null table load service", KR(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(service->get_client_service().get_client_task(key, client_task))) {
|
||||||
|
LOG_WARN("fail to get client task", KR(ret), K(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::get_task(const ObTableLoadKey &key,
|
||||||
|
ObTableLoadClientTask *&client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadService *service = nullptr;
|
||||||
|
if (OB_ISNULL(service = MTL(ObTableLoadService *))) {
|
||||||
|
ret = OB_ERR_SYS;
|
||||||
|
LOG_WARN("null table load service", KR(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(
|
||||||
|
service->get_client_service().get_client_task_by_table_id(key.table_id_, client_task))) {
|
||||||
|
LOG_WARN("fail to get client task", KR(ret), K(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::commit_task(ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(nullptr == client_task)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), KPC(client_task));
|
||||||
|
} else if (OB_FAIL(client_task->set_status_committing())) {
|
||||||
|
LOG_WARN("fail to set status committing", KR(ret));
|
||||||
|
} else {
|
||||||
|
LOG_INFO("client task commit");
|
||||||
|
if (OB_FAIL(construct_commit_task(client_task))) {
|
||||||
|
LOG_WARN("fail to construct commit task", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
client_task->set_status_error(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::abort_task(ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(nullptr == client_task)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), KPC(client_task));
|
||||||
|
} else if (ObTableLoadClientStatus::ABORT == client_task->get_status()) {
|
||||||
|
// already abort
|
||||||
|
} else {
|
||||||
|
LOG_INFO("client task abort");
|
||||||
|
client_task->set_status_abort();
|
||||||
|
if (OB_FAIL(construct_abort_task(client_task))) {
|
||||||
|
LOG_WARN("fail to construct abort task", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::add_client_task(const ObTableLoadUniqueKey &key,
|
||||||
|
ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientService not init", KR(ret), KP(this));
|
||||||
|
} else if (OB_UNLIKELY(!key.is_valid() || nullptr == client_task)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(key), KP(client_task));
|
||||||
|
} else {
|
||||||
|
const uint64_t table_id = key.table_id_;
|
||||||
|
obsys::ObWLockGuard guard(rwlock_);
|
||||||
|
if (OB_FAIL(client_task_map_.set_refactored(key, client_task))) {
|
||||||
|
if (OB_UNLIKELY(OB_HASH_EXIST != ret)) {
|
||||||
|
LOG_WARN("fail to set refactored", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ret = OB_ENTRY_EXIST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// force update client task index
|
||||||
|
else if (OB_FAIL(client_task_index_map_.set_refactored(table_id, client_task, 1))) {
|
||||||
|
LOG_WARN("fail to set refactored", KR(ret), K(table_id));
|
||||||
|
// erase from client task map, avoid wild pointer is been use
|
||||||
|
int tmp_ret = OB_SUCCESS;
|
||||||
|
if (OB_TMP_FAIL(client_task_map_.erase_refactored(key))) {
|
||||||
|
LOG_WARN("fail to erase refactored", KR(tmp_ret), K(key));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client_task->inc_ref_count(); // hold by map
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::remove_client_task(const ObTableLoadUniqueKey &key,
|
||||||
|
ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientService not init", KR(ret), KP(this));
|
||||||
|
} else if (OB_UNLIKELY(!key.is_valid())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
const uint64_t table_id = key.table_id_;
|
||||||
|
HashMapEraseIfEqual erase_if_equal(client_task);
|
||||||
|
bool is_erased = false;
|
||||||
|
obsys::ObWLockGuard guard(rwlock_);
|
||||||
|
if (OB_FAIL(client_task_map_.erase_if(key, erase_if_equal, is_erased))) {
|
||||||
|
if (OB_UNLIKELY(OB_HASH_NOT_EXIST == ret)) {
|
||||||
|
LOG_WARN("fail to erase refactored", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ret = OB_ENTRY_NOT_EXIST;
|
||||||
|
}
|
||||||
|
} else if (OB_UNLIKELY(!is_erased)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected client task", KR(ret), KPC(client_task));
|
||||||
|
}
|
||||||
|
// try remove index
|
||||||
|
else if (OB_FAIL(client_task_index_map_.erase_if(table_id, erase_if_equal, is_erased))) {
|
||||||
|
if (OB_UNLIKELY(OB_HASH_NOT_EXIST == ret)) {
|
||||||
|
LOG_WARN("fail to get refactored", KR(ret), K(table_id));
|
||||||
|
} else {
|
||||||
|
ret = OB_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
client_task->dec_ref_count();
|
||||||
|
}
|
||||||
|
// add client task brief
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
ObTableLoadClientTaskBrief *client_task_brief = nullptr;
|
||||||
|
if (OB_FAIL(client_task_brief_map_.create(key, client_task_brief))) {
|
||||||
|
LOG_WARN("fail to create client task brief", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
client_task_brief->table_id_ = client_task->table_id_;
|
||||||
|
client_task_brief->dest_table_id_ = client_task->ddl_param_.dest_table_id_;
|
||||||
|
client_task_brief->task_id_ = client_task->ddl_param_.task_id_;
|
||||||
|
client_task->get_status(client_task_brief->client_status_, client_task_brief->error_code_);
|
||||||
|
client_task_brief->active_time_ = ObTimeUtil::current_time();
|
||||||
|
}
|
||||||
|
if (nullptr != client_task_brief) {
|
||||||
|
client_task_brief_map_.revert(client_task_brief);
|
||||||
|
client_task_brief = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::get_all_client_task(
|
||||||
|
ObIArray<ObTableLoadClientTask *> &client_task_array)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientService not init", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
client_task_array.reset();
|
||||||
|
obsys::ObWLockGuard guard(rwlock_);
|
||||||
|
for (ClientTaskMap::const_iterator iter = client_task_map_.begin();
|
||||||
|
OB_SUCC(ret) && iter != client_task_map_.end(); ++iter) {
|
||||||
|
const ObTableLoadUniqueKey &key = iter->first;
|
||||||
|
ObTableLoadClientTask *client_task = iter->second;
|
||||||
|
if (OB_FAIL(client_task_array.push_back(client_task))) {
|
||||||
|
LOG_WARN("fail to push back", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
client_task->inc_ref_count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
for (int64_t i = 0; i < client_task_array.count(); ++i) {
|
||||||
|
ObTableLoadClientTask *client_task = client_task_array.at(i);
|
||||||
|
client_task->dec_ref_count();
|
||||||
|
}
|
||||||
|
client_task_array.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::get_client_task(const ObTableLoadUniqueKey &key,
|
||||||
|
ObTableLoadClientTask *&client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
client_task = nullptr;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientService not init", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
obsys::ObRLockGuard guard(rwlock_);
|
||||||
|
if (OB_FAIL(client_task_map_.get_refactored(key, client_task))) {
|
||||||
|
if (OB_UNLIKELY(OB_HASH_NOT_EXIST != ret)) {
|
||||||
|
LOG_WARN("fail to get refactored", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
ret = OB_ENTRY_NOT_EXIST;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client_task->inc_ref_count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::get_client_task_by_table_id(uint64_t table_id,
|
||||||
|
ObTableLoadClientTask *&client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
client_task = nullptr;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientService not init", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
obsys::ObRLockGuard guard(rwlock_);
|
||||||
|
if (OB_FAIL(client_task_index_map_.get_refactored(table_id, client_task))) {
|
||||||
|
if (OB_UNLIKELY(OB_HASH_NOT_EXIST != ret)) {
|
||||||
|
LOG_WARN("fail to get refactored", KR(ret), K(table_id));
|
||||||
|
} else {
|
||||||
|
ret = OB_ENTRY_NOT_EXIST;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client_task->inc_ref_count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t ObTableLoadClientService::get_client_task_count() const
|
||||||
|
{
|
||||||
|
obsys::ObRLockGuard guard(rwlock_);
|
||||||
|
return client_task_map_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableLoadClientService::purge_client_task()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientService not init", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
ObArray<ObTableLoadClientTask *> client_task_array;
|
||||||
|
if (OB_FAIL(get_all_client_task(client_task_array))) {
|
||||||
|
LOG_WARN("fail to get all client task", KR(ret));
|
||||||
|
}
|
||||||
|
for (int64_t i = 0; i < client_task_array.count(); ++i) {
|
||||||
|
ObTableLoadClientTask *client_task = client_task_array.at(i);
|
||||||
|
ObTableLoadClientStatus client_status = client_task->get_status();
|
||||||
|
if (client_status != ObTableLoadClientStatus::COMMIT &&
|
||||||
|
client_status != ObTableLoadClientStatus::ABORT) {
|
||||||
|
// ignore
|
||||||
|
} else if (client_task->get_ref_count() > 2) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
// remove client task
|
||||||
|
else if (OB_FAIL(remove_task(client_task))) {
|
||||||
|
LOG_WARN("fail to remove client task", KR(ret), KPC(client_task));
|
||||||
|
}
|
||||||
|
revert_task(client_task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::get_task_brief(const ObTableLoadUniqueKey &key,
|
||||||
|
ObTableLoadClientTaskBrief *&client_task_brief)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadService *service = nullptr;
|
||||||
|
if (OB_ISNULL(service = MTL(ObTableLoadService *))) {
|
||||||
|
ret = OB_ERR_SYS;
|
||||||
|
LOG_WARN("null table load service", KR(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(service->get_client_service().get_client_task_brief(key, client_task_brief))) {
|
||||||
|
LOG_WARN("fail to get client task brief", KR(ret), K(key));
|
||||||
|
} else {
|
||||||
|
// update active time
|
||||||
|
client_task_brief->active_time_ = ObTimeUtil::current_time();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableLoadClientService::revert_task_brief(ObTableLoadClientTaskBrief *client_task_brief)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadService *service = nullptr;
|
||||||
|
if (OB_ISNULL(service = MTL(ObTableLoadService *))) {
|
||||||
|
ret = OB_ERR_SYS;
|
||||||
|
LOG_WARN("null table load service", KR(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(service->get_client_service().revert_client_task_brief(client_task_brief))) {
|
||||||
|
LOG_WARN("fail to revert client task brief", KR(ret), KP(client_task_brief));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::get_client_task_brief(const ObTableLoadUniqueKey &key,
|
||||||
|
ObTableLoadClientTaskBrief *&client_task_brief)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
client_task_brief = nullptr;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientService not init", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(client_task_brief_map_.get(key, client_task_brief))) {
|
||||||
|
if (OB_UNLIKELY(OB_ENTRY_NOT_EXIST != ret)) {
|
||||||
|
LOG_WARN("fail to get refactored", KR(ret), K(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::revert_client_task_brief(
|
||||||
|
ObTableLoadClientTaskBrief *client_task_brief)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientService not init", KR(ret), KP(this));
|
||||||
|
} else if (OB_UNLIKELY(nullptr == client_task_brief)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), KP(client_task_brief));
|
||||||
|
} else {
|
||||||
|
client_task_brief_map_.revert(client_task_brief);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableLoadClientService::purge_client_task_brief()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientService not init", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
const int64_t expired_ts = ObTimeUtil::current_time() - CLIENT_TASK_RETENTION_PERIOD;
|
||||||
|
ClientTaskBriefEraseIfExpired erase_if_expired(expired_ts);
|
||||||
|
if (OB_FAIL(client_task_brief_map_.remove_if(erase_if_expired))) {
|
||||||
|
LOG_WARN("fail to remove if client task brief", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::construct_commit_task(ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadTask *task = nullptr;
|
||||||
|
if (OB_FAIL(client_task->alloc_task(task))) {
|
||||||
|
LOG_WARN("fail to alloc task", KR(ret));
|
||||||
|
} else if (OB_FAIL(task->set_processor<CommitTaskProcessor>(client_task))) {
|
||||||
|
LOG_WARN("fail to set commit task processor", KR(ret));
|
||||||
|
} else if (OB_FAIL(task->set_callback<CommonTaskCallback>(client_task))) {
|
||||||
|
LOG_WARN("fail to set common task callback", KR(ret));
|
||||||
|
} else if (OB_FAIL(client_task->add_task(task))) {
|
||||||
|
LOG_WARN("fail to add task", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
if (nullptr != task) {
|
||||||
|
client_task->free_task(task);
|
||||||
|
task = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientService::construct_abort_task(ObTableLoadClientTask *client_task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObTableLoadTask *task = nullptr;
|
||||||
|
if (OB_FAIL(client_task->alloc_task(task))) {
|
||||||
|
LOG_WARN("fail to alloc task", KR(ret));
|
||||||
|
} else if (OB_FAIL(task->set_processor<AbortTaskProcessor>(client_task))) {
|
||||||
|
LOG_WARN("fail to set abort task processor", KR(ret));
|
||||||
|
} else if (OB_FAIL(task->set_callback<CommonTaskCallback>(client_task))) {
|
||||||
|
LOG_WARN("fail to set common task callback", KR(ret));
|
||||||
|
} else if (OB_FAIL(client_task->add_task(task))) {
|
||||||
|
LOG_WARN("fail to add task", KR(ret));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
if (nullptr != task) {
|
||||||
|
client_task->free_task(task);
|
||||||
|
task = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
135
src/observer/table_load/ob_table_load_client_service.h
Normal file
135
src/observer/table_load/ob_table_load_client_service.h
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "lib/hash/ob_hashmap.h"
|
||||||
|
#include "lib/hash/ob_link_hashmap.h"
|
||||||
|
#include "lib/lock/ob_mutex.h"
|
||||||
|
#include "observer/table_load/client/ob_table_direct_load_rpc_proxy.h"
|
||||||
|
#include "observer/table_load/ob_table_load_struct.h"
|
||||||
|
#include "share/table/ob_table_load_define.h"
|
||||||
|
#include "share/table/ob_table_load_row_array.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
class ObTableLoadTask;
|
||||||
|
class ObTableLoadClientTask;
|
||||||
|
class ObTableLoadClientTaskBrief;
|
||||||
|
class ObTableDirectLoadExecContext;
|
||||||
|
|
||||||
|
class ObTableLoadClientService
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObTableLoadClientService();
|
||||||
|
~ObTableLoadClientService();
|
||||||
|
int init();
|
||||||
|
|
||||||
|
static ObTableLoadClientService *get_client_service();
|
||||||
|
|
||||||
|
// client task api
|
||||||
|
static ObTableLoadClientTask *alloc_task();
|
||||||
|
static void free_task(ObTableLoadClientTask *client_task);
|
||||||
|
static void revert_task(ObTableLoadClientTask *client_task);
|
||||||
|
static int add_task(ObTableLoadClientTask *client_task);
|
||||||
|
static int remove_task(ObTableLoadClientTask *client_task);
|
||||||
|
static int get_task(const ObTableLoadUniqueKey &key, ObTableLoadClientTask *&client_task);
|
||||||
|
static int get_task(const ObTableLoadKey &key, ObTableLoadClientTask *&client_task);
|
||||||
|
static int commit_task(ObTableLoadClientTask *client_task);
|
||||||
|
static int abort_task(ObTableLoadClientTask *client_task);
|
||||||
|
|
||||||
|
int add_client_task(const ObTableLoadUniqueKey &key, ObTableLoadClientTask *client_task);
|
||||||
|
int remove_client_task(const ObTableLoadUniqueKey &key, ObTableLoadClientTask *client_task);
|
||||||
|
int get_all_client_task(common::ObIArray<ObTableLoadClientTask *> &client_task_array);
|
||||||
|
int get_client_task(const ObTableLoadUniqueKey &key, ObTableLoadClientTask *&client_task);
|
||||||
|
int get_client_task_by_table_id(uint64_t table_id, ObTableLoadClientTask *&client_task);
|
||||||
|
int64_t get_client_task_count() const;
|
||||||
|
void purge_client_task();
|
||||||
|
|
||||||
|
// client task brief api
|
||||||
|
static int get_task_brief(const ObTableLoadUniqueKey &key,
|
||||||
|
ObTableLoadClientTaskBrief *&client_task_brief);
|
||||||
|
static void revert_task_brief(ObTableLoadClientTaskBrief *client_task_brief);
|
||||||
|
int get_client_task_brief(const ObTableLoadUniqueKey &key,
|
||||||
|
ObTableLoadClientTaskBrief *&client_task_brief);
|
||||||
|
int revert_client_task_brief(ObTableLoadClientTaskBrief *client_task_brief);
|
||||||
|
void purge_client_task_brief();
|
||||||
|
|
||||||
|
// for table direct load api
|
||||||
|
static int direct_load_operate(ObTableDirectLoadExecContext &ctx,
|
||||||
|
const table::ObTableDirectLoadRequest &request,
|
||||||
|
table::ObTableDirectLoadResult &result)
|
||||||
|
{
|
||||||
|
return ObTableDirectLoadRpcProxy::dispatch(ctx, request, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static int construct_commit_task(ObTableLoadClientTask *client_task);
|
||||||
|
static int construct_abort_task(ObTableLoadClientTask *client_task);
|
||||||
|
private:
|
||||||
|
class CommitTaskProcessor;
|
||||||
|
class AbortTaskProcessor;
|
||||||
|
class CommonTaskCallback;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const int64_t CLIENT_TASK_RETENTION_PERIOD = 24LL * 60 * 60 * 1000 * 1000; // 1day
|
||||||
|
// key => client_task
|
||||||
|
typedef common::hash::ObHashMap<ObTableLoadUniqueKey, ObTableLoadClientTask *,
|
||||||
|
common::hash::NoPthreadDefendMode>
|
||||||
|
ClientTaskMap;
|
||||||
|
// table_id => client_task
|
||||||
|
typedef common::hash::ObHashMap<uint64_t, ObTableLoadClientTask *,
|
||||||
|
common::hash::NoPthreadDefendMode>
|
||||||
|
ClientTaskIndexMap;
|
||||||
|
// key => client_task_brief
|
||||||
|
typedef common::ObLinkHashMap<ObTableLoadUniqueKey, ObTableLoadClientTaskBrief>
|
||||||
|
ClientTaskBriefMap;
|
||||||
|
|
||||||
|
class HashMapEraseIfEqual
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HashMapEraseIfEqual(ObTableLoadClientTask *client_task) : client_task_(client_task) {}
|
||||||
|
bool operator()(
|
||||||
|
common::hash::HashMapPair<ObTableLoadUniqueKey, ObTableLoadClientTask *> &entry) const
|
||||||
|
{
|
||||||
|
return client_task_ == entry.second;
|
||||||
|
}
|
||||||
|
bool operator()(common::hash::HashMapPair<uint64_t, ObTableLoadClientTask *> &entry) const
|
||||||
|
{
|
||||||
|
return client_task_ == entry.second;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
ObTableLoadClientTask *client_task_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ClientTaskBriefEraseIfExpired
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ClientTaskBriefEraseIfExpired(int64_t expired_ts) : expired_ts_(expired_ts) {}
|
||||||
|
bool operator()(const ObTableLoadUniqueKey &key,
|
||||||
|
ObTableLoadClientTaskBrief *client_task_brief) const;
|
||||||
|
private:
|
||||||
|
int64_t expired_ts_;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable obsys::ObRWLock rwlock_;
|
||||||
|
ClientTaskMap client_task_map_;
|
||||||
|
ClientTaskIndexMap client_task_index_map_;
|
||||||
|
ClientTaskBriefMap client_task_brief_map_; // thread safety
|
||||||
|
bool is_inited_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
357
src/observer/table_load/ob_table_load_client_task.cpp
Normal file
357
src/observer/table_load/ob_table_load_client_task.cpp
Normal file
@ -0,0 +1,357 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "observer/table_load/ob_table_load_client_task.h"
|
||||||
|
#include "observer/table_load/ob_table_load_exec_ctx.h"
|
||||||
|
#include "observer/table_load/ob_table_load_schema.h"
|
||||||
|
#include "observer/table_load/ob_table_load_service.h"
|
||||||
|
#include "observer/table_load/ob_table_load_table_ctx.h"
|
||||||
|
#include "observer/table_load/ob_table_load_task_scheduler.h"
|
||||||
|
#include "observer/table_load/ob_table_load_utils.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
using namespace common;
|
||||||
|
using namespace table;
|
||||||
|
|
||||||
|
ObTableLoadClientTask::ObTableLoadClientTask()
|
||||||
|
: tenant_id_(OB_INVALID_ID),
|
||||||
|
user_id_(OB_INVALID_ID),
|
||||||
|
table_id_(OB_INVALID_ID),
|
||||||
|
allocator_("TLD_ClientTask"),
|
||||||
|
session_info_(nullptr),
|
||||||
|
exec_ctx_(nullptr),
|
||||||
|
task_scheduler_(nullptr),
|
||||||
|
next_trans_idx_(0),
|
||||||
|
table_ctx_(nullptr),
|
||||||
|
client_status_(ObTableLoadClientStatus::MAX_STATUS),
|
||||||
|
error_code_(OB_SUCCESS),
|
||||||
|
ref_count_(0),
|
||||||
|
is_inited_(false)
|
||||||
|
{
|
||||||
|
allocator_.set_tenant_id(MTL_ID());
|
||||||
|
free_session_ctx_.sessid_ = sql::ObSQLSessionInfo::INVALID_SESSID;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObTableLoadClientTask::~ObTableLoadClientTask()
|
||||||
|
{
|
||||||
|
if (nullptr != task_scheduler_) {
|
||||||
|
task_scheduler_->stop();
|
||||||
|
task_scheduler_->wait();
|
||||||
|
task_scheduler_->~ObITableLoadTaskScheduler();
|
||||||
|
allocator_.free(task_scheduler_);
|
||||||
|
task_scheduler_ = nullptr;
|
||||||
|
}
|
||||||
|
if (nullptr != session_info_) {
|
||||||
|
ObTableLoadUtils::free_session_info(session_info_, free_session_ctx_);
|
||||||
|
session_info_ = nullptr;
|
||||||
|
}
|
||||||
|
if (nullptr != exec_ctx_) {
|
||||||
|
exec_ctx_->~ObTableLoadClientExecCtx();
|
||||||
|
allocator_.free(exec_ctx_);
|
||||||
|
exec_ctx_ = nullptr;
|
||||||
|
}
|
||||||
|
if (nullptr != table_ctx_) {
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::remove_ctx(table_ctx_))) {
|
||||||
|
LOG_WARN("fail to remove table ctx", KR(ret), KP(table_ctx_));
|
||||||
|
}
|
||||||
|
ObTableLoadService::put_ctx(table_ctx_);
|
||||||
|
table_ctx_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::init(uint64_t tenant_id, uint64_t user_id, uint64_t table_id,
|
||||||
|
int64_t timeout_us)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_INIT) {
|
||||||
|
ret = OB_INIT_TWICE;
|
||||||
|
LOG_WARN("ObTableLoadClientTask init twice", KR(ret), KP(this));
|
||||||
|
} else if (OB_UNLIKELY(OB_INVALID_ID == tenant_id || OB_INVALID_ID == table_id ||
|
||||||
|
OB_INVALID_ID == user_id || 0 == timeout_us)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(tenant_id), K(user_id), K(table_id), K(timeout_us));
|
||||||
|
} else {
|
||||||
|
tenant_id_ = tenant_id;
|
||||||
|
user_id_ = user_id;
|
||||||
|
table_id_ = table_id;
|
||||||
|
if (OB_FAIL(init_column_names_and_idxs())) {
|
||||||
|
LOG_WARN("fail to init column names and idxs", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadUtils::create_session_info(user_id_, session_info_,
|
||||||
|
free_session_ctx_))) {
|
||||||
|
LOG_WARN("fail to create session info", KR(ret));
|
||||||
|
} else if (OB_FAIL(init_exec_ctx(timeout_us))) {
|
||||||
|
LOG_WARN("fail to init client exec ctx", KR(ret));
|
||||||
|
} else if (OB_FAIL(task_allocator_.init("TLD_TaskPool", MTL_ID()))) {
|
||||||
|
LOG_WARN("fail to init task allocator", KR(ret));
|
||||||
|
} else if (OB_ISNULL(task_scheduler_ = OB_NEWx(ObTableLoadTaskThreadPoolScheduler,
|
||||||
|
(&allocator_), 1, allocator_))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("fail to new ObTableLoadTaskThreadPoolScheduler", KR(ret));
|
||||||
|
} else if (OB_FAIL(task_scheduler_->init())) {
|
||||||
|
LOG_WARN("fail to init task scheduler", KR(ret));
|
||||||
|
} else if (OB_FAIL(task_scheduler_->start())) {
|
||||||
|
LOG_WARN("fail to start task scheduler", KR(ret));
|
||||||
|
} else {
|
||||||
|
is_inited_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::init_column_names_and_idxs()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObSchemaGetterGuard schema_guard;
|
||||||
|
const ObTableSchema *table_schema = nullptr;
|
||||||
|
if (OB_FAIL(
|
||||||
|
ObTableLoadSchema::get_table_schema(tenant_id_, table_id_, schema_guard, table_schema))) {
|
||||||
|
LOG_WARN("fail to get table schema", KR(ret), K_(tenant_id), K_(table_id));
|
||||||
|
} else if (OB_FAIL(
|
||||||
|
ObTableLoadSchema::get_column_names(table_schema, allocator_, column_names_))) {
|
||||||
|
LOG_WARN("fail to get all column name", KR(ret));
|
||||||
|
} else if (OB_UNLIKELY(column_names_.empty())) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected empty column names", KR(ret));
|
||||||
|
} else if (OB_FAIL(ObTableLoadSchema::get_column_idxs(table_schema, column_idxs_))) {
|
||||||
|
LOG_WARN("failed to get all column idx", K(ret));
|
||||||
|
} else if (OB_UNLIKELY(column_idxs_.empty())) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected empty column idxs", KR(ret));
|
||||||
|
} else if (OB_UNLIKELY(column_names_.count() != column_idxs_.count())) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected column names and idxs", KR(ret), K(column_names_), K(column_idxs_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::init_exec_ctx(int64_t timeout_us)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_ISNULL(exec_ctx_ = OB_NEWx(ObTableLoadClientExecCtx, &allocator_))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("fail to new client exec ctx", KR(ret));
|
||||||
|
} else {
|
||||||
|
exec_ctx_->allocator_ = &allocator_;
|
||||||
|
exec_ctx_->session_info_ = session_info_;
|
||||||
|
exec_ctx_->timeout_ts_ = ObTimeUtil::current_time() + timeout_us;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::set_table_ctx(ObTableLoadTableCtx *table_ctx)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(nullptr == table_ctx)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), KP(table_ctx));
|
||||||
|
} else {
|
||||||
|
obsys::ObWLockGuard guard(rw_lock_);
|
||||||
|
if (OB_UNLIKELY(nullptr != table_ctx_)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected set table ctx twice", KR(ret), KP(table_ctx_), KP(table_ctx));
|
||||||
|
} else {
|
||||||
|
table_ctx->inc_ref_count();
|
||||||
|
table_ctx_ = table_ctx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::get_table_ctx(ObTableLoadTableCtx *&table_ctx)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
table_ctx = nullptr;
|
||||||
|
obsys::ObRLockGuard guard(rw_lock_);
|
||||||
|
if (OB_UNLIKELY(nullptr == table_ctx_)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected null table ctx", KR(ret));
|
||||||
|
} else {
|
||||||
|
table_ctx = table_ctx_;
|
||||||
|
table_ctx->inc_ref_count();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::add_trans_id(const ObTableLoadTransId &trans_id)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(trans_ids_.push_back(trans_id))) {
|
||||||
|
LOG_WARN("fail to push back trans id", KR(ret), K(trans_id));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::get_next_trans_id(ObTableLoadTransId &trans_id)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(trans_ids_.empty())) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected empty trans id", KR(ret));
|
||||||
|
} else {
|
||||||
|
const int64_t trans_idx = ATOMIC_FAA(&next_trans_idx_, 1) % trans_ids_.count();
|
||||||
|
trans_id = trans_ids_.at(trans_idx);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::set_status_running()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
obsys::ObWLockGuard guard(rw_lock_);
|
||||||
|
if (OB_UNLIKELY(ObTableLoadClientStatus::MAX_STATUS != client_status_)) {
|
||||||
|
ret = OB_STATE_NOT_MATCH;
|
||||||
|
LOG_WARN("unexpected status", KR(ret), K(client_status_));
|
||||||
|
} else {
|
||||||
|
client_status_ = ObTableLoadClientStatus::RUNNING;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::set_status_committing()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
obsys::ObWLockGuard guard(rw_lock_);
|
||||||
|
if (OB_UNLIKELY(ObTableLoadClientStatus::RUNNING != client_status_)) {
|
||||||
|
ret = OB_STATE_NOT_MATCH;
|
||||||
|
LOG_WARN("unexpected status", KR(ret), K(client_status_));
|
||||||
|
} else {
|
||||||
|
client_status_ = ObTableLoadClientStatus::COMMITTING;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::set_status_commit()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
obsys::ObWLockGuard guard(rw_lock_);
|
||||||
|
if (OB_UNLIKELY(ObTableLoadClientStatus::COMMITTING != client_status_)) {
|
||||||
|
ret = OB_STATE_NOT_MATCH;
|
||||||
|
LOG_WARN("unexpected status", KR(ret), K(client_status_));
|
||||||
|
} else {
|
||||||
|
client_status_ = ObTableLoadClientStatus::COMMIT;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::set_status_error(int error_code)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_UNLIKELY(OB_SUCCESS == error_code)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), K(error_code));
|
||||||
|
} else {
|
||||||
|
obsys::ObWLockGuard guard(rw_lock_);
|
||||||
|
if (ObTableLoadClientStatus::ERROR == client_status_ ||
|
||||||
|
ObTableLoadClientStatus::ABORT == client_status_) {
|
||||||
|
// ignore
|
||||||
|
} else {
|
||||||
|
client_status_ = ObTableLoadClientStatus::ERROR;
|
||||||
|
error_code_ = error_code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableLoadClientTask::set_status_abort()
|
||||||
|
{
|
||||||
|
obsys::ObWLockGuard guard(rw_lock_);
|
||||||
|
if (ObTableLoadClientStatus::ABORT == client_status_) {
|
||||||
|
// ignore
|
||||||
|
} else {
|
||||||
|
client_status_ = ObTableLoadClientStatus::ABORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::check_status(ObTableLoadClientStatus client_status)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
obsys::ObRLockGuard guard(rw_lock_);
|
||||||
|
if (OB_UNLIKELY(client_status != client_status_)) {
|
||||||
|
if (ObTableLoadClientStatus::ERROR == client_status_) {
|
||||||
|
ret = error_code_;
|
||||||
|
} else if (ObTableLoadClientStatus::ABORT == client_status_) {
|
||||||
|
ret = OB_CANCELED;
|
||||||
|
} else {
|
||||||
|
ret = OB_STATE_NOT_MATCH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObTableLoadClientStatus ObTableLoadClientTask::get_status() const
|
||||||
|
{
|
||||||
|
obsys::ObRLockGuard guard(rw_lock_);
|
||||||
|
return client_status_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableLoadClientTask::get_status(ObTableLoadClientStatus &client_status,
|
||||||
|
int &error_code) const
|
||||||
|
{
|
||||||
|
obsys::ObRLockGuard guard(rw_lock_);
|
||||||
|
client_status = client_status_;
|
||||||
|
error_code = error_code_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::alloc_task(ObTableLoadTask *&task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientTask not init", KR(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_ISNULL(task = task_allocator_.alloc(MTL_ID()))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("fail to alloc task", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableLoadClientTask::free_task(ObTableLoadTask *task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientTask not init", KR(ret));
|
||||||
|
} else if (OB_ISNULL(task)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid null task", KR(ret));
|
||||||
|
} else {
|
||||||
|
task_allocator_.free(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadClientTask::add_task(ObTableLoadTask *task)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadClientTask not init", KR(ret));
|
||||||
|
} else if (OB_ISNULL(task)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid null task", KR(ret));
|
||||||
|
} else {
|
||||||
|
if (OB_FAIL(task_scheduler_->add_task(0, task))) {
|
||||||
|
LOG_WARN("fail to add task", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
117
src/observer/table_load/ob_table_load_client_task.h
Normal file
117
src/observer/table_load/ob_table_load_client_task.h
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "lib/hash/ob_link_hashmap.h"
|
||||||
|
#include "observer/table_load/ob_table_load_object_allocator.h"
|
||||||
|
#include "observer/table_load/ob_table_load_struct.h"
|
||||||
|
#include "share/table/ob_table_load_define.h"
|
||||||
|
#include "sql/session/ob_sql_session_mgr.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
class ObTableLoadClientExecCtx;
|
||||||
|
class ObTableLoadTableCtx;
|
||||||
|
class ObTableLoadTask;
|
||||||
|
class ObITableLoadTaskScheduler;
|
||||||
|
|
||||||
|
class ObTableLoadClientTask
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObTableLoadClientTask();
|
||||||
|
~ObTableLoadClientTask();
|
||||||
|
int init(uint64_t tenant_id, uint64_t user_id, uint64_t table_id, int64_t timeout_us);
|
||||||
|
bool is_inited() const { return is_inited_; }
|
||||||
|
int64_t get_ref_count() const { return ATOMIC_LOAD(&ref_count_); }
|
||||||
|
int64_t inc_ref_count() { return ATOMIC_AAF(&ref_count_, 1); }
|
||||||
|
int64_t dec_ref_count() { return ATOMIC_SAF(&ref_count_, 1); }
|
||||||
|
int set_table_ctx(ObTableLoadTableCtx *table_ctx);
|
||||||
|
int get_table_ctx(ObTableLoadTableCtx *&table_ctx);
|
||||||
|
OB_INLINE sql::ObSQLSessionInfo *get_session_info() { return session_info_; }
|
||||||
|
OB_INLINE ObTableLoadClientExecCtx *get_exec_ctx() { return exec_ctx_; }
|
||||||
|
int add_trans_id(const table::ObTableLoadTransId &trans_id);
|
||||||
|
int get_next_trans_id(table::ObTableLoadTransId &trans_id);
|
||||||
|
OB_INLINE const common::ObIArray<table::ObTableLoadTransId> &get_trans_ids() const
|
||||||
|
{
|
||||||
|
return trans_ids_;
|
||||||
|
}
|
||||||
|
int set_status_running();
|
||||||
|
int set_status_committing();
|
||||||
|
int set_status_commit();
|
||||||
|
int set_status_error(int error_code);
|
||||||
|
void set_status_abort();
|
||||||
|
table::ObTableLoadClientStatus get_status() const;
|
||||||
|
void get_status(table::ObTableLoadClientStatus &client_status, int &error_code) const;
|
||||||
|
int check_status(table::ObTableLoadClientStatus client_status);
|
||||||
|
int alloc_task(ObTableLoadTask *&task);
|
||||||
|
void free_task(ObTableLoadTask *task);
|
||||||
|
int add_task(ObTableLoadTask *task);
|
||||||
|
TO_STRING_KV(K_(tenant_id), K_(user_id), K_(table_id), K_(ddl_param), K_(column_names),
|
||||||
|
K_(column_idxs), K_(result_info), KP_(session_info), K_(free_session_ctx),
|
||||||
|
KP_(exec_ctx), KP_(task_scheduler), K_(trans_ids), K_(next_trans_idx),
|
||||||
|
KP_(table_ctx), K_(client_status), K_(error_code), K_(ref_count));
|
||||||
|
private:
|
||||||
|
int init_column_names_and_idxs();
|
||||||
|
int init_exec_ctx(int64_t timeout_us);
|
||||||
|
public:
|
||||||
|
uint64_t tenant_id_;
|
||||||
|
uint64_t user_id_;
|
||||||
|
uint64_t table_id_;
|
||||||
|
ObTableLoadDDLParam ddl_param_;
|
||||||
|
common::ObArray<ObString> column_names_;
|
||||||
|
common::ObArray<int64_t> column_idxs_;
|
||||||
|
table::ObTableLoadResultInfo result_info_;
|
||||||
|
private:
|
||||||
|
ObArenaAllocator allocator_;
|
||||||
|
sql::ObSQLSessionInfo *session_info_;
|
||||||
|
sql::ObFreeSessionCtx free_session_ctx_;
|
||||||
|
ObTableLoadClientExecCtx *exec_ctx_;
|
||||||
|
ObTableLoadObjectAllocator<ObTableLoadTask> task_allocator_;
|
||||||
|
ObITableLoadTaskScheduler *task_scheduler_;
|
||||||
|
common::ObArray<table::ObTableLoadTransId> trans_ids_;
|
||||||
|
int64_t next_trans_idx_;
|
||||||
|
mutable obsys::ObRWLock rw_lock_;
|
||||||
|
ObTableLoadTableCtx *table_ctx_;
|
||||||
|
table::ObTableLoadClientStatus client_status_;
|
||||||
|
int error_code_;
|
||||||
|
int64_t ref_count_ CACHE_ALIGNED;
|
||||||
|
bool is_inited_;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObTableLoadClientTaskBrief : public common::LinkHashValue<ObTableLoadUniqueKey>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObTableLoadClientTaskBrief()
|
||||||
|
: table_id_(common::OB_INVALID_ID),
|
||||||
|
dest_table_id_(common::OB_INVALID_ID),
|
||||||
|
task_id_(0),
|
||||||
|
client_status_(table::ObTableLoadClientStatus::MAX_STATUS),
|
||||||
|
error_code_(common::OB_SUCCESS),
|
||||||
|
active_time_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(table_id), K_(dest_table_id), K_(task_id), K_(client_status), K_(error_code),
|
||||||
|
K_(active_time));
|
||||||
|
public:
|
||||||
|
uint64_t table_id_;
|
||||||
|
uint64_t dest_table_id_;
|
||||||
|
int64_t task_id_;
|
||||||
|
table::ObTableLoadClientStatus client_status_;
|
||||||
|
int error_code_;
|
||||||
|
int64_t active_time_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -1,99 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#define USING_LOG_PREFIX SERVER
|
|
||||||
|
|
||||||
#include "observer/table_load/ob_table_load_commit_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_coordinator.h"
|
|
||||||
#include "observer/table_load/ob_table_load_service.h"
|
|
||||||
#include "observer/table_load/ob_table_load_store.h"
|
|
||||||
#include "sql/engine/ob_exec_context.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
using namespace table;
|
|
||||||
using namespace sql;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadCommitP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadCommitP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadCoordinator coordinator(table_ctx);
|
|
||||||
if (OB_FAIL(coordinator.init())) {
|
|
||||||
LOG_WARN("fail to init coordinator", KR(ret));
|
|
||||||
} else if (OB_FAIL(coordinator.commit(result_.result_info_))) {
|
|
||||||
LOG_WARN("fail to coordinator commit", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::remove_ctx(table_ctx))) {
|
|
||||||
LOG_WARN("fail to remove table ctx", KR(ret), K(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadCommitP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadCommitPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadCommitPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.commit(result_.result_info_, result_.sql_statistics_))) {
|
|
||||||
LOG_WARN("fail to store commit", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::remove_ctx(table_ctx))) {
|
|
||||||
LOG_WARN("fail to remove table ctx", KR(ret), K(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadCommitPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "observer/table/ob_table_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_proxy.h"
|
|
||||||
#include "share/table/ob_table_rpc_proxy.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
|
|
||||||
class ObTableLoadCommitP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_COMMIT> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadCommitP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadCommitP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadCommitP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadCommitPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_COMMIT_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadCommitPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadCommitPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadCommitPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "observer/table_load/ob_table_load_coordinator.h"
|
#include "observer/table_load/ob_table_load_coordinator.h"
|
||||||
#include "observer/ob_server.h"
|
#include "observer/ob_server.h"
|
||||||
|
#include "observer/table_load/control/ob_table_load_control_rpc_proxy.h"
|
||||||
#include "observer/table_load/ob_table_load_coordinator_ctx.h"
|
#include "observer/table_load/ob_table_load_coordinator_ctx.h"
|
||||||
#include "observer/table_load/ob_table_load_coordinator_trans.h"
|
#include "observer/table_load/ob_table_load_coordinator_trans.h"
|
||||||
#include "observer/table_load/ob_table_load_redef_table.h"
|
#include "observer/table_load/ob_table_load_redef_table.h"
|
||||||
@ -18,7 +19,6 @@
|
|||||||
#include "observer/table_load/ob_table_load_trans_bucket_writer.h"
|
#include "observer/table_load/ob_table_load_trans_bucket_writer.h"
|
||||||
#include "observer/table_load/ob_table_load_utils.h"
|
#include "observer/table_load/ob_table_load_utils.h"
|
||||||
#include "share/ob_share_util.h"
|
#include "share/ob_share_util.h"
|
||||||
#include "share/table/ob_table_load_rpc_struct.h"
|
|
||||||
#include "share/stat/ob_incremental_stat_estimator.h"
|
#include "share/stat/ob_incremental_stat_estimator.h"
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
@ -30,18 +30,17 @@ using namespace table;
|
|||||||
using namespace share;
|
using namespace share;
|
||||||
using namespace sql;
|
using namespace sql;
|
||||||
|
|
||||||
#define TABLE_LOAD_RPC_CALL(name, addr, request, ...) \
|
#define TABLE_LOAD_CONTROL_RPC_CALL(name, addr, arg, ...) \
|
||||||
if (OB_SUCC(ret)) { \
|
if (OB_SUCC(ret)) { \
|
||||||
|
ObTableLoadControlRpcProxy proxy(*GCTX.srv_rpc_proxy_); \
|
||||||
ObTimeoutCtx ctx; \
|
ObTimeoutCtx ctx; \
|
||||||
if (OB_FAIL(ObShareUtil::set_default_timeout_ctx(ctx, DEFAULT_TIMEOUT_US))) { \
|
if (OB_FAIL(ObShareUtil::set_default_timeout_ctx(ctx, DEFAULT_TIMEOUT_US))) { \
|
||||||
LOG_WARN("fail to set default timeout ctx", KR(ret)); \
|
LOG_WARN("fail to set default timeout ctx", KR(ret)); \
|
||||||
} else if (OB_FAIL(ObServer::get_instance() \
|
} else if (OB_FAIL(proxy.to(addr) \
|
||||||
.get_table_rpc_proxy() \
|
|
||||||
.to(addr) \
|
|
||||||
.timeout(ctx.get_timeout()) \
|
.timeout(ctx.get_timeout()) \
|
||||||
.by(MTL_ID()) \
|
.by(MTL_ID()) \
|
||||||
.name(request, ##__VA_ARGS__))) { \
|
.name(arg, ##__VA_ARGS__))) { \
|
||||||
LOG_WARN("fail to rpc call " #name, KR(ret), K(addr), K(request)); \
|
LOG_WARN("fail to rpc call " #name, KR(ret), K(addr), K(arg)); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,13 +63,13 @@ bool ObTableLoadCoordinator::is_ctx_inited(ObTableLoadTableCtx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ObTableLoadCoordinator::init_ctx(ObTableLoadTableCtx *ctx, const ObIArray<int64_t> &idx_array,
|
int ObTableLoadCoordinator::init_ctx(ObTableLoadTableCtx *ctx, const ObIArray<int64_t> &idx_array,
|
||||||
uint64_t user_id, ObTableLoadExecCtx *exec_ctx)
|
ObTableLoadExecCtx *exec_ctx)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (OB_ISNULL(ctx)) {
|
if (OB_ISNULL(ctx)) {
|
||||||
ret = OB_INVALID_ARGUMENT;
|
ret = OB_INVALID_ARGUMENT;
|
||||||
LOG_WARN("invalid agrs", KR(ret));
|
LOG_WARN("invalid agrs", KR(ret));
|
||||||
} else if (OB_FAIL(ctx->init_coordinator_ctx(idx_array, user_id, exec_ctx))) {
|
} else if (OB_FAIL(ctx->init_coordinator_ctx(idx_array, exec_ctx))) {
|
||||||
LOG_WARN("fail to init coordinator ctx", KR(ret));
|
LOG_WARN("fail to init coordinator ctx", KR(ret));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -141,11 +140,9 @@ int ObTableLoadCoordinator::abort_peers_ctx(ObTableLoadTableCtx *ctx)
|
|||||||
LOG_WARN("fail to get all addr", KR(ret));
|
LOG_WARN("fail to get all addr", KR(ret));
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_abort_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_abort_peer_request begin", K(all_addr_array.count()));
|
||||||
ObTableLoadAbortPeerRequest request;
|
ObDirectLoadControlAbortArg arg;
|
||||||
ObTableLoadAbortPeerResult result;
|
arg.table_id_ = ctx->param_.table_id_;
|
||||||
request.credential_ = ctx->coordinator_ctx_->credential_;
|
arg.task_id_ = ctx->ddl_param_.task_id_;
|
||||||
request.table_id_ = ctx->param_.table_id_;
|
|
||||||
request.task_id_ = ctx->ddl_param_.task_id_;
|
|
||||||
for (int64_t i = 0; i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
@ -153,7 +150,7 @@ int ObTableLoadCoordinator::abort_peers_ctx(ObTableLoadTableCtx *ctx)
|
|||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
const int64_t origin_timeout_ts = THIS_WORKER.get_timeout_ts();
|
const int64_t origin_timeout_ts = THIS_WORKER.get_timeout_ts();
|
||||||
THIS_WORKER.set_timeout_ts(INT64_MAX); // use default timeout value, avoid timeout now
|
THIS_WORKER.set_timeout_ts(INT64_MAX); // use default timeout value, avoid timeout now
|
||||||
TABLE_LOAD_RPC_CALL(load_abort_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(abort, addr, arg);
|
||||||
THIS_WORKER.set_timeout_ts(origin_timeout_ts);
|
THIS_WORKER.set_timeout_ts(origin_timeout_ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,37 +211,36 @@ int ObTableLoadCoordinator::pre_begin_peers()
|
|||||||
K(target_all_leader_info_array.count()), KR(ret));
|
K(target_all_leader_info_array.count()), KR(ret));
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_pre_begin_peer_request begin", K(all_leader_info_array.count()));
|
LOG_INFO("route_pre_begin_peer_request begin", K(all_leader_info_array.count()));
|
||||||
ObTableLoadPreBeginPeerRequest request;
|
ObDirectLoadControlPreBeginArg arg;
|
||||||
ObTableLoadPreBeginPeerResult result;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.config_.parallel_ = param_.session_count_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.config_.max_error_row_count_ = param_.max_error_row_count_;
|
||||||
request.config_.session_count_ = param_.session_count_;
|
arg.config_.batch_size_ = param_.batch_size_;
|
||||||
request.config_.max_error_row_count_ = param_.max_error_row_count_;
|
arg.config_.is_need_sort_ = param_.need_sort_;
|
||||||
request.config_.batch_size_ = param_.batch_size_;
|
arg.column_count_ = param_.column_count_;
|
||||||
request.config_.flag_.is_need_sort_ = param_.need_sort_;
|
arg.dup_action_ = param_.dup_action_;
|
||||||
request.column_count_ = param_.column_count_;
|
arg.px_mode_ = param_.px_mode_;
|
||||||
request.dup_action_ = param_.dup_action_;
|
arg.online_opt_stat_gather_ = param_.online_opt_stat_gather_;
|
||||||
request.px_mode_ = param_.px_mode_;
|
arg.dest_table_id_ = ctx_->ddl_param_.dest_table_id_;
|
||||||
request.online_opt_stat_gather_ = param_.online_opt_stat_gather_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.dest_table_id_ = ctx_->ddl_param_.dest_table_id_;
|
arg.schema_version_ = ctx_->ddl_param_.schema_version_;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
arg.snapshot_version_ = ctx_->ddl_param_.snapshot_version_;
|
||||||
request.schema_version_ = ctx_->ddl_param_.schema_version_;
|
arg.data_version_ = ctx_->ddl_param_.data_version_;
|
||||||
request.snapshot_version_ = ctx_->ddl_param_.snapshot_version_;
|
arg.session_info_ = ctx_->session_info_;
|
||||||
request.data_version_ = ctx_->ddl_param_.data_version_;
|
|
||||||
request.session_info_ = ctx_->session_info_;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_leader_info_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_leader_info_array.count(); ++i) {
|
||||||
const ObTableLoadPartitionLocation::LeaderInfo &leader_info = all_leader_info_array.at(i);
|
const ObTableLoadPartitionLocation::LeaderInfo &leader_info = all_leader_info_array.at(i);
|
||||||
const ObTableLoadPartitionLocation::LeaderInfo &target_leader_info = target_all_leader_info_array.at(i);
|
const ObTableLoadPartitionLocation::LeaderInfo &target_leader_info =
|
||||||
|
target_all_leader_info_array.at(i);
|
||||||
//目前源表和目标表的分区信息连同每个分区的地址都完全一样
|
//目前源表和目标表的分区信息连同每个分区的地址都完全一样
|
||||||
const ObAddr &addr = leader_info.addr_;
|
const ObAddr &addr = leader_info.addr_;
|
||||||
if (OB_UNLIKELY(leader_info.addr_ != target_leader_info.addr_)) {
|
if (OB_UNLIKELY(leader_info.addr_ != target_leader_info.addr_)) {
|
||||||
LOG_INFO("addr must be same", K(leader_info.addr_), K(target_leader_info.addr_));
|
LOG_INFO("addr must be same", K(leader_info.addr_), K(target_leader_info.addr_));
|
||||||
}
|
}
|
||||||
request.partition_id_array_ = leader_info.partition_id_array_;
|
arg.partition_id_array_ = leader_info.partition_id_array_;
|
||||||
request.target_partition_id_array_ = target_leader_info.partition_id_array_;
|
arg.target_partition_id_array_ = target_leader_info.partition_id_array_;
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
if (OB_FAIL(ObTableLoadStore::init_ctx(ctx_, request.partition_id_array_,
|
if (OB_FAIL(ObTableLoadStore::init_ctx(ctx_, arg.partition_id_array_,
|
||||||
request.target_partition_id_array_))) {
|
arg.target_partition_id_array_))) {
|
||||||
LOG_WARN("fail to store init ctx", KR(ret));
|
LOG_WARN("fail to store init ctx", KR(ret));
|
||||||
} else {
|
} else {
|
||||||
ObTableLoadStore store(ctx_);
|
ObTableLoadStore store(ctx_);
|
||||||
@ -255,7 +251,7 @@ int ObTableLoadCoordinator::pre_begin_peers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // 对端, 发送rpc
|
} else { // 对端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_pre_begin_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(pre_begin, addr, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,11 +266,9 @@ int ObTableLoadCoordinator::confirm_begin_peers()
|
|||||||
LOG_WARN("fail to get all addr", KR(ret));
|
LOG_WARN("fail to get all addr", KR(ret));
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_confirm_begin_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_confirm_begin_peer_request begin", K(all_addr_array.count()));
|
||||||
ObTableLoadConfirmBeginPeerRequest request;
|
ObDirectLoadControlConfirmBeginArg arg;
|
||||||
ObTableLoadConfirmBeginPeerResult result;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
@ -285,7 +279,7 @@ int ObTableLoadCoordinator::confirm_begin_peers()
|
|||||||
LOG_WARN("fail to store confirm begin", KR(ret));
|
LOG_WARN("fail to store confirm begin", KR(ret));
|
||||||
}
|
}
|
||||||
} else { // 对端, 发送rpc
|
} else { // 对端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_confirm_begin_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(confirm_begin, addr, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,18 +321,16 @@ int ObTableLoadCoordinator::pre_merge_peers()
|
|||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_pre_merge_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_pre_merge_peer_request begin", K(all_addr_array.count()));
|
||||||
ObArenaAllocator allocator("TLD_Coord");
|
ObArenaAllocator allocator("TLD_Coord");
|
||||||
ObTableLoadPreMergePeerRequest request;
|
ObDirectLoadControlPreMergeArg arg;
|
||||||
ObTableLoadPreMergePeerResult result;
|
|
||||||
allocator.set_tenant_id(MTL_ID());
|
allocator.set_tenant_id(MTL_ID());
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
if (!ctx_->param_.px_mode_) {
|
if (!ctx_->param_.px_mode_) {
|
||||||
if (OB_FAIL(coordinator_ctx_->get_committed_trans_ids(request.committed_trans_id_array_,
|
if (OB_FAIL(coordinator_ctx_->get_committed_trans_ids(arg.committed_trans_id_array_,
|
||||||
allocator))) {
|
allocator))) {
|
||||||
LOG_WARN("fail to get committed trans ids", KR(ret));
|
LOG_WARN("fail to get committed trans ids", KR(ret));
|
||||||
} else {
|
} else {
|
||||||
std::sort(request.committed_trans_id_array_.begin(), request.committed_trans_id_array_.end());
|
std::sort(arg.committed_trans_id_array_.begin(), arg.committed_trans_id_array_.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
@ -347,11 +339,11 @@ int ObTableLoadCoordinator::pre_merge_peers()
|
|||||||
ObTableLoadStore store(ctx_);
|
ObTableLoadStore store(ctx_);
|
||||||
if (OB_FAIL(store.init())) {
|
if (OB_FAIL(store.init())) {
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
} else if (OB_FAIL(store.pre_merge(request.committed_trans_id_array_))) {
|
} else if (OB_FAIL(store.pre_merge(arg.committed_trans_id_array_))) {
|
||||||
LOG_WARN("fail to store pre merge", KR(ret));
|
LOG_WARN("fail to store pre merge", KR(ret));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_pre_merge_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(pre_merge, addr, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,11 +358,9 @@ int ObTableLoadCoordinator::start_merge_peers()
|
|||||||
LOG_WARN("fail to get all addr", KR(ret));
|
LOG_WARN("fail to get all addr", KR(ret));
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_start_merge_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_start_merge_peer_request begin", K(all_addr_array.count()));
|
||||||
ObTableLoadStartMergePeerRequest request;
|
ObDirectLoadControlStartMergeArg arg;
|
||||||
ObTableLoadStartMergePeerResult result;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
@ -381,7 +371,7 @@ int ObTableLoadCoordinator::start_merge_peers()
|
|||||||
LOG_WARN("fail to store start merge", KR(ret));
|
LOG_WARN("fail to store start merge", KR(ret));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_start_merge_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(start_merge, addr, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,11 +440,10 @@ int ObTableLoadCoordinator::check_peers_merge_result(bool &is_finish)
|
|||||||
LOG_WARN("fail to get all addr", KR(ret));
|
LOG_WARN("fail to get all addr", KR(ret));
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_get_status_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_get_status_peer_request begin", K(all_addr_array.count()));
|
||||||
ObTableLoadGetStatusPeerRequest request;
|
ObDirectLoadControlGetStatusArg arg;
|
||||||
ObTableLoadGetStatusPeerResult result;
|
ObDirectLoadControlGetStatusRes res;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
is_finish = true;
|
is_finish = true;
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
@ -462,21 +451,21 @@ int ObTableLoadCoordinator::check_peers_merge_result(bool &is_finish)
|
|||||||
ObTableLoadStore store(ctx_);
|
ObTableLoadStore store(ctx_);
|
||||||
if (OB_FAIL(store.init())) {
|
if (OB_FAIL(store.init())) {
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
} else if (OB_FAIL(store.get_status(result.status_, result.error_code_))) {
|
} else if (OB_FAIL(store.get_status(res.status_, res.error_code_))) {
|
||||||
LOG_WARN("fail to store get status", KR(ret));
|
LOG_WARN("fail to store get status", KR(ret));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_get_status_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(get_status, addr, arg, res);
|
||||||
}
|
}
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
if (OB_UNLIKELY(ObTableLoadStatusType::ERROR == result.status_)) {
|
if (OB_UNLIKELY(ObTableLoadStatusType::ERROR == res.status_)) {
|
||||||
ret = result.error_code_;
|
ret = res.error_code_;
|
||||||
LOG_WARN("store has error", KR(ret), K(addr), K(result.status_));
|
LOG_WARN("store has error", KR(ret), K(addr), K(res.status_));
|
||||||
} else if (OB_UNLIKELY(ObTableLoadStatusType::MERGING != result.status_ &&
|
} else if (OB_UNLIKELY(ObTableLoadStatusType::MERGING != res.status_ &&
|
||||||
ObTableLoadStatusType::MERGED != result.status_)) {
|
ObTableLoadStatusType::MERGED != res.status_)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("unexpected peer status", KR(ret), K(addr), K(result.status_));
|
LOG_WARN("unexpected peer status", KR(ret), K(addr), K(res.status_));
|
||||||
} else if (ObTableLoadStatusType::MERGED != result.status_) {
|
} else if (ObTableLoadStatusType::MERGED != res.status_) {
|
||||||
is_finish = false;
|
is_finish = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -599,30 +588,29 @@ int ObTableLoadCoordinator::commit_peers(ObTableLoadSqlStatistics &sql_statistic
|
|||||||
LOG_WARN("fail to get all addr", KR(ret));
|
LOG_WARN("fail to get all addr", KR(ret));
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_commit_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_commit_peer_request begin", K(all_addr_array.count()));
|
||||||
ObTableLoadCommitPeerRequest request;
|
ObDirectLoadControlCommitArg arg;
|
||||||
ObTableLoadCommitPeerResult result;
|
ObDirectLoadControlCommitRes res;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
ObTableLoadStore store(ctx_);
|
ObTableLoadStore store(ctx_);
|
||||||
if (OB_FAIL(store.init())) {
|
if (OB_FAIL(store.init())) {
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
} else if (OB_FAIL(store.commit(result.result_info_, result.sql_statistics_))) {
|
} else if (OB_FAIL(store.commit(res.result_info_, res.sql_statistics_))) {
|
||||||
LOG_WARN("fail to commit store", KR(ret));
|
LOG_WARN("fail to commit store", KR(ret));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_commit_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(commit, addr, arg, res);
|
||||||
}
|
}
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
ATOMIC_AAF(&coordinator_ctx_->result_info_.rows_affected_, result.result_info_.rows_affected_);
|
ATOMIC_AAF(&coordinator_ctx_->result_info_.rows_affected_, res.result_info_.rows_affected_);
|
||||||
ATOMIC_AAF(&coordinator_ctx_->result_info_.deleted_, result.result_info_.deleted_);
|
ATOMIC_AAF(&coordinator_ctx_->result_info_.deleted_, res.result_info_.deleted_);
|
||||||
ATOMIC_AAF(&coordinator_ctx_->result_info_.skipped_, result.result_info_.skipped_);
|
ATOMIC_AAF(&coordinator_ctx_->result_info_.skipped_, res.result_info_.skipped_);
|
||||||
ATOMIC_AAF(&coordinator_ctx_->result_info_.warnings_, result.result_info_.warnings_);
|
ATOMIC_AAF(&coordinator_ctx_->result_info_.warnings_, res.result_info_.warnings_);
|
||||||
if (OB_FAIL(sql_statistics.add(result.sql_statistics_))) {
|
if (OB_FAIL(sql_statistics.add(res.sql_statistics_))) {
|
||||||
LOG_WARN("fail to add result sql stats", KR(ret), K(addr), K(result));
|
LOG_WARN("fail to add result sql stats", KR(ret), K(addr), K(res));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -786,12 +774,10 @@ int ObTableLoadCoordinator::pre_start_trans_peers(ObTableLoadCoordinatorTrans *t
|
|||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_pre_start_trans_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_pre_start_trans_peer_request begin", K(all_addr_array.count()));
|
||||||
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
||||||
ObTableLoadPreStartTransPeerRequest request;
|
ObDirectLoadControlPreStartTransArg arg;
|
||||||
ObTableLoadPreStartTransPeerResult result;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.trans_id_ = trans_id;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
request.trans_id_ = trans_id;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
@ -802,7 +788,7 @@ int ObTableLoadCoordinator::pre_start_trans_peers(ObTableLoadCoordinatorTrans *t
|
|||||||
LOG_WARN("fail to store pre start trans", KR(ret), K(trans_id));
|
LOG_WARN("fail to store pre start trans", KR(ret), K(trans_id));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_pre_start_trans_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(pre_start_trans, addr, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -818,12 +804,10 @@ int ObTableLoadCoordinator::confirm_start_trans_peers(ObTableLoadCoordinatorTran
|
|||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_confirm_start_trans_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_confirm_start_trans_peer_request begin", K(all_addr_array.count()));
|
||||||
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
||||||
ObTableLoadConfirmStartTransPeerRequest request;
|
ObDirectLoadControlConfirmStartTransArg arg;
|
||||||
ObTableLoadConfirmStartTransPeerResult result;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.trans_id_ = trans_id;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
request.trans_id_ = trans_id;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
@ -834,7 +818,7 @@ int ObTableLoadCoordinator::confirm_start_trans_peers(ObTableLoadCoordinatorTran
|
|||||||
LOG_WARN("fail to store confirm start trans", KR(ret), K(trans_id));
|
LOG_WARN("fail to store confirm start trans", KR(ret), K(trans_id));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_confirm_start_trans_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(confirm_start_trans, addr, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -903,12 +887,10 @@ int ObTableLoadCoordinator::pre_finish_trans_peers(ObTableLoadCoordinatorTrans *
|
|||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_pre_finish_trans_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_pre_finish_trans_peer_request begin", K(all_addr_array.count()));
|
||||||
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
||||||
ObTableLoadPreFinishTransPeerRequest request;
|
ObDirectLoadControlPreFinishTransArg arg;
|
||||||
ObTableLoadPreFinishTransPeerResult result;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.trans_id_ = trans_id;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
request.trans_id_ = trans_id;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
@ -919,7 +901,7 @@ int ObTableLoadCoordinator::pre_finish_trans_peers(ObTableLoadCoordinatorTrans *
|
|||||||
LOG_WARN("fail to store pre finish trans", KR(ret), K(trans_id));
|
LOG_WARN("fail to store pre finish trans", KR(ret), K(trans_id));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_pre_finish_trans_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(pre_finish_trans, addr, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -935,12 +917,10 @@ int ObTableLoadCoordinator::confirm_finish_trans_peers(ObTableLoadCoordinatorTra
|
|||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_pre_finish_trans_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_pre_finish_trans_peer_request begin", K(all_addr_array.count()));
|
||||||
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
||||||
ObTableLoadConfirmFinishTransPeerRequest request;
|
ObDirectLoadControlConfirmFinishTransArg arg;
|
||||||
ObTableLoadConfirmFinishTransPeerResult result;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.trans_id_ = trans_id;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
request.trans_id_ = trans_id;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
@ -951,7 +931,7 @@ int ObTableLoadCoordinator::confirm_finish_trans_peers(ObTableLoadCoordinatorTra
|
|||||||
LOG_WARN("fail to store confirm finish trans", KR(ret), K(trans_id));
|
LOG_WARN("fail to store confirm finish trans", KR(ret), K(trans_id));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_confirm_finish_trans_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(confirm_finish_trans, addr, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -994,12 +974,11 @@ int ObTableLoadCoordinator::check_peers_trans_commit(ObTableLoadCoordinatorTrans
|
|||||||
LOG_WARN("fail to get all addr", KR(ret));
|
LOG_WARN("fail to get all addr", KR(ret));
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_check_peers_trans_commit begin", K(all_addr_array.count()));
|
LOG_INFO("route_check_peers_trans_commit begin", K(all_addr_array.count()));
|
||||||
ObTableLoadGetTransStatusPeerRequest request;
|
ObDirectLoadControlGetTransStatusArg arg;
|
||||||
ObTableLoadGetTransStatusPeerResult result;
|
ObDirectLoadControlGetTransStatusRes res;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
arg.trans_id_ = trans->get_trans_id();
|
||||||
request.trans_id_ = trans->get_trans_id();
|
|
||||||
is_commit = true;
|
is_commit = true;
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
@ -1007,22 +986,22 @@ int ObTableLoadCoordinator::check_peers_trans_commit(ObTableLoadCoordinatorTrans
|
|||||||
ObTableLoadStore store(ctx_);
|
ObTableLoadStore store(ctx_);
|
||||||
if (OB_FAIL(store.init())) {
|
if (OB_FAIL(store.init())) {
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
LOG_WARN("fail to init store", KR(ret));
|
||||||
} else if (OB_FAIL(store.get_trans_status(request.trans_id_, result.trans_status_,
|
} else if (OB_FAIL(store.get_trans_status(arg.trans_id_, res.trans_status_,
|
||||||
result.error_code_))) {
|
res.error_code_))) {
|
||||||
LOG_WARN("fail to store get trans status", KR(ret));
|
LOG_WARN("fail to store get trans status", KR(ret));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_get_trans_status_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(get_trans_status, addr, arg, res);
|
||||||
}
|
}
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
if (OB_UNLIKELY(ObTableLoadTransStatusType::ERROR == result.trans_status_)) {
|
if (OB_UNLIKELY(ObTableLoadTransStatusType::ERROR == res.trans_status_)) {
|
||||||
ret = result.error_code_;
|
ret = res.error_code_;
|
||||||
LOG_WARN("trans has error", KR(ret), K(addr));
|
LOG_WARN("trans has error", KR(ret), K(addr));
|
||||||
} else if (OB_UNLIKELY(ObTableLoadTransStatusType::FROZEN != result.trans_status_ &&
|
} else if (OB_UNLIKELY(ObTableLoadTransStatusType::FROZEN != res.trans_status_ &&
|
||||||
ObTableLoadTransStatusType::COMMIT != result.trans_status_)) {
|
ObTableLoadTransStatusType::COMMIT != res.trans_status_)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("unexpected peer trans status", KR(ret), K(addr), K(result.trans_status_));
|
LOG_WARN("unexpected peer trans status", KR(ret), K(addr), K(res.trans_status_));
|
||||||
} else if (ObTableLoadTransStatusType::COMMIT != result.trans_status_) {
|
} else if (ObTableLoadTransStatusType::COMMIT != res.trans_status_) {
|
||||||
is_commit = false;
|
is_commit = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1184,12 +1163,10 @@ int ObTableLoadCoordinator::abandon_trans_peers(ObTableLoadCoordinatorTrans *tra
|
|||||||
} else {
|
} else {
|
||||||
LOG_INFO("route_abandon_trans_peer_request begin", K(all_addr_array.count()));
|
LOG_INFO("route_abandon_trans_peer_request begin", K(all_addr_array.count()));
|
||||||
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
const ObTableLoadTransId &trans_id = trans->get_trans_id();
|
||||||
ObTableLoadAbandonTransPeerRequest request;
|
ObDirectLoadControlAbandonTransArg arg;
|
||||||
ObTableLoadAbandonTransPeerResult result;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.trans_id_ = trans_id;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
|
||||||
request.trans_id_ = trans_id;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < all_addr_array.count(); ++i) {
|
||||||
const ObAddr &addr = all_addr_array.at(i);
|
const ObAddr &addr = all_addr_array.at(i);
|
||||||
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
if (ObTableLoadUtils::is_local_addr(addr)) { // 本机
|
||||||
@ -1200,7 +1177,7 @@ int ObTableLoadCoordinator::abandon_trans_peers(ObTableLoadCoordinatorTrans *tra
|
|||||||
LOG_WARN("fail to store abandon trans", KR(ret), K(trans_id));
|
LOG_WARN("fail to store abandon trans", KR(ret), K(trans_id));
|
||||||
}
|
}
|
||||||
} else { // 远端, 发送rpc
|
} else { // 远端, 发送rpc
|
||||||
TABLE_LOAD_RPC_CALL(load_abandon_trans_peer, addr, request, result);
|
TABLE_LOAD_CONTROL_RPC_CALL(abandon_trans, addr, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1429,6 +1406,68 @@ int ObTableLoadCoordinator::write(const ObTableLoadTransId &trans_id, int32_t se
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ObTableLoadCoordinator::write(const ObTableLoadTransId &trans_id,
|
||||||
|
const ObTableLoadObjRowArray &obj_rows)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadCoordinator not init", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG("coordinator write");
|
||||||
|
ObTableLoadCoordinatorTrans *trans = nullptr;
|
||||||
|
ObTableLoadTransBucketWriter *bucket_writer = nullptr;
|
||||||
|
int32_t session_id = 0;
|
||||||
|
if (OB_FAIL(coordinator_ctx_->get_trans(trans_id, trans))) {
|
||||||
|
LOG_WARN("fail to get trans", KR(ret));
|
||||||
|
} else if (FALSE_IT(session_id = trans->get_default_session_id())) {
|
||||||
|
}
|
||||||
|
// 取出bucket_writer
|
||||||
|
else if (OB_FAIL(trans->get_bucket_writer_for_write(bucket_writer))) {
|
||||||
|
LOG_WARN("fail to get bucket writer", KR(ret));
|
||||||
|
} else {
|
||||||
|
ObTableLoadTask *task = nullptr;
|
||||||
|
WriteTaskProcessor *processor = nullptr;
|
||||||
|
// 1. 分配task
|
||||||
|
if (OB_FAIL(ctx_->alloc_task(task))) {
|
||||||
|
LOG_WARN("fail to alloc task", KR(ret));
|
||||||
|
}
|
||||||
|
// 2. 设置processor
|
||||||
|
else if (OB_FAIL(
|
||||||
|
task->set_processor<WriteTaskProcessor>(ctx_, trans, bucket_writer, session_id))) {
|
||||||
|
LOG_WARN("fail to set write task processor", KR(ret));
|
||||||
|
} else if (OB_ISNULL(processor = dynamic_cast<WriteTaskProcessor *>(task->get_processor()))) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("unexpected null processor", KR(ret));
|
||||||
|
} else if (OB_FAIL(processor->set_objs(obj_rows, coordinator_ctx_->idx_array_))) {
|
||||||
|
LOG_WARN("fail to set objs", KR(ret), K(coordinator_ctx_->idx_array_));
|
||||||
|
}
|
||||||
|
// 3. 设置callback
|
||||||
|
else if (OB_FAIL(task->set_callback<WriteTaskCallback>(ctx_, trans, bucket_writer))) {
|
||||||
|
LOG_WARN("fail to set write task callback", KR(ret));
|
||||||
|
}
|
||||||
|
// 4. 把task放入调度器
|
||||||
|
else if (OB_FAIL(coordinator_ctx_->task_scheduler_->add_task(session_id - 1, task))) {
|
||||||
|
LOG_WARN("fail to add task", KR(ret), K(session_id), KPC(task));
|
||||||
|
}
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
if (nullptr != task) {
|
||||||
|
ctx_->free_task(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OB_NOT_NULL(trans)) {
|
||||||
|
if (OB_NOT_NULL(bucket_writer)) {
|
||||||
|
trans->put_bucket_writer(bucket_writer);
|
||||||
|
bucket_writer = nullptr;
|
||||||
|
}
|
||||||
|
coordinator_ctx_->put_trans(trans);
|
||||||
|
trans = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flush
|
* flush
|
||||||
*/
|
*/
|
||||||
@ -1584,16 +1623,14 @@ int ObTableLoadCoordinator::write_peer_leader(const ObTableLoadTransId &trans_id
|
|||||||
} else if (OB_FAIL(tablet_obj_rows.serialize(buf, buf_len, pos))) {
|
} else if (OB_FAIL(tablet_obj_rows.serialize(buf, buf_len, pos))) {
|
||||||
LOG_WARN("failed to serialize obj row array", KR(ret), KP(buf), K(buf_len), K(pos));
|
LOG_WARN("failed to serialize obj row array", KR(ret), KP(buf), K(buf_len), K(pos));
|
||||||
} else {
|
} else {
|
||||||
ObTableLoadPeerRequest request;
|
ObDirectLoadControlInsertTransArg arg;
|
||||||
ObTableLoadPeerResult result;
|
arg.table_id_ = param_.table_id_;
|
||||||
request.credential_ = coordinator_ctx_->credential_;
|
arg.task_id_ = ctx_->ddl_param_.task_id_;
|
||||||
request.table_id_ = param_.table_id_;
|
arg.trans_id_ = trans_id;
|
||||||
request.task_id_ = ctx_->ddl_param_.task_id_;
|
arg.session_id_ = session_id;
|
||||||
request.trans_id_ = trans_id;
|
arg.sequence_no_ = sequence_no;
|
||||||
request.session_id_ = session_id;
|
arg.payload_.assign(buf, buf_len);
|
||||||
request.sequence_no_ = sequence_no;
|
TABLE_LOAD_CONTROL_RPC_CALL(insert_trans, addr, arg);
|
||||||
request.payload_.assign(buf, buf_len);
|
|
||||||
TABLE_LOAD_RPC_CALL(load_peer, addr, request, result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public:
|
|||||||
ObTableLoadCoordinator(ObTableLoadTableCtx *ctx);
|
ObTableLoadCoordinator(ObTableLoadTableCtx *ctx);
|
||||||
static bool is_ctx_inited(ObTableLoadTableCtx *ctx);
|
static bool is_ctx_inited(ObTableLoadTableCtx *ctx);
|
||||||
static int init_ctx(ObTableLoadTableCtx *ctx, const common::ObIArray<int64_t> &idx_array,
|
static int init_ctx(ObTableLoadTableCtx *ctx, const common::ObIArray<int64_t> &idx_array,
|
||||||
uint64_t user_id, ObTableLoadExecCtx *exec_ctx);
|
ObTableLoadExecCtx *exec_ctx);
|
||||||
static void abort_ctx(ObTableLoadTableCtx *ctx);
|
static void abort_ctx(ObTableLoadTableCtx *ctx);
|
||||||
int init();
|
int init();
|
||||||
bool is_valid() const { return is_inited_; }
|
bool is_valid() const { return is_inited_; }
|
||||||
@ -90,6 +90,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
int write(const table::ObTableLoadTransId &trans_id, int32_t session_id, uint64_t sequence_no,
|
int write(const table::ObTableLoadTransId &trans_id, int32_t session_id, uint64_t sequence_no,
|
||||||
const table::ObTableLoadObjRowArray &obj_rows);
|
const table::ObTableLoadObjRowArray &obj_rows);
|
||||||
|
// for client
|
||||||
|
int write(const table::ObTableLoadTransId &trans_id, const table::ObTableLoadObjRowArray &obj_rows);
|
||||||
int flush(ObTableLoadCoordinatorTrans *trans);
|
int flush(ObTableLoadCoordinatorTrans *trans);
|
||||||
// 只写到主节点
|
// 只写到主节点
|
||||||
int write_peer_leader(const table::ObTableLoadTransId &trans_id, int32_t session_id,
|
int write_peer_leader(const table::ObTableLoadTransId &trans_id, int32_t session_id,
|
||||||
|
|||||||
@ -79,7 +79,7 @@ int ObTableLoadCoordinatorCtx::init_partition_location()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObTableLoadCoordinatorCtx::init(const ObIArray<int64_t> &idx_array, uint64_t user_id,
|
int ObTableLoadCoordinatorCtx::init(const ObIArray<int64_t> &idx_array,
|
||||||
ObTableLoadExecCtx *exec_ctx)
|
ObTableLoadExecCtx *exec_ctx)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
@ -87,12 +87,11 @@ int ObTableLoadCoordinatorCtx::init(const ObIArray<int64_t> &idx_array, uint64_t
|
|||||||
ret = OB_INIT_TWICE;
|
ret = OB_INIT_TWICE;
|
||||||
LOG_WARN("ObTableLoadCoordinatorCtx init twice", KR(ret), KP(this));
|
LOG_WARN("ObTableLoadCoordinatorCtx init twice", KR(ret), KP(this));
|
||||||
} else if (OB_UNLIKELY(
|
} else if (OB_UNLIKELY(
|
||||||
idx_array.count() != ctx_->param_.column_count_ || OB_INVALID_ID == user_id ||
|
idx_array.count() != ctx_->param_.column_count_ || nullptr == exec_ctx ||
|
||||||
nullptr == exec_ctx || !exec_ctx->is_valid() ||
|
!exec_ctx->is_valid() ||
|
||||||
(ctx_->param_.online_opt_stat_gather_ && nullptr == exec_ctx->get_exec_ctx()))) {
|
(ctx_->param_.online_opt_stat_gather_ && nullptr == exec_ctx->get_exec_ctx()))) {
|
||||||
ret = OB_INVALID_ARGUMENT;
|
ret = OB_INVALID_ARGUMENT;
|
||||||
LOG_WARN("invalid args", KR(ret), K(ctx_->param_), K(idx_array.count()), K(user_id),
|
LOG_WARN("invalid args", KR(ret), K(ctx_->param_), K(idx_array.count()), KPC(exec_ctx));
|
||||||
KPC(exec_ctx));
|
|
||||||
} else {
|
} else {
|
||||||
allocator_.set_tenant_id(MTL_ID());
|
allocator_.set_tenant_id(MTL_ID());
|
||||||
if (OB_FAIL(target_schema_.init(ctx_->param_.tenant_id_, ctx_->ddl_param_.dest_table_id_))) {
|
if (OB_FAIL(target_schema_.init(ctx_->param_.tenant_id_, ctx_->ddl_param_.dest_table_id_))) {
|
||||||
@ -128,10 +127,6 @@ int ObTableLoadCoordinatorCtx::init(const ObIArray<int64_t> &idx_array, uint64_t
|
|||||||
else if (OB_FAIL(segment_ctx_map_.init("TLD_SegCtxMap", ctx_->param_.tenant_id_))) {
|
else if (OB_FAIL(segment_ctx_map_.init("TLD_SegCtxMap", ctx_->param_.tenant_id_))) {
|
||||||
LOG_WARN("fail to init segment ctx map", KR(ret));
|
LOG_WARN("fail to init segment ctx map", KR(ret));
|
||||||
}
|
}
|
||||||
// generate credential_
|
|
||||||
else if (OB_FAIL(generate_credential(user_id))) {
|
|
||||||
LOG_WARN("fail to generate credential", KR(ret), K(user_id));
|
|
||||||
}
|
|
||||||
// init task_scheduler_
|
// init task_scheduler_
|
||||||
else if (OB_ISNULL(task_scheduler_ = OB_NEWx(ObTableLoadTaskThreadPoolScheduler, (&allocator_),
|
else if (OB_ISNULL(task_scheduler_ = OB_NEWx(ObTableLoadTaskThreadPoolScheduler, (&allocator_),
|
||||||
ctx_->param_.session_count_, allocator_))) {
|
ctx_->param_.session_count_, allocator_))) {
|
||||||
@ -202,31 +197,6 @@ void ObTableLoadCoordinatorCtx::destroy()
|
|||||||
commited_trans_ctx_array_.reset();
|
commited_trans_ctx_array_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObTableLoadCoordinatorCtx::generate_credential(uint64_t user_id)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
const int64_t expire_ts = 0;
|
|
||||||
|
|
||||||
share::schema::ObSchemaGetterGuard schema_guard;
|
|
||||||
const share::schema::ObUserInfo *user_info = NULL;
|
|
||||||
if (OB_ISNULL(GCTX.schema_service_)) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("invalid schema service", K(ret));
|
|
||||||
} else if (OB_FAIL(GCTX.schema_service_->get_tenant_schema_guard(ctx_->param_.tenant_id_, schema_guard))) {
|
|
||||||
LOG_WARN("fail to get schema guard", K(ret), "tenant_id", ctx_->param_.tenant_id_);
|
|
||||||
} else if (OB_FAIL(schema_guard.get_user_info(ctx_->param_.tenant_id_, user_id, user_info))) {
|
|
||||||
LOG_WARN("fail to get user info", K(ret), K(ctx_->param_.tenant_id_), K(user_id));
|
|
||||||
} else if (OB_ISNULL(user_info)) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("user info is null", K(ret), K(ctx_->param_.tenant_id_), K(user_id));
|
|
||||||
} else if (OB_FAIL(ObTableLoadUtils::generate_credential(ctx_->param_.tenant_id_, user_id,
|
|
||||||
0, expire_ts,
|
|
||||||
user_info->get_passwd_str().hash(), allocator_, credential_))) {
|
|
||||||
LOG_WARN("fail to generate credential", KR(ret));
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadCoordinatorCtx::advance_status(ObTableLoadStatusType status)
|
int ObTableLoadCoordinatorCtx::advance_status(ObTableLoadStatusType status)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
|||||||
@ -34,8 +34,7 @@ class ObTableLoadCoordinatorCtx
|
|||||||
public:
|
public:
|
||||||
ObTableLoadCoordinatorCtx(ObTableLoadTableCtx *ctx);
|
ObTableLoadCoordinatorCtx(ObTableLoadTableCtx *ctx);
|
||||||
~ObTableLoadCoordinatorCtx();
|
~ObTableLoadCoordinatorCtx();
|
||||||
int init(const common::ObIArray<int64_t> &idx_array, uint64_t user_id,
|
int init(const common::ObIArray<int64_t> &idx_array, ObTableLoadExecCtx *exec_ctx);
|
||||||
ObTableLoadExecCtx *exec_ctx);
|
|
||||||
void stop();
|
void stop();
|
||||||
void destroy();
|
void destroy();
|
||||||
bool is_valid() const { return is_inited_; }
|
bool is_valid() const { return is_inited_; }
|
||||||
@ -102,7 +101,6 @@ public:
|
|||||||
int check_exist_trans(bool &is_exist) const;
|
int check_exist_trans(bool &is_exist) const;
|
||||||
int check_exist_committed_trans(bool &is_exist) const;
|
int check_exist_committed_trans(bool &is_exist) const;
|
||||||
private:
|
private:
|
||||||
int generate_credential(uint64_t user_id);
|
|
||||||
int alloc_trans_ctx(const table::ObTableLoadTransId &trans_id, ObTableLoadTransCtx *&trans_ctx);
|
int alloc_trans_ctx(const table::ObTableLoadTransId &trans_id, ObTableLoadTransCtx *&trans_ctx);
|
||||||
int alloc_trans(const table::ObTableLoadSegmentID &segment_id,
|
int alloc_trans(const table::ObTableLoadSegmentID &segment_id,
|
||||||
ObTableLoadCoordinatorTrans *&trans);
|
ObTableLoadCoordinatorTrans *&trans);
|
||||||
@ -121,7 +119,6 @@ public:
|
|||||||
common::ObArray<int64_t> idx_array_;
|
common::ObArray<int64_t> idx_array_;
|
||||||
ObTableLoadExecCtx *exec_ctx_;
|
ObTableLoadExecCtx *exec_ctx_;
|
||||||
table::ObTableLoadResultInfo result_info_;
|
table::ObTableLoadResultInfo result_info_;
|
||||||
common::ObString credential_;
|
|
||||||
share::schema::ObSequenceSchema sequence_schema_;
|
share::schema::ObSequenceSchema sequence_schema_;
|
||||||
struct SessionContext
|
struct SessionContext
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,156 +0,0 @@
|
|||||||
// Copyright (c) 2022-present Oceanbase Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// xiaotao.ht <>
|
|
||||||
|
|
||||||
#define USING_LOG_PREFIX SERVER
|
|
||||||
|
|
||||||
#include "observer/table_load/ob_table_load_csv_parser.h"
|
|
||||||
#include "observer/table_load/ob_table_load_table_ctx.h"
|
|
||||||
#include "observer/table_load/ob_table_load_utils.h"
|
|
||||||
#include "sql/engine/cmd/ob_load_data_parser.h"
|
|
||||||
#include "sql/resolver/cmd/ob_load_data_stmt.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
using namespace common;
|
|
||||||
using namespace sql;
|
|
||||||
using namespace table;
|
|
||||||
|
|
||||||
const char *ObTableLoadCSVParser::default_field_term_str = "|";
|
|
||||||
|
|
||||||
ObTableLoadCSVParser::ObTableLoadCSVParser()
|
|
||||||
: allocator_("TLD_CSVParser"),
|
|
||||||
column_count_(0),
|
|
||||||
batch_row_count_(0),
|
|
||||||
str_(nullptr),
|
|
||||||
end_(nullptr),
|
|
||||||
escape_buf_(nullptr),
|
|
||||||
is_inited_(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ObTableLoadCSVParser::~ObTableLoadCSVParser()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadCSVParser::init(ObTableLoadTableCtx *table_ctx, const ObString &data_buffer)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (IS_INIT) {
|
|
||||||
ret = OB_INIT_TWICE;
|
|
||||||
LOG_WARN("ObTableLoadCSVParser init twice", KR(ret), KP(this));
|
|
||||||
} else if (OB_UNLIKELY(nullptr == table_ctx || data_buffer.empty())) {
|
|
||||||
ret = OB_INVALID_ARGUMENT;
|
|
||||||
LOG_WARN("invalid args", KR(ret), KP(table_ctx), K(data_buffer.length()),
|
|
||||||
K(table_ctx->param_.data_type_));
|
|
||||||
} else {
|
|
||||||
allocator_.set_tenant_id(MTL_ID());
|
|
||||||
column_count_ = table_ctx->param_.column_count_;
|
|
||||||
batch_row_count_ = table_ctx->param_.batch_size_;
|
|
||||||
const int64_t total_obj_count = batch_row_count_ * column_count_;
|
|
||||||
ObDataInFileStruct file_struct;
|
|
||||||
file_struct.field_term_str_ = default_field_term_str;
|
|
||||||
if (OB_FAIL(csv_parser_.init(file_struct, column_count_, table_ctx->schema_.collation_type_))) {
|
|
||||||
LOG_WARN("fail to init csv general parser", KR(ret));
|
|
||||||
} else if (OB_FAIL(store_column_objs_.create(total_obj_count, allocator_))) {
|
|
||||||
LOG_WARN("fail to create objs", KR(ret));
|
|
||||||
} else if (OB_ISNULL(escape_buf_ = static_cast<char *>(
|
|
||||||
allocator_.alloc(ObLoadFileBuffer::MAX_BUFFER_SIZE)))) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
LOG_WARN("fail to allocate escape buf memory", KR(ret));
|
|
||||||
} else {
|
|
||||||
str_ = data_buffer.ptr();
|
|
||||||
end_ = data_buffer.ptr() + data_buffer.length();
|
|
||||||
is_inited_ = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadCSVParser::get_next_row(ObNewRow &row)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_ISNULL(row.cells_) || OB_UNLIKELY(row.count_ != column_count_)) {
|
|
||||||
ret = OB_INVALID_ARGUMENT;
|
|
||||||
LOG_WARN("invalid args", KR(ret), K(row));
|
|
||||||
} else if (str_ == end_) {
|
|
||||||
ret = OB_ITER_END;
|
|
||||||
} else {
|
|
||||||
ObSEArray<ObCSVGeneralParser::LineErrRec, 1> err_records;
|
|
||||||
int64_t nrows = 1;
|
|
||||||
auto handle_one_line = [](ObIArray<ObCSVGeneralParser::FieldValue> &fields_per_line) -> int {
|
|
||||||
UNUSED(fields_per_line);
|
|
||||||
return OB_SUCCESS;
|
|
||||||
};
|
|
||||||
ret = csv_parser_.scan<decltype(handle_one_line), true>(
|
|
||||||
str_, end_, nrows, escape_buf_, escape_buf_ + ObLoadFileBuffer::MAX_BUFFER_SIZE,
|
|
||||||
handle_one_line, err_records, true);
|
|
||||||
if (OB_FAIL(ret)) {
|
|
||||||
LOG_WARN("fail to csv parser scan", KR(ret));
|
|
||||||
} else if (OB_UNLIKELY(!err_records.empty())) {
|
|
||||||
ret = OB_ERR_WRONG_VALUE;
|
|
||||||
LOG_WARN("parser error, have err records", KR(ret));
|
|
||||||
} else if (0 == nrows) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("parser error 0 == nrows", KR(ret));
|
|
||||||
} else {
|
|
||||||
const ObIArray<ObCSVGeneralParser::FieldValue> &field_values_in_file =
|
|
||||||
csv_parser_.get_fields_per_line();
|
|
||||||
for (int64_t i = 0; i < row.count_; ++i) {
|
|
||||||
const ObCSVGeneralParser::FieldValue &str_v = field_values_in_file.at(i);
|
|
||||||
ObObj &obj = row.cells_[i];
|
|
||||||
if (str_v.is_null_) {
|
|
||||||
obj.set_null();
|
|
||||||
} else {
|
|
||||||
obj.set_string(ObVarcharType, ObString(str_v.len_, str_v.ptr_));
|
|
||||||
obj.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int64_t i = 0; i < err_records.count(); ++i) {
|
|
||||||
LOG_WARN("csv parser error records", K(i), K(err_records.at(i).err_code));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadCSVParser::get_batch_objs(ObTableLoadArray<ObObj> &store_column_objs)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (IS_NOT_INIT) {
|
|
||||||
ret = OB_NOT_INIT;
|
|
||||||
LOG_WARN("ObTableLoadCSVParser not init", KR(ret), KP(this));
|
|
||||||
} else {
|
|
||||||
uint64_t processed_line_count = 0;
|
|
||||||
ObNewRow row;
|
|
||||||
row.cells_ = store_column_objs_.ptr();
|
|
||||||
row.count_ = column_count_;
|
|
||||||
while (OB_SUCC(ret) && processed_line_count < batch_row_count_) {
|
|
||||||
if (OB_FAIL(get_next_row(row))) {
|
|
||||||
if (OB_UNLIKELY(OB_ITER_END != ret)) {
|
|
||||||
LOG_WARN("fail to get row objs", KR(ret));
|
|
||||||
} else {
|
|
||||||
ret = OB_SUCCESS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
++processed_line_count;
|
|
||||||
row.cells_ += column_count_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (processed_line_count == 0) {
|
|
||||||
ret = OB_ITER_END;
|
|
||||||
} else if (OB_FAIL(store_column_objs.ref(store_column_objs_.ptr(),
|
|
||||||
processed_line_count * column_count_))) {
|
|
||||||
LOG_WARN("fail to ref", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
// Copyright (c) 2022-present Oceanbase Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// xiaotao.ht <>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "lib/string/ob_string.h"
|
|
||||||
#include "observer/table_load/ob_table_load_table_ctx.h"
|
|
||||||
#include "sql/engine/cmd/ob_load_data_impl.h"
|
|
||||||
#include "sql/engine/cmd/ob_load_data_parser.h"
|
|
||||||
#include "sql/resolver/cmd/ob_load_data_stmt.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
|
|
||||||
struct ObTableLoadCSVParser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const char *default_field_term_str;
|
|
||||||
ObTableLoadCSVParser();
|
|
||||||
~ObTableLoadCSVParser();
|
|
||||||
int init(ObTableLoadTableCtx *table_ctx, const ObString &data_buffer);
|
|
||||||
int get_batch_objs(table::ObTableLoadArray<ObObj> &store_column_objs);
|
|
||||||
private:
|
|
||||||
int get_next_row(ObNewRow &row);
|
|
||||||
private:
|
|
||||||
sql::ObCSVGeneralParser csv_parser_;
|
|
||||||
common::ObArenaAllocator allocator_;
|
|
||||||
int64_t column_count_;
|
|
||||||
int64_t batch_row_count_;
|
|
||||||
const char *str_;
|
|
||||||
const char *end_;
|
|
||||||
table::ObTableLoadArray<ObObj> store_column_objs_;
|
|
||||||
char *escape_buf_;
|
|
||||||
bool is_inited_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -63,6 +63,9 @@ int ObTableLoadClientExecCtx::check_status()
|
|||||||
LOG_WARN("observer is stopped", KR(ret), K(GCTX.status_));
|
LOG_WARN("observer is stopped", KR(ret), K(GCTX.status_));
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
LOG_WARN("fail to check tenant", KR(ret));
|
||||||
|
} else if (OB_UNLIKELY(timeout_ts_ < ObTimeUtil::current_time())) {
|
||||||
|
ret = OB_TIMEOUT;
|
||||||
|
LOG_WARN("table load is timeout", KR(ret), K_(timeout_ts));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,17 +48,18 @@ public:
|
|||||||
class ObTableLoadClientExecCtx : public ObTableLoadExecCtx
|
class ObTableLoadClientExecCtx : public ObTableLoadExecCtx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObTableLoadClientExecCtx() : allocator_(nullptr), session_info_(nullptr) {}
|
ObTableLoadClientExecCtx() : allocator_(nullptr), session_info_(nullptr), timeout_ts_(0) {}
|
||||||
virtual ~ObTableLoadClientExecCtx() = default;
|
virtual ~ObTableLoadClientExecCtx() = default;
|
||||||
common::ObIAllocator *get_allocator() override { return allocator_; }
|
common::ObIAllocator *get_allocator() override { return allocator_; }
|
||||||
sql::ObSQLSessionInfo *get_session_info() override { return session_info_; }
|
sql::ObSQLSessionInfo *get_session_info() override { return session_info_; }
|
||||||
sql::ObExecContext *get_exec_ctx() override { return nullptr; } // not support sql statistics
|
sql::ObExecContext *get_exec_ctx() override { return nullptr; } // not support sql statistics
|
||||||
int check_status() override;
|
int check_status() override;
|
||||||
bool is_valid() const override { return nullptr != allocator_ && nullptr != session_info_; }
|
bool is_valid() const override { return nullptr != allocator_ && nullptr != session_info_; }
|
||||||
TO_STRING_KV(KP_(allocator), KP_(session_info));
|
TO_STRING_KV(KP_(allocator), KP_(session_info), K_(timeout_ts));
|
||||||
public:
|
public:
|
||||||
common::ObIAllocator *allocator_;
|
common::ObIAllocator *allocator_;
|
||||||
sql::ObSQLSessionInfo *session_info_;
|
sql::ObSQLSessionInfo *session_info_;
|
||||||
|
int64_t timeout_ts_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace observer
|
} // namespace observer
|
||||||
|
|||||||
@ -1,136 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#define USING_LOG_PREFIX SERVER
|
|
||||||
|
|
||||||
#include "observer/table_load/ob_table_load_finish_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_coordinator.h"
|
|
||||||
#include "observer/table_load/ob_table_load_service.h"
|
|
||||||
#include "observer/table_load/ob_table_load_store.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
using namespace table;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadFinishP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadFinishP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadCoordinator coordinator(table_ctx);
|
|
||||||
if (OB_FAIL(coordinator.init())) {
|
|
||||||
LOG_WARN("fail to init coordinator", KR(ret));
|
|
||||||
} else if (OB_FAIL(coordinator.finish())) {
|
|
||||||
LOG_WARN("fail to coordinator finish", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadFinishP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadPreMergePeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadPreMergePeerP::deserialize()
|
|
||||||
{
|
|
||||||
arg_.committed_trans_id_array_.set_allocator(allocator_);
|
|
||||||
return ParentType::deserialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadPreMergePeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.pre_merge(arg_.committed_trans_id_array_))) {
|
|
||||||
LOG_WARN("fail to store pre merge", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadPreMergePeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadStartMergePeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadStartMergePeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.start_merge())) {
|
|
||||||
LOG_WARN("fail to store start merge", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadStartMergePeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,78 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "observer/table/ob_table_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_proxy.h"
|
|
||||||
#include "share/table/ob_table_rpc_proxy.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
|
|
||||||
class ObTableLoadFinishP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_FINISH> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadFinishP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadFinishP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadFinishP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreMergePeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_PRE_MERGE_PEER> >
|
|
||||||
{
|
|
||||||
typedef obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_PRE_MERGE_PEER> > ParentType;
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadPreMergePeerP(const ObGlobalContext &gctx) : gctx_(gctx)
|
|
||||||
{
|
|
||||||
allocator_.set_tenant_id(MTL_ID());
|
|
||||||
}
|
|
||||||
virtual ~ObTableLoadPreMergePeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int deserialize() override;
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadPreMergePeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
common::ObArenaAllocator allocator_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadStartMergePeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_START_MERGE_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadStartMergePeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadStartMergePeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadStartMergePeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,93 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#define USING_LOG_PREFIX SERVER
|
|
||||||
|
|
||||||
#include "observer/table_load/ob_table_load_get_status_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_coordinator.h"
|
|
||||||
#include "observer/table_load/ob_table_load_service.h"
|
|
||||||
#include "observer/table_load/ob_table_load_store.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
using namespace table;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadGetStatusP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadGetStatusP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadCoordinator coordinator(table_ctx);
|
|
||||||
if (OB_FAIL(coordinator.init())) {
|
|
||||||
LOG_WARN("fail to init coordinator", KR(ret));
|
|
||||||
} else if (OB_FAIL(coordinator.get_status(result_.status_, result_.error_code_))) {
|
|
||||||
LOG_WARN("fail to coordinator get status", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadGetStatusP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadGetStatusPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadGetStatusPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.get_status(result_.status_, result_.error_code_))) {
|
|
||||||
LOG_WARN("fail to store get status", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadGetStatusPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "observer/table/ob_table_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_proxy.h"
|
|
||||||
#include "share/table/ob_table_rpc_proxy.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
|
|
||||||
class ObTableLoadGetStatusP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_GET_STATUS> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadGetStatusP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadGetStatusP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadGetStatusP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadGetStatusPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_GET_STATUS_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadGetStatusPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadGetStatusPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadGetStatusPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -128,8 +128,7 @@ int ObTableLoadInstance::create_table_ctx(ObTableLoadParam ¶m,
|
|||||||
LOG_WARN("fail to alloc table ctx", KR(ret), K(param));
|
LOG_WARN("fail to alloc table ctx", KR(ret), K(param));
|
||||||
} else if (OB_FAIL(table_ctx->init(param, ddl_param, session_info))) {
|
} else if (OB_FAIL(table_ctx->init(param, ddl_param, session_info))) {
|
||||||
LOG_WARN("fail to init table ctx", KR(ret));
|
LOG_WARN("fail to init table ctx", KR(ret));
|
||||||
} else if (OB_FAIL(ObTableLoadCoordinator::init_ctx(
|
} else if (OB_FAIL(ObTableLoadCoordinator::init_ctx(table_ctx, idx_array, execute_ctx_))) {
|
||||||
table_ctx, idx_array, session_info->get_priv_user_id(), execute_ctx_))) {
|
|
||||||
LOG_WARN("fail to coordinator init ctx", KR(ret));
|
LOG_WARN("fail to coordinator init ctx", KR(ret));
|
||||||
} else if (OB_FAIL(ObTableLoadService::add_ctx(table_ctx))) {
|
} else if (OB_FAIL(ObTableLoadService::add_ctx(table_ctx))) {
|
||||||
LOG_WARN("fail to add ctx", KR(ret));
|
LOG_WARN("fail to add ctx", KR(ret));
|
||||||
|
|||||||
@ -1,216 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#define USING_LOG_PREFIX SERVER
|
|
||||||
|
|
||||||
#include "observer/table_load/ob_table_load_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_coordinator.h"
|
|
||||||
#include "observer/table_load/ob_table_load_csv_parser.h"
|
|
||||||
#include "observer/table_load/ob_table_load_service.h"
|
|
||||||
#include "observer/table_load/ob_table_load_store.h"
|
|
||||||
#include "observer/table_load/ob_table_load_table_ctx.h"
|
|
||||||
#include "sql/engine/cmd/ob_load_data_parser.h"
|
|
||||||
#include "sql/resolver/cmd/ob_load_data_stmt.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
using namespace table;
|
|
||||||
using namespace sql;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadP::deserialize()
|
|
||||||
{
|
|
||||||
return ParentType::deserialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadSharedAllocatorHandle allocator_handle = ObTableLoadSharedAllocatorHandle::make_handle();
|
|
||||||
ObTableLoadCoordinator coordinator(table_ctx);
|
|
||||||
if (OB_FAIL(coordinator.init())) {
|
|
||||||
LOG_WARN("fail to init coordinator", KR(ret));
|
|
||||||
} else if (!allocator_handle) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
LOG_WARN("failed to make allocator handle", KR(ret));
|
|
||||||
} else if (table_ctx->param_.data_type_ == ObTableLoadDataType::RAW_STRING) {
|
|
||||||
int64_t col_count = table_ctx->param_.column_count_;
|
|
||||||
ObTableLoadObjRowArray obj_rows;
|
|
||||||
obj_rows.set_allocator(allocator_handle);
|
|
||||||
ObTableLoadCSVParser csv_parser;
|
|
||||||
ObTableLoadArray<ObObj> store_column_objs;
|
|
||||||
if (OB_FAIL(csv_parser.init(table_ctx, arg_.payload_))) {
|
|
||||||
LOG_WARN("fail to init csv parser", KR(ret));
|
|
||||||
}
|
|
||||||
while (OB_SUCC(ret)) {
|
|
||||||
if (OB_FAIL(csv_parser.get_batch_objs(store_column_objs))) {
|
|
||||||
if (OB_UNLIKELY(OB_ITER_END != ret)) {
|
|
||||||
LOG_WARN("fail to get batch objs", KR(ret));
|
|
||||||
} else {
|
|
||||||
ret = OB_SUCCESS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ObObj *src_objs = store_column_objs.ptr();
|
|
||||||
int64_t row_count = store_column_objs.count() / col_count;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && (i < row_count); ++i) {
|
|
||||||
ObTableLoadObjRow obj_row;
|
|
||||||
if (OB_FAIL(obj_row.deep_copy_and_assign(src_objs, col_count, allocator_handle))) {
|
|
||||||
LOG_WARN("failed to deep copy and assign src_objs to obj_row", KR(ret));
|
|
||||||
} else if (OB_FAIL(obj_rows.push_back(obj_row))) {
|
|
||||||
LOG_WARN("failed to add row to obj_rows", KR(ret), K(obj_row));
|
|
||||||
} else {
|
|
||||||
src_objs += col_count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (OB_FAIL(coordinator.write(arg_.trans_id_, arg_.session_id_, arg_.sequence_no_,
|
|
||||||
obj_rows))) {
|
|
||||||
LOG_WARN("fail to coordinator write objs", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int64_t pos = 0;
|
|
||||||
int64_t data_len = arg_.payload_.length();
|
|
||||||
char *buf = static_cast<char *>(allocator_handle->alloc(data_len));
|
|
||||||
if (OB_ISNULL(buf)) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
LOG_WARN("failed to allocate memory", KR(ret));
|
|
||||||
} else {
|
|
||||||
MEMCPY(buf, arg_.payload_.ptr(), data_len);
|
|
||||||
if (table_ctx->param_.data_type_ == ObTableLoadDataType::OBJ_ARRAY) {
|
|
||||||
ObTableLoadObjRowArray obj_rows;
|
|
||||||
obj_rows.set_allocator(allocator_handle);
|
|
||||||
if (OB_FAIL(obj_rows.deserialize(buf, data_len, pos))) {
|
|
||||||
LOG_WARN("failed to deserialize obj rows", KR(ret));
|
|
||||||
} else if (OB_FAIL(
|
|
||||||
coordinator.write(arg_.trans_id_, arg_.session_id_, arg_.sequence_no_, obj_rows))) {
|
|
||||||
LOG_WARN("fail to coordinator write", KR(ret));
|
|
||||||
}
|
|
||||||
} else if (table_ctx->param_.data_type_ == ObTableLoadDataType::STR_ARRAY) {
|
|
||||||
ObTableLoadObjRowArray obj_rows;
|
|
||||||
obj_rows.set_allocator(allocator_handle);
|
|
||||||
ObTableLoadStrRowArray str_rows;
|
|
||||||
str_rows.set_allocator(allocator_handle);
|
|
||||||
|
|
||||||
if (OB_FAIL(str_rows.deserialize(buf, data_len, pos))) {
|
|
||||||
LOG_WARN("failed to deserialize str rows", KR(ret));
|
|
||||||
} else {
|
|
||||||
int64_t col_count = table_ctx->param_.column_count_;
|
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && (i < str_rows.count()); ++i) {
|
|
||||||
ObTableLoadObjRow obj_row;
|
|
||||||
if (OB_FAIL(obj_row.init(col_count, allocator_handle))) {
|
|
||||||
LOG_WARN("failed to init obj_row", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStrRow &str_row = str_rows.at(i);
|
|
||||||
for (int64_t j = 0; OB_SUCC(ret) && (j < col_count); ++j) {
|
|
||||||
obj_row.cells_[j].set_string(ObVarcharType, str_row.cells_[j]);
|
|
||||||
obj_row.cells_[j].set_collation_type(
|
|
||||||
ObCharset::get_default_collation(ObCharset::get_default_charset()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (OB_FAIL(obj_rows.push_back(obj_row))) {
|
|
||||||
LOG_WARN("failed to push back obj_row to obj_rows", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // end for()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (OB_FAIL(coordinator.write(arg_.trans_id_, arg_.session_id_, arg_.sequence_no_,
|
|
||||||
obj_rows))) {
|
|
||||||
LOG_WARN("fail to coordinator write objs", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // end if
|
|
||||||
} // end if
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadPeerP::deserialize()
|
|
||||||
{
|
|
||||||
return ParentType::deserialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
ObTableLoadSharedAllocatorHandle allocator_handle = ObTableLoadSharedAllocatorHandle::make_handle();
|
|
||||||
int64_t data_len = arg_.payload_.length();
|
|
||||||
char *buf = nullptr;
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else if (!allocator_handle) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
LOG_WARN("failed to make allocator handle", KR(ret));
|
|
||||||
} else if (OB_ISNULL(buf = static_cast<char *>(allocator_handle->alloc(data_len)))) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
LOG_WARN("failed to allocate memory", KR(ret));
|
|
||||||
} else {
|
|
||||||
int64_t pos = 0;
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
ObTableLoadTabletObjRowArray row_array;
|
|
||||||
row_array.set_allocator(allocator_handle);
|
|
||||||
MEMCPY(buf, arg_.payload_.ptr(), data_len);
|
|
||||||
if (OB_FAIL(row_array.deserialize(buf, data_len, pos))) {
|
|
||||||
LOG_WARN("failed to deserialize obj rows", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.write(arg_.trans_id_, arg_.session_id_, arg_.sequence_no_, row_array))) {
|
|
||||||
LOG_WARN("fail to store write", KR(ret), K_(arg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,66 +0,0 @@
|
|||||||
// Copyright (c) 2018-present Alibaba Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// Junquan Chen <>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "observer/table/ob_table_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_proxy.h"
|
|
||||||
#include "share/table/ob_table_rpc_proxy.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
|
|
||||||
class ObTableLoadP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD> >
|
|
||||||
{
|
|
||||||
typedef obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD> > ParentType;
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadP(const ObGlobalContext &gctx) : gctx_(gctx), allocator_("TLD_LoadP")
|
|
||||||
{
|
|
||||||
allocator_.set_tenant_id(MTL_ID());
|
|
||||||
}
|
|
||||||
virtual ~ObTableLoadP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int deserialize() override;
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
common::ObArenaAllocator allocator_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_PEER> >
|
|
||||||
{
|
|
||||||
typedef obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_PEER> > ParentType;
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadPeerP(const ObGlobalContext &gctx) : gctx_(gctx), allocator_("TLD_PLoadP")
|
|
||||||
{
|
|
||||||
allocator_.set_tenant_id(MTL_ID());
|
|
||||||
}
|
|
||||||
virtual ~ObTableLoadPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int deserialize() override;
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
common::ObArenaAllocator allocator_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
132
src/observer/table_load/ob_table_load_rpc_executor.h
Normal file
132
src/observer/table_load/ob_table_load_rpc_executor.h
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "lib/allocator/page_arena.h"
|
||||||
|
#include "lib/string/ob_string.h"
|
||||||
|
#include "rpc/obrpc/ob_rpc_proxy.h"
|
||||||
|
#include "share/rc/ob_tenant_base.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
// template <typename pcode, typename IGNORE = void>
|
||||||
|
// struct ObTableLoadRpc
|
||||||
|
// {
|
||||||
|
// };
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_LOAD_RPC_STRUCT(RpcType, pcode, Processor, Request, Result, Arg, Res) \
|
||||||
|
template <typename IGNORE> \
|
||||||
|
struct RpcType<pcode, IGNORE> \
|
||||||
|
{ \
|
||||||
|
static constexpr auto PCODE = pcode; \
|
||||||
|
typedef Processor ProcessorType; \
|
||||||
|
typedef Request RequestType; \
|
||||||
|
typedef Result ResultType; \
|
||||||
|
typedef Arg ArgType; \
|
||||||
|
typedef Res ResType; \
|
||||||
|
};
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_LOAD_RPC_S1(RpcType, pcode, Processor, Request, Result, Arg) \
|
||||||
|
OB_DEFINE_TABLE_LOAD_RPC_STRUCT(RpcType, pcode, Processor, Request, Result, Arg, \
|
||||||
|
obrpc::ObRpcProxy::NoneT)
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_LOAD_RPC_S2(RpcType, pcode, Processor, Request, Result, Arg, Res) \
|
||||||
|
OB_DEFINE_TABLE_LOAD_RPC_STRUCT(RpcType, pcode, Processor, Request, Result, Arg, Res)
|
||||||
|
|
||||||
|
#define OB_DEFINE_TABLE_LOAD_RPC(RpcType, pcode, Processor, Request, Result, ...) \
|
||||||
|
CONCAT(OB_DEFINE_TABLE_LOAD_RPC_S, ARGS_NUM(__VA_ARGS__)) \
|
||||||
|
(RpcType, pcode, Processor, Request, Result, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS_WITHOUT_ARG(RpcType, pcode, request, result) \
|
||||||
|
({ \
|
||||||
|
typename RpcType<pcode>::ProcessorType processor(request, result); \
|
||||||
|
if (OB_FAIL(processor.execute())) { \
|
||||||
|
SERVER_LOG(WARN, "fail to execute", K(ret)); \
|
||||||
|
} \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS_WITH_ARG(RpcType, pcode, request, result, ...) \
|
||||||
|
({ \
|
||||||
|
typename RpcType<pcode>::ProcessorType processor(__VA_ARGS__, request, result); \
|
||||||
|
if (OB_FAIL(processor.execute())) { \
|
||||||
|
SERVER_LOG(WARN, "fail to execute", K(ret)); \
|
||||||
|
} \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS_ARG0(RpcType, pcode, request, result) \
|
||||||
|
OB_TABLE_LOAD_RPC_PROCESS_WITHOUT_ARG(RpcType, pcode, request, result)
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS_ARG1(RpcType, pcode, request, result, ...) \
|
||||||
|
OB_TABLE_LOAD_RPC_PROCESS_WITH_ARG(RpcType, pcode, request, result, __VA_ARGS__)
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS_ARG2(RpcType, pcode, request, result, ...) \
|
||||||
|
OB_TABLE_LOAD_RPC_PROCESS_WITH_ARG(RpcType, pcode, request, result, __VA_ARGS__)
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS_ARG3(RpcType, pcode, request, result, ...) \
|
||||||
|
OB_TABLE_LOAD_RPC_PROCESS_WITH_ARG(RpcType, pcode, request, result, __VA_ARGS__)
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS_ARG4(RpcType, pcode, request, result, ...) \
|
||||||
|
OB_TABLE_LOAD_RPC_PROCESS_WITH_ARG(RpcType, pcode, request, result, __VA_ARGS__)
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS_ARG5(RpcType, pcode, request, result, ...) \
|
||||||
|
OB_TABLE_LOAD_RPC_PROCESS_WITH_ARG(RpcType, pcode, request, result, __VA_ARGS__)
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS_ARG6(RpcType, pcode, request, result, ...) \
|
||||||
|
OB_TABLE_LOAD_RPC_PROCESS_WITH_ARG(RpcType, pcode, request, result, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define OB_TABLE_LOAD_RPC_PROCESS(RpcType, pcode, request, result, ...) \
|
||||||
|
CONCAT(OB_TABLE_LOAD_RPC_PROCESS_ARG, ARGS_NUM(__VA_ARGS__)) \
|
||||||
|
(RpcType, pcode, request, result, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
template <class Rpc>
|
||||||
|
class ObTableLoadRpcExecutor
|
||||||
|
{
|
||||||
|
typedef typename Rpc::RequestType RequestType;
|
||||||
|
typedef typename Rpc::ResultType ResultType;
|
||||||
|
typedef typename Rpc::ArgType ArgType;
|
||||||
|
typedef typename Rpc::ResType ResType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ObTableLoadRpcExecutor(const RequestType &request, ResultType &result)
|
||||||
|
: request_(request), result_(result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObTableLoadRpcExecutor() = default;
|
||||||
|
int execute()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(deserialize())) {
|
||||||
|
SERVER_LOG(WARN, "fail to do deserialize", K(ret));
|
||||||
|
} else if (OB_FAIL(check_args())) {
|
||||||
|
SERVER_LOG(WARN, "fail to check args", K(ret));
|
||||||
|
} else if (OB_FAIL(process())) {
|
||||||
|
SERVER_LOG(WARN, "fail to process", K(ret));
|
||||||
|
} else if (OB_FAIL(serialize())) {
|
||||||
|
SERVER_LOG(WARN, "fail to do serialize", K(ret));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// deserialize arg from request
|
||||||
|
virtual int deserialize() = 0;
|
||||||
|
virtual int check_args() = 0;
|
||||||
|
virtual int process() = 0;
|
||||||
|
// serialize res to result
|
||||||
|
virtual int serialize() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const RequestType &request_;
|
||||||
|
ResultType &result_;
|
||||||
|
ArgType arg_;
|
||||||
|
ResType res_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
33
src/observer/table_load/ob_table_load_rpc_processor.cpp
Normal file
33
src/observer/table_load/ob_table_load_rpc_processor.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USING_LOG_PREFIX SERVER
|
||||||
|
|
||||||
|
#include "ob_table_load_rpc_processor.h"
|
||||||
|
#include "observer/table_load/ob_table_load_service.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
|
||||||
|
int ObDirectLoadControlP::process()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_FAIL(ObTableLoadService::direct_load_control(arg_, result_, allocator_))) {
|
||||||
|
LOG_WARN("fail to direct load control", KR(ret), K(arg_));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
40
src/observer/table_load/ob_table_load_rpc_processor.h
Normal file
40
src/observer/table_load/ob_table_load_rpc_processor.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 OceanBase
|
||||||
|
* OceanBase CE is licensed under Mulan PubL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||||
|
* You may obtain a copy of Mulan PubL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the Mulan PubL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "lib/allocator/page_arena.h"
|
||||||
|
#include "rpc/obrpc/ob_rpc_processor.h"
|
||||||
|
#include "share/ob_srv_rpc_proxy.h"
|
||||||
|
|
||||||
|
namespace oceanbase
|
||||||
|
{
|
||||||
|
namespace observer
|
||||||
|
{
|
||||||
|
|
||||||
|
/// RPC_S(PR5 direct_load_control, OB_DIRECT_LOAD_CONTROL, (observer::ObDirectLoadControlRequest), observer::ObDirectLoadControlResult);
|
||||||
|
class ObDirectLoadControlP : public obrpc::ObRpcProcessor<obrpc::ObSrvRpcProxy::ObRpc<obrpc::OB_DIRECT_LOAD_CONTROL>>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObDirectLoadControlP(const ObGlobalContext &gctx) : gctx_(gctx), allocator_("TLD_RpcP")
|
||||||
|
{
|
||||||
|
allocator_.set_tenant_id(MTL_ID());
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
int process();
|
||||||
|
private:
|
||||||
|
const ObGlobalContext &gctx_ __maybe_unused;
|
||||||
|
ObArenaAllocator allocator_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace observer
|
||||||
|
} // namespace oceanbase
|
||||||
@ -48,6 +48,20 @@ int ObTableLoadSchema::get_table_schema(uint64_t tenant_id, uint64_t database_id
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ObTableLoadSchema::get_table_id(uint64_t tenant_id, uint64_t database_id,
|
||||||
|
const ObString &table_name, uint64_t &table_id)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObSchemaGetterGuard schema_guard;
|
||||||
|
const ObTableSchema *table_schema = nullptr;
|
||||||
|
if (OB_FAIL(get_table_schema(tenant_id, database_id, table_name, schema_guard, table_schema))) {
|
||||||
|
LOG_WARN("fail to get table schema", KR(ret), K(tenant_id), K(database_id), K(table_name));
|
||||||
|
} else {
|
||||||
|
table_id = table_schema->get_table_id();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ObTableLoadSchema::get_table_schema(uint64_t tenant_id, uint64_t table_id,
|
int ObTableLoadSchema::get_table_schema(uint64_t tenant_id, uint64_t table_id,
|
||||||
ObSchemaGetterGuard &schema_guard,
|
ObSchemaGetterGuard &schema_guard,
|
||||||
const ObTableSchema *&table_schema)
|
const ObTableSchema *&table_schema)
|
||||||
@ -66,42 +80,62 @@ int ObTableLoadSchema::get_table_schema(uint64_t tenant_id, uint64_t table_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ObTableLoadSchema::get_column_names(const ObTableSchema *table_schema, ObIAllocator &allocator,
|
int ObTableLoadSchema::get_column_names(const ObTableSchema *table_schema, ObIAllocator &allocator,
|
||||||
ObTableLoadArray<ObString> &column_names)
|
ObIArray<ObString> &column_names)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (OB_ISNULL(table_schema)) {
|
if (OB_ISNULL(table_schema)) {
|
||||||
ret = OB_NOT_INIT;
|
ret = OB_INVALID_ARGUMENT;
|
||||||
LOG_WARN("ObTableLoadSchema not init", KR(ret));
|
LOG_WARN("invalid args", KR(ret), KP(table_schema));
|
||||||
} else {
|
} else {
|
||||||
ObSEArray<ObString, 64> column_name_array;
|
|
||||||
ObColumnIterByPrevNextID iter(*table_schema);
|
ObColumnIterByPrevNextID iter(*table_schema);
|
||||||
const ObColumnSchemaV2 *column_schema = NULL;
|
const ObColumnSchemaV2 *column_schema = NULL;
|
||||||
while (OB_SUCC(ret) && OB_SUCC(iter.next(column_schema))) {
|
while (OB_SUCC(ret)) {
|
||||||
if (OB_ISNULL(column_schema)) {
|
if (OB_FAIL(iter.next(column_schema))) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
if (OB_UNLIKELY(OB_ITER_END != ret)) {
|
||||||
LOG_WARN("The column is null", K(ret));
|
LOG_WARN("fail to iterate all table columns", KR(ret));
|
||||||
} else if (!column_schema->is_hidden()
|
|
||||||
&& !column_schema->is_invisible_column()) {
|
|
||||||
if (column_schema->is_virtual_generated_column()) {
|
|
||||||
} else if (OB_FAIL(column_name_array.push_back(column_schema->get_column_name_str()))) {
|
|
||||||
LOG_WARN("failed to push back item", K(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret != OB_ITER_END) {
|
|
||||||
LOG_WARN("Failed to iterate all table columns. iter quit. ", K(ret));
|
|
||||||
} else {
|
} else {
|
||||||
ret = OB_SUCCESS;
|
ret = OB_SUCCESS;
|
||||||
if (OB_UNLIKELY(column_name_array.empty())) {
|
break;
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("unexpected empty column desc", KR(ret));
|
|
||||||
} else if (OB_FAIL(column_names.create(column_name_array.count(), allocator))) {
|
|
||||||
LOG_WARN("fail to create", KR(ret));
|
|
||||||
}
|
}
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < column_name_array.count(); ++i) {
|
} else if (OB_ISNULL(column_schema)) {
|
||||||
const ObString &column_name = column_name_array.at(i);
|
ret = OB_ERR_UNEXPECTED;
|
||||||
if (OB_FAIL(ob_write_string(allocator, column_name, column_names[i]))) {
|
LOG_WARN("The column is null", KR(ret));
|
||||||
LOG_WARN("fail to write string", KR(ret), K(i), K(column_name));
|
} else if (!column_schema->is_hidden() && !column_schema->is_invisible_column()) {
|
||||||
|
ObString column_name;
|
||||||
|
if (OB_FAIL(
|
||||||
|
ob_write_string(allocator, column_schema->get_column_name_str(), column_name))) {
|
||||||
|
LOG_WARN("fail to write string", KR(ret), K(column_name));
|
||||||
|
} else if (OB_FAIL(column_names.push_back(column_name))) {
|
||||||
|
LOG_WARN("fail to push back column name", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ObTableLoadSchema::get_column_idxs(const ObTableSchema *table_schema,
|
||||||
|
ObIArray<int64_t> &column_idxs)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (OB_ISNULL(table_schema)) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
LOG_WARN("invalid args", KR(ret), KP(table_schema));
|
||||||
|
} else {
|
||||||
|
ObSEArray<ObColDesc, 64> column_descs;
|
||||||
|
if (OB_FAIL(table_schema->get_column_ids(column_descs, false))) {
|
||||||
|
LOG_WARN("fail to get column ids", KR(ret));
|
||||||
|
}
|
||||||
|
for (int64_t i = 0; OB_SUCC(ret) && (i < column_descs.count()); ++i) {
|
||||||
|
ObColDesc &col_desc = column_descs.at(i);
|
||||||
|
const ObColumnSchemaV2 *column_schema = table_schema->get_column_schema(col_desc.col_id_);
|
||||||
|
if (OB_ISNULL(column_schema)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
LOG_WARN("The column is null", KR(ret));
|
||||||
|
} else if (!column_schema->is_hidden() && !column_schema->is_invisible_column()) {
|
||||||
|
const int64_t idx = col_desc.col_id_ - OB_APP_MIN_COLUMN_ID;
|
||||||
|
if (OB_FAIL(column_idxs.push_back(idx))) {
|
||||||
|
LOG_WARN("fail to push back idx", KR(ret), K(idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,12 +25,16 @@ public:
|
|||||||
const common::ObString &table_name,
|
const common::ObString &table_name,
|
||||||
share::schema::ObSchemaGetterGuard &schema_guard,
|
share::schema::ObSchemaGetterGuard &schema_guard,
|
||||||
const share::schema::ObTableSchema *&table_schema);
|
const share::schema::ObTableSchema *&table_schema);
|
||||||
|
static int get_table_id(uint64_t tenant_id, uint64_t database_id,
|
||||||
|
const common::ObString &table_name, uint64_t &table_id);
|
||||||
static int get_table_schema(uint64_t tenant_id, uint64_t table_id,
|
static int get_table_schema(uint64_t tenant_id, uint64_t table_id,
|
||||||
share::schema::ObSchemaGetterGuard &schema_guard,
|
share::schema::ObSchemaGetterGuard &schema_guard,
|
||||||
const share::schema::ObTableSchema *&table_schema);
|
const share::schema::ObTableSchema *&table_schema);
|
||||||
static int get_column_names(const share::schema::ObTableSchema *table_schema,
|
static int get_column_names(const share::schema::ObTableSchema *table_schema,
|
||||||
common::ObIAllocator &allocator,
|
common::ObIAllocator &allocator,
|
||||||
table::ObTableLoadArray<common::ObString> &column_names);
|
common::ObIArray<common::ObString> &column_names);
|
||||||
|
static int get_column_idxs(const share::schema::ObTableSchema *table_schema,
|
||||||
|
common::ObIArray<int64_t> &column_idxs);
|
||||||
static int check_has_udt_column(const share::schema::ObTableSchema *table_schema, bool &bret);
|
static int check_has_udt_column(const share::schema::ObTableSchema *table_schema, bool &bret);
|
||||||
public:
|
public:
|
||||||
ObTableLoadSchema();
|
ObTableLoadSchema();
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "observer/table_load/ob_table_load_service.h"
|
#include "observer/table_load/ob_table_load_service.h"
|
||||||
#include "observer/omt/ob_tenant.h"
|
#include "observer/omt/ob_tenant.h"
|
||||||
|
#include "observer/table_load/ob_table_load_client_task.h"
|
||||||
#include "observer/table_load/ob_table_load_coordinator_ctx.h"
|
#include "observer/table_load/ob_table_load_coordinator_ctx.h"
|
||||||
#include "observer/table_load/ob_table_load_schema.h"
|
#include "observer/table_load/ob_table_load_schema.h"
|
||||||
#include "observer/table_load/ob_table_load_store_ctx.h"
|
#include "observer/table_load/ob_table_load_store_ctx.h"
|
||||||
@ -55,6 +56,8 @@ void ObTableLoadService::ObCheckTenantTask::runTimerTask()
|
|||||||
} else if (OB_UNLIKELY(ObUnitInfoGetter::ObUnitStatus::UNIT_NORMAL !=
|
} else if (OB_UNLIKELY(ObUnitInfoGetter::ObUnitStatus::UNIT_NORMAL !=
|
||||||
tenant->get_unit_status())) {
|
tenant->get_unit_status())) {
|
||||||
LOG_DEBUG("tenant unit status not normal, clear", K(tenant_id_), KPC(tenant));
|
LOG_DEBUG("tenant unit status not normal, clear", K(tenant_id_), KPC(tenant));
|
||||||
|
// abort all client task
|
||||||
|
service_.abort_all_client_task();
|
||||||
// fail all current tasks
|
// fail all current tasks
|
||||||
service_.fail_all_ctx(OB_ERR_UNEXPECTED_UNIT_STATUS);
|
service_.fail_all_ctx(OB_ERR_UNEXPECTED_UNIT_STATUS);
|
||||||
}
|
}
|
||||||
@ -164,12 +167,44 @@ void ObTableLoadService::ObReleaseTask::runTimerTask()
|
|||||||
ObTableLoadTableCtx *table_ctx = releasable_table_ctx_array.at(i);
|
ObTableLoadTableCtx *table_ctx = releasable_table_ctx_array.at(i);
|
||||||
const uint64_t table_id = table_ctx->param_.table_id_;
|
const uint64_t table_id = table_ctx->param_.table_id_;
|
||||||
const uint64_t hidden_table_id = table_ctx->ddl_param_.dest_table_id_;
|
const uint64_t hidden_table_id = table_ctx->ddl_param_.dest_table_id_;
|
||||||
LOG_INFO("free table ctx", K(tenant_id_), K(table_id), K(hidden_table_id), KP(table_ctx));
|
const int64_t task_id = table_ctx->ddl_param_.task_id_;
|
||||||
|
LOG_INFO("free table ctx", K(tenant_id_), K(table_id), K(hidden_table_id), K(task_id),
|
||||||
|
KP(table_ctx));
|
||||||
ObTableLoadService::free_ctx(table_ctx);
|
ObTableLoadService::free_ctx(table_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ObClientTaskPurgeTask
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ObTableLoadService::ObClientTaskPurgeTask::init(uint64_t tenant_id)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_INIT) {
|
||||||
|
ret = OB_INIT_TWICE;
|
||||||
|
LOG_WARN("ObTableLoadService::ObClientTaskPurgeTask init twice", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
tenant_id_ = tenant_id;
|
||||||
|
is_inited_ = true;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObTableLoadService::ObClientTaskPurgeTask::runTimerTask()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
if (IS_NOT_INIT) {
|
||||||
|
ret = OB_NOT_INIT;
|
||||||
|
LOG_WARN("ObTableLoadService::ObClientTaskPurgeTask not init", KR(ret), KP(this));
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG("table load purge client task", K(tenant_id_));
|
||||||
|
service_.get_client_service().purge_client_task();
|
||||||
|
service_.get_client_service().purge_client_task_brief();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ObTableLoadService
|
* ObTableLoadService
|
||||||
*/
|
*/
|
||||||
@ -337,6 +372,7 @@ ObTableLoadService::ObTableLoadService()
|
|||||||
: check_tenant_task_(*this),
|
: check_tenant_task_(*this),
|
||||||
gc_task_(*this),
|
gc_task_(*this),
|
||||||
release_task_(*this),
|
release_task_(*this),
|
||||||
|
client_task_purge_task_(*this),
|
||||||
is_stop_(false),
|
is_stop_(false),
|
||||||
is_inited_(false)
|
is_inited_(false)
|
||||||
{
|
{
|
||||||
@ -350,12 +386,16 @@ int ObTableLoadService::init(uint64_t tenant_id)
|
|||||||
LOG_WARN("ObTableLoadService init twice", KR(ret), KP(this));
|
LOG_WARN("ObTableLoadService init twice", KR(ret), KP(this));
|
||||||
} else if (OB_FAIL(manager_.init())) {
|
} else if (OB_FAIL(manager_.init())) {
|
||||||
LOG_WARN("fail to init table ctx manager", KR(ret));
|
LOG_WARN("fail to init table ctx manager", KR(ret));
|
||||||
|
} else if (OB_FAIL(client_service_.init())) {
|
||||||
|
LOG_WARN("fail to init client service", KR(ret));
|
||||||
} else if (OB_FAIL(check_tenant_task_.init(tenant_id))) {
|
} else if (OB_FAIL(check_tenant_task_.init(tenant_id))) {
|
||||||
LOG_WARN("fail to init check tenant task", KR(ret));
|
LOG_WARN("fail to init check tenant task", KR(ret));
|
||||||
} else if (OB_FAIL(gc_task_.init(tenant_id))) {
|
} else if (OB_FAIL(gc_task_.init(tenant_id))) {
|
||||||
LOG_WARN("fail to init gc task", KR(ret));
|
LOG_WARN("fail to init gc task", KR(ret));
|
||||||
} else if (OB_FAIL(release_task_.init(tenant_id))) {
|
} else if (OB_FAIL(release_task_.init(tenant_id))) {
|
||||||
LOG_WARN("fail to init release task", KR(ret));
|
LOG_WARN("fail to init release task", KR(ret));
|
||||||
|
} else if (OB_FAIL(client_task_purge_task_.init(tenant_id))) {
|
||||||
|
LOG_WARN("fail to init client task purge task", KR(ret));
|
||||||
} else {
|
} else {
|
||||||
is_inited_ = true;
|
is_inited_ = true;
|
||||||
}
|
}
|
||||||
@ -378,6 +418,9 @@ int ObTableLoadService::start()
|
|||||||
LOG_WARN("fail to schedule gc task", KR(ret));
|
LOG_WARN("fail to schedule gc task", KR(ret));
|
||||||
} else if (OB_FAIL(timer_.schedule(release_task_, RELEASE_INTERVAL, true))) {
|
} else if (OB_FAIL(timer_.schedule(release_task_, RELEASE_INTERVAL, true))) {
|
||||||
LOG_WARN("fail to schedule release task", KR(ret));
|
LOG_WARN("fail to schedule release task", KR(ret));
|
||||||
|
} else if (OB_FAIL(
|
||||||
|
timer_.schedule(client_task_purge_task_, CLIENT_TASK_PURGE_INTERVAL, true))) {
|
||||||
|
LOG_WARN("fail to schedule client task purge task", KR(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -403,6 +446,23 @@ void ObTableLoadService::destroy()
|
|||||||
timer_.destroy();
|
timer_.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObTableLoadService::abort_all_client_task()
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObArray<ObTableLoadClientTask *> client_task_array;
|
||||||
|
if (OB_FAIL(client_service_.get_all_client_task(client_task_array))) {
|
||||||
|
LOG_WARN("fail to get all client task", KR(ret));
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < client_task_array.count(); ++i) {
|
||||||
|
ObTableLoadClientTask *client_task = client_task_array.at(i);
|
||||||
|
if (OB_FAIL(ObTableLoadClientService::abort_task(client_task))) {
|
||||||
|
LOG_WARN("fail to abort client task", KR(ret), KPC(client_task));
|
||||||
|
}
|
||||||
|
ObTableLoadClientService::revert_task(client_task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ObTableLoadService::fail_all_ctx(int error_code)
|
void ObTableLoadService::fail_all_ctx(int error_code)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
@ -432,8 +492,10 @@ void ObTableLoadService::release_all_ctx()
|
|||||||
// 1. check all ctx are removed
|
// 1. check all ctx are removed
|
||||||
while (OB_SUCC(ret)) {
|
while (OB_SUCC(ret)) {
|
||||||
if (REACH_TIME_INTERVAL(30 * 1000 * 1000)) {
|
if (REACH_TIME_INTERVAL(30 * 1000 * 1000)) {
|
||||||
LOG_INFO("[DIRECT LOAD TABLE CTX]", "count", manager_.get_table_ctx_count());
|
LOG_INFO("[DIRECT LOAD]", "client_task_count", client_service_.get_client_task_count(),
|
||||||
|
"table_ctx_count", manager_.get_table_ctx_count());
|
||||||
}
|
}
|
||||||
|
abort_all_client_task();
|
||||||
fail_all_ctx(OB_ERR_UNEXPECTED_UNIT_STATUS);
|
fail_all_ctx(OB_ERR_UNEXPECTED_UNIT_STATUS);
|
||||||
ObArray<ObTableLoadTableCtx *> table_ctx_array;
|
ObArray<ObTableLoadTableCtx *> table_ctx_array;
|
||||||
if (OB_FAIL(manager_.get_inactive_table_ctx_list(table_ctx_array))) {
|
if (OB_FAIL(manager_.get_inactive_table_ctx_list(table_ctx_array))) {
|
||||||
@ -479,7 +541,9 @@ void ObTableLoadService::release_all_ctx()
|
|||||||
ObTableLoadTableCtx *table_ctx = table_ctx_array.at(i);
|
ObTableLoadTableCtx *table_ctx = table_ctx_array.at(i);
|
||||||
const uint64_t table_id = table_ctx->param_.table_id_;
|
const uint64_t table_id = table_ctx->param_.table_id_;
|
||||||
const uint64_t hidden_table_id = table_ctx->ddl_param_.dest_table_id_;
|
const uint64_t hidden_table_id = table_ctx->ddl_param_.dest_table_id_;
|
||||||
LOG_INFO("free table ctx", K(tenant_id), K(table_id), K(hidden_table_id), KP(table_ctx));
|
const int64_t task_id = table_ctx->ddl_param_.task_id_;
|
||||||
|
LOG_INFO("free table ctx", K(tenant_id), K(table_id), K(hidden_table_id), K(task_id),
|
||||||
|
KP(table_ctx));
|
||||||
ObTableLoadService::free_ctx(table_ctx);
|
ObTableLoadService::free_ctx(table_ctx);
|
||||||
}
|
}
|
||||||
if (0 == manager_.get_dirty_list_count()) {
|
if (0 == manager_.get_dirty_list_count()) {
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "lib/task/ob_timer.h"
|
#include "lib/task/ob_timer.h"
|
||||||
|
#include "observer/table_load/control/ob_table_load_control_rpc_proxy.h"
|
||||||
|
#include "observer/table_load/ob_table_load_client_service.h"
|
||||||
#include "observer/table_load/ob_table_load_manager.h"
|
#include "observer/table_load/ob_table_load_manager.h"
|
||||||
#include "observer/table_load/ob_table_load_struct.h"
|
#include "observer/table_load/ob_table_load_struct.h"
|
||||||
|
|
||||||
@ -29,6 +31,13 @@ public:
|
|||||||
// get ctx by table_id
|
// get ctx by table_id
|
||||||
static int get_ctx(const ObTableLoadKey &key, ObTableLoadTableCtx *&table_ctx);
|
static int get_ctx(const ObTableLoadKey &key, ObTableLoadTableCtx *&table_ctx);
|
||||||
static void put_ctx(ObTableLoadTableCtx *table_ctx);
|
static void put_ctx(ObTableLoadTableCtx *table_ctx);
|
||||||
|
|
||||||
|
// for direct load control api
|
||||||
|
static int direct_load_control(const ObDirectLoadControlRequest &request,
|
||||||
|
ObDirectLoadControlResult &result, common::ObIAllocator &allocator)
|
||||||
|
{
|
||||||
|
return ObTableLoadControlRpcProxy::dispatch(request, result, allocator);
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
ObTableLoadService();
|
ObTableLoadService();
|
||||||
int init(uint64_t tenant_id);
|
int init(uint64_t tenant_id);
|
||||||
@ -37,13 +46,16 @@ public:
|
|||||||
void wait();
|
void wait();
|
||||||
void destroy();
|
void destroy();
|
||||||
ObTableLoadManager &get_manager() { return manager_; }
|
ObTableLoadManager &get_manager() { return manager_; }
|
||||||
|
ObTableLoadClientService &get_client_service() { return client_service_; }
|
||||||
private:
|
private:
|
||||||
|
void abort_all_client_task();
|
||||||
void fail_all_ctx(int error_code);
|
void fail_all_ctx(int error_code);
|
||||||
void release_all_ctx();
|
void release_all_ctx();
|
||||||
private:
|
private:
|
||||||
static const int64_t CHECK_TENANT_INTERVAL = 1LL * 1000 * 1000; // 1s
|
static const int64_t CHECK_TENANT_INTERVAL = 1LL * 1000 * 1000; // 1s
|
||||||
static const int64_t GC_INTERVAL = 30LL * 1000 * 1000; // 30s
|
static const int64_t GC_INTERVAL = 30LL * 1000 * 1000; // 30s
|
||||||
static const int64_t RELEASE_INTERVAL = 1LL * 1000 * 1000; // 1s
|
static const int64_t RELEASE_INTERVAL = 1LL * 1000 * 1000; // 1s
|
||||||
|
static const int64_t CLIENT_TASK_PURGE_INTERVAL = 1LL * 1000 * 1000; // 30s
|
||||||
class ObCheckTenantTask : public common::ObTimerTask
|
class ObCheckTenantTask : public common::ObTimerTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -83,12 +95,29 @@ private:
|
|||||||
uint64_t tenant_id_;
|
uint64_t tenant_id_;
|
||||||
bool is_inited_;
|
bool is_inited_;
|
||||||
};
|
};
|
||||||
|
class ObClientTaskPurgeTask : public common::ObTimerTask
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObClientTaskPurgeTask(ObTableLoadService &service)
|
||||||
|
: service_(service), tenant_id_(common::OB_INVALID_ID), is_inited_(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~ObClientTaskPurgeTask() = default;
|
||||||
|
int init(uint64_t tenant_id);
|
||||||
|
void runTimerTask() override;
|
||||||
|
private:
|
||||||
|
ObTableLoadService &service_;
|
||||||
|
uint64_t tenant_id_;
|
||||||
|
bool is_inited_;
|
||||||
|
};
|
||||||
private:
|
private:
|
||||||
ObTableLoadManager manager_;
|
ObTableLoadManager manager_;
|
||||||
|
ObTableLoadClientService client_service_;
|
||||||
common::ObTimer timer_;
|
common::ObTimer timer_;
|
||||||
ObCheckTenantTask check_tenant_task_;
|
ObCheckTenantTask check_tenant_task_;
|
||||||
ObGCTask gc_task_;
|
ObGCTask gc_task_;
|
||||||
ObReleaseTask release_task_;
|
ObReleaseTask release_task_;
|
||||||
|
ObClientTaskPurgeTask client_task_purge_task_;
|
||||||
volatile bool is_stop_;
|
volatile bool is_stop_;
|
||||||
bool is_inited_;
|
bool is_inited_;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -19,14 +19,6 @@ class ObObj;
|
|||||||
namespace observer
|
namespace observer
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class ObTableLoadDataType : int32_t
|
|
||||||
{
|
|
||||||
OBJ_ARRAY = 0, //obobj[]
|
|
||||||
STR_ARRAY = 1, //string[]
|
|
||||||
RAW_STRING = 2, //string
|
|
||||||
MAX_DATA_TYPE
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ObTableLoadKey
|
struct ObTableLoadKey
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -110,7 +102,6 @@ struct ObTableLoadParam
|
|||||||
need_sort_(false),
|
need_sort_(false),
|
||||||
px_mode_(false),
|
px_mode_(false),
|
||||||
online_opt_stat_gather_(false),
|
online_opt_stat_gather_(false),
|
||||||
data_type_(ObTableLoadDataType::RAW_STRING),
|
|
||||||
dup_action_(sql::ObLoadDupActionType::LOAD_INVALID_MODE)
|
dup_action_(sql::ObLoadDupActionType::LOAD_INVALID_MODE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -138,7 +129,7 @@ struct ObTableLoadParam
|
|||||||
|
|
||||||
TO_STRING_KV(K_(tenant_id), K_(table_id), K_(parallel), K_(session_count), K_(batch_size),
|
TO_STRING_KV(K_(tenant_id), K_(table_id), K_(parallel), K_(session_count), K_(batch_size),
|
||||||
K_(max_error_row_count), K_(sql_mode), K_(column_count), K_(need_sort), K_(px_mode),
|
K_(max_error_row_count), K_(sql_mode), K_(column_count), K_(need_sort), K_(px_mode),
|
||||||
K_(online_opt_stat_gather), K_(data_type), K_(dup_action));
|
K_(online_opt_stat_gather), K_(dup_action));
|
||||||
public:
|
public:
|
||||||
uint64_t tenant_id_;
|
uint64_t tenant_id_;
|
||||||
uint64_t table_id_;
|
uint64_t table_id_;
|
||||||
@ -151,7 +142,6 @@ public:
|
|||||||
bool need_sort_;
|
bool need_sort_;
|
||||||
bool px_mode_;
|
bool px_mode_;
|
||||||
bool online_opt_stat_gather_;
|
bool online_opt_stat_gather_;
|
||||||
ObTableLoadDataType data_type_;
|
|
||||||
sql::ObLoadDupActionType dup_action_;
|
sql::ObLoadDupActionType dup_action_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -24,8 +24,7 @@ using namespace table;
|
|||||||
using namespace obrpc;
|
using namespace obrpc;
|
||||||
|
|
||||||
ObTableLoadTableCtx::ObTableLoadTableCtx()
|
ObTableLoadTableCtx::ObTableLoadTableCtx()
|
||||||
: client_exec_ctx_(nullptr),
|
: coordinator_ctx_(nullptr),
|
||||||
coordinator_ctx_(nullptr),
|
|
||||||
store_ctx_(nullptr),
|
store_ctx_(nullptr),
|
||||||
job_stat_(nullptr),
|
job_stat_(nullptr),
|
||||||
session_info_(nullptr),
|
session_info_(nullptr),
|
||||||
@ -161,28 +160,7 @@ void ObTableLoadTableCtx::unregister_job_stat()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObTableLoadTableCtx::init_client_exec_ctx()
|
int ObTableLoadTableCtx::init_coordinator_ctx(const ObIArray<int64_t> &idx_array,
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (IS_NOT_INIT) {
|
|
||||||
ret = OB_NOT_INIT;
|
|
||||||
LOG_WARN("ObTableLoadTableCtx not init", KR(ret));
|
|
||||||
} else if (OB_NOT_NULL(client_exec_ctx_)) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("client table ctx already exist", KR(ret));
|
|
||||||
} else {
|
|
||||||
if (OB_ISNULL(client_exec_ctx_ = OB_NEWx(ObTableLoadClientExecCtx, &allocator_))) {
|
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
|
||||||
LOG_WARN("fail to new ObTableLoadClientExecCtx", KR(ret));
|
|
||||||
} else {
|
|
||||||
client_exec_ctx_->allocator_ = &allocator_;
|
|
||||||
client_exec_ctx_->session_info_ = session_info_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadTableCtx::init_coordinator_ctx(const ObIArray<int64_t> &idx_array, uint64_t user_id,
|
|
||||||
ObTableLoadExecCtx *exec_ctx)
|
ObTableLoadExecCtx *exec_ctx)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
@ -197,7 +175,7 @@ int ObTableLoadTableCtx::init_coordinator_ctx(const ObIArray<int64_t> &idx_array
|
|||||||
if (OB_ISNULL(coordinator_ctx = OB_NEWx(ObTableLoadCoordinatorCtx, (&allocator_), this))) {
|
if (OB_ISNULL(coordinator_ctx = OB_NEWx(ObTableLoadCoordinatorCtx, (&allocator_), this))) {
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
LOG_WARN("fail to new ObTableLoadCoordinatorCtx", KR(ret));
|
LOG_WARN("fail to new ObTableLoadCoordinatorCtx", KR(ret));
|
||||||
} else if (OB_FAIL(coordinator_ctx->init(idx_array, user_id, exec_ctx))) {
|
} else if (OB_FAIL(coordinator_ctx->init(idx_array, exec_ctx))) {
|
||||||
LOG_WARN("fail to init coordinator ctx", KR(ret));
|
LOG_WARN("fail to init coordinator ctx", KR(ret));
|
||||||
} else if (OB_FAIL(coordinator_ctx->set_status_inited())) {
|
} else if (OB_FAIL(coordinator_ctx->set_status_inited())) {
|
||||||
LOG_WARN("fail to set coordinator status inited", KR(ret));
|
LOG_WARN("fail to set coordinator status inited", KR(ret));
|
||||||
@ -263,11 +241,6 @@ void ObTableLoadTableCtx::stop()
|
|||||||
void ObTableLoadTableCtx::destroy()
|
void ObTableLoadTableCtx::destroy()
|
||||||
{
|
{
|
||||||
abort_unless(0 == get_ref_count());
|
abort_unless(0 == get_ref_count());
|
||||||
if (nullptr != client_exec_ctx_) {
|
|
||||||
client_exec_ctx_->~ObTableLoadClientExecCtx();
|
|
||||||
allocator_.free(client_exec_ctx_);
|
|
||||||
client_exec_ctx_ = nullptr;
|
|
||||||
}
|
|
||||||
if (nullptr != coordinator_ctx_) {
|
if (nullptr != coordinator_ctx_) {
|
||||||
coordinator_ctx_->~ObTableLoadCoordinatorCtx();
|
coordinator_ctx_->~ObTableLoadCoordinatorCtx();
|
||||||
allocator_.free(coordinator_ctx_);
|
allocator_.free(coordinator_ctx_);
|
||||||
|
|||||||
@ -42,8 +42,7 @@ public:
|
|||||||
TO_STRING_KV(K_(param), KP_(coordinator_ctx), KP_(store_ctx), "ref_count", get_ref_count(),
|
TO_STRING_KV(K_(param), KP_(coordinator_ctx), KP_(store_ctx), "ref_count", get_ref_count(),
|
||||||
K_(is_dirty), K_(is_inited));
|
K_(is_dirty), K_(is_inited));
|
||||||
public:
|
public:
|
||||||
int init_client_exec_ctx();
|
int init_coordinator_ctx(const common::ObIArray<int64_t> &idx_array,
|
||||||
int init_coordinator_ctx(const common::ObIArray<int64_t> &idx_array, uint64_t user_id,
|
|
||||||
ObTableLoadExecCtx *exec_ctx);
|
ObTableLoadExecCtx *exec_ctx);
|
||||||
int init_store_ctx(
|
int init_store_ctx(
|
||||||
const table::ObTableLoadArray<table::ObTableLoadLSIdAndPartitionId> &partition_id_array,
|
const table::ObTableLoadArray<table::ObTableLoadLSIdAndPartitionId> &partition_id_array,
|
||||||
@ -60,7 +59,6 @@ public:
|
|||||||
ObTableLoadParam param_;
|
ObTableLoadParam param_;
|
||||||
ObTableLoadDDLParam ddl_param_;
|
ObTableLoadDDLParam ddl_param_;
|
||||||
ObTableLoadSchema schema_;
|
ObTableLoadSchema schema_;
|
||||||
ObTableLoadClientExecCtx *client_exec_ctx_; // for java client
|
|
||||||
ObTableLoadCoordinatorCtx *coordinator_ctx_; // 只在控制节点构造
|
ObTableLoadCoordinatorCtx *coordinator_ctx_; // 只在控制节点构造
|
||||||
ObTableLoadStoreCtx *store_ctx_; // 只在数据节点构造
|
ObTableLoadStoreCtx *store_ctx_; // 只在数据节点构造
|
||||||
sql::ObLoadDataGID gid_;
|
sql::ObLoadDataGID gid_;
|
||||||
|
|||||||
@ -1,397 +0,0 @@
|
|||||||
// Copyright (c) 2022-present Oceanbase Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// suzhi.yt <>
|
|
||||||
|
|
||||||
#define USING_LOG_PREFIX SERVER
|
|
||||||
|
|
||||||
#include "observer/table_load/ob_table_load_trans_processor.h"
|
|
||||||
#include "observer/table_load/ob_table_load_coordinator.h"
|
|
||||||
#include "observer/table_load/ob_table_load_store.h"
|
|
||||||
#include "observer/table_load/ob_table_load_service.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
using namespace table;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadStartTransP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadStartTransP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadCoordinator coordinator(table_ctx);
|
|
||||||
if (OB_FAIL(coordinator.init())) {
|
|
||||||
LOG_WARN("fail to init coordinator", KR(ret));
|
|
||||||
} else if (OB_FAIL(coordinator.start_trans(arg_.segment_id_, result_.trans_id_))) {
|
|
||||||
LOG_WARN("fail to coordinator start trans", KR(ret));
|
|
||||||
} else if (OB_FAIL(coordinator.get_trans_status(result_.trans_id_, result_.trans_status_,
|
|
||||||
result_.error_code_))) {
|
|
||||||
LOG_WARN("fail to coordinator get trans status", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadStartTransP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadPreStartTransPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadPreStartTransPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.pre_start_trans(arg_.trans_id_))) {
|
|
||||||
LOG_WARN("fail to store pre start trans", KR(ret), K(arg_.trans_id_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadPreStartTransPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadConfirmStartTransPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadConfirmStartTransPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.confirm_start_trans(arg_.trans_id_))) {
|
|
||||||
LOG_WARN("fail to store confirm start trans", KR(ret), K(arg_.trans_id_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadConfirmStartTransPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadFinishTransP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadFinishTransP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadCoordinator coordinator(table_ctx);
|
|
||||||
if (OB_FAIL(coordinator.init())) {
|
|
||||||
LOG_WARN("fail to init coordinator", KR(ret));
|
|
||||||
} else if (OB_FAIL(coordinator.finish_trans(arg_.trans_id_))) {
|
|
||||||
LOG_WARN("fail to coordinator finish trans", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadFinishTransP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadPreFinishTransPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadPreFinishTransPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.pre_finish_trans(arg_.trans_id_))) {
|
|
||||||
LOG_WARN("fail to store pre finish trans", KR(ret), K(arg_.trans_id_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadPreFinishTransPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadConfirmFinishTransPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadConfirmFinishTransPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.confirm_finish_trans(arg_.trans_id_))) {
|
|
||||||
LOG_WARN("fail to store confirm finish trans", KR(ret), K(arg_.trans_id_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadConfirmFinishTransPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadAbandonTransP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadAbandonTransP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadCoordinator coordinator(table_ctx);
|
|
||||||
if (OB_FAIL(coordinator.init())) {
|
|
||||||
LOG_WARN("fail to init coordinator", KR(ret));
|
|
||||||
} else if (OB_FAIL(coordinator.abandon_trans(arg_.trans_id_))) {
|
|
||||||
LOG_WARN("fail to coordinator abandon trans", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadAbandonTransP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadAbandonTransPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadAbandonTransPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.abandon_trans(arg_.trans_id_))) {
|
|
||||||
LOG_WARN("fail to store abandon trans", KR(ret), K(arg_.trans_id_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadAbandonTransPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadGetTransStatusP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadGetTransStatusP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadCoordinator coordinator(table_ctx);
|
|
||||||
if (OB_FAIL(coordinator.init())) {
|
|
||||||
LOG_WARN("fail to init coordinator", KR(ret));
|
|
||||||
} else if (OB_FAIL(coordinator.get_trans_status(arg_.trans_id_, result_.trans_status_,
|
|
||||||
result_.error_code_))) {
|
|
||||||
LOG_WARN("fail to coordinator get trans status", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadGetTransStatusP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ObTableLoadGetTransStatusPeerP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ObTableLoadGetTransStatusPeerP::process()
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
if (OB_FAIL(check_user_access(arg_.credential_))) {
|
|
||||||
LOG_WARN("fail to check_user_access", KR(ret));
|
|
||||||
} else if (OB_FAIL(ObTableLoadService::check_tenant())) {
|
|
||||||
LOG_WARN("fail to check tenant", KR(ret));
|
|
||||||
} else {
|
|
||||||
ObTableLoadTableCtx *table_ctx = nullptr;
|
|
||||||
ObTableLoadUniqueKey key(arg_.table_id_, arg_.task_id_);
|
|
||||||
if (OB_FAIL(ObTableLoadService::get_ctx(key, table_ctx))) {
|
|
||||||
LOG_WARN("fail to get table ctx", KR(ret), K(key));
|
|
||||||
} else {
|
|
||||||
ObTableLoadStore store(table_ctx);
|
|
||||||
if (OB_FAIL(store.init())) {
|
|
||||||
LOG_WARN("fail to init store", KR(ret));
|
|
||||||
} else if (OB_FAIL(store.get_trans_status(arg_.trans_id_, result_.trans_status_,
|
|
||||||
result_.error_code_))) {
|
|
||||||
LOG_WARN("fail to store get trans status", KR(ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OB_NOT_NULL(table_ctx)) {
|
|
||||||
ObTableLoadService::put_ctx(table_ctx);
|
|
||||||
table_ctx = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ObTableLoadGetTransStatusPeerP::check_user_access(const ObString &credential_str)
|
|
||||||
{
|
|
||||||
return ObTableLoadUtils::check_user_access(credential_str, gctx_, credential_);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace observer
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,204 +0,0 @@
|
|||||||
// Copyright (c) 2022-present Oceanbase Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// suzhi.yt <>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "observer/table/ob_table_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_processor.h"
|
|
||||||
#include "rpc/obrpc/ob_rpc_proxy.h"
|
|
||||||
#include "share/table/ob_table_rpc_proxy.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace observer
|
|
||||||
{
|
|
||||||
|
|
||||||
class ObTableLoadStartTransP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_START_TRANS> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadStartTransP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadStartTransP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadStartTransP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreStartTransPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_PRE_START_TRANS_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadPreStartTransPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadPreStartTransPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadPreStartTransPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadConfirmStartTransPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_CONFIRM_START_TRANS_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadConfirmStartTransPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadConfirmStartTransPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadConfirmStartTransPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class ObTableLoadFinishTransP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_FINISH_TRANS> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadFinishTransP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadFinishTransP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadFinishTransP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreFinishTransPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_PRE_FINISH_TRANS_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadPreFinishTransPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadPreFinishTransPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadPreFinishTransPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadConfirmFinishTransPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_CONFIRM_FINISH_TRANS_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadConfirmFinishTransPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadConfirmFinishTransPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadConfirmFinishTransPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class ObTableLoadAbandonTransP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_ABANDON_TRANS> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadAbandonTransP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadAbandonTransP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadAbandonTransP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadAbandonTransPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_ABANDON_TRANS_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadAbandonTransPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadAbandonTransPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadAbandonTransPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class ObTableLoadGetTransStatusP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_GET_TRANS_STATUS> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadGetTransStatusP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadGetTransStatusP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadGetTransStatusP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadGetTransStatusPeerP : public obrpc::ObRpcProcessor<obrpc::ObTableRpcProxy::ObRpc<obrpc::OB_TABLE_API_LOAD_GET_TRANS_STATUS_PEER> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit ObTableLoadGetTransStatusPeerP(const ObGlobalContext &gctx) : gctx_(gctx) {}
|
|
||||||
virtual ~ObTableLoadGetTransStatusPeerP() = default;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int process() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int check_user_access(const ObString &credential_str);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObTableLoadGetTransStatusPeerP);
|
|
||||||
private:
|
|
||||||
const ObGlobalContext &gctx_;
|
|
||||||
table::ObTableApiCredential credential_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace observer
|
|
||||||
} // end namespace oceanbase
|
|
||||||
@ -236,7 +236,6 @@ ob_set_subtarget(ob_share common_mixed
|
|||||||
table/ob_table.cpp
|
table/ob_table.cpp
|
||||||
table/ob_table_rpc_struct.cpp
|
table/ob_table_rpc_struct.cpp
|
||||||
table/ob_table_load_define.cpp
|
table/ob_table_load_define.cpp
|
||||||
table/ob_table_load_rpc_struct.cpp
|
|
||||||
table/ob_table_load_shared_allocator.cpp
|
table/ob_table_load_shared_allocator.cpp
|
||||||
table/ob_table_load_row.cpp
|
table/ob_table_load_row.cpp
|
||||||
transfer/ob_transfer_info.cpp
|
transfer/ob_transfer_info.cpp
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include "observer/ob_server_struct.h"
|
#include "observer/ob_server_struct.h"
|
||||||
#include "observer/net/ob_net_endpoint_ingress_rpc_struct.h"
|
#include "observer/net/ob_net_endpoint_ingress_rpc_struct.h"
|
||||||
#include "share/ob_heartbeat_struct.h"
|
#include "share/ob_heartbeat_struct.h"
|
||||||
|
#include "observer/table_load/control/ob_table_load_control_rpc_struct.h"
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
{
|
{
|
||||||
@ -204,6 +205,7 @@ public:
|
|||||||
RPC_AP(PR5 notify_switch_leader, OB_NOTIFY_SWITCH_LEADER, (obrpc::ObNotifySwitchLeaderArg));
|
RPC_AP(PR5 notify_switch_leader, OB_NOTIFY_SWITCH_LEADER, (obrpc::ObNotifySwitchLeaderArg));
|
||||||
RPC_AP(PR5 update_tenant_info_cache, OB_UPDATE_TENANT_INFO_CACHE, (obrpc::ObUpdateTenantInfoCacheArg), obrpc::ObUpdateTenantInfoCacheRes);
|
RPC_AP(PR5 update_tenant_info_cache, OB_UPDATE_TENANT_INFO_CACHE, (obrpc::ObUpdateTenantInfoCacheArg), obrpc::ObUpdateTenantInfoCacheRes);
|
||||||
RPC_AP(PR5 broadcast_consensus_version, OB_BROADCAST_CONSENSUS_VERSION, (obrpc::ObBroadcastConsensusVersionArg), obrpc::ObBroadcastConsensusVersionRes);
|
RPC_AP(PR5 broadcast_consensus_version, OB_BROADCAST_CONSENSUS_VERSION, (obrpc::ObBroadcastConsensusVersionArg), obrpc::ObBroadcastConsensusVersionRes);
|
||||||
|
RPC_S(PR5 direct_load_control, OB_DIRECT_LOAD_CONTROL, (observer::ObDirectLoadControlRequest), observer::ObDirectLoadControlResult);
|
||||||
}; // end of class ObSrvRpcProxy
|
}; // end of class ObSrvRpcProxy
|
||||||
|
|
||||||
} // end of namespace rpc
|
} // end of namespace rpc
|
||||||
|
|||||||
@ -855,6 +855,16 @@ public:
|
|||||||
K_(hash_val));
|
K_(hash_val));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Table Direct Load Operation Type
|
||||||
|
enum class ObTableDirectLoadOperationType {
|
||||||
|
BEGIN = 0,
|
||||||
|
COMMIT = 1,
|
||||||
|
ABORT = 2,
|
||||||
|
GET_STATUS = 3,
|
||||||
|
INSERT = 4,
|
||||||
|
MAX_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
} // end namespace table
|
} // end namespace table
|
||||||
} // end namespace oceanbase
|
} // end namespace oceanbase
|
||||||
|
|
||||||
|
|||||||
@ -11,13 +11,12 @@ namespace oceanbase
|
|||||||
namespace table
|
namespace table
|
||||||
{
|
{
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER_SIMPLE(ObTableLoadFlag, flag_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER_SIMPLE(ObTableLoadConfig,
|
OB_SERIALIZE_MEMBER_SIMPLE(ObTableLoadConfig,
|
||||||
session_count_,
|
parallel_,
|
||||||
batch_size_,
|
batch_size_,
|
||||||
max_error_row_count_,
|
max_error_row_count_,
|
||||||
flag_);
|
dup_action_,
|
||||||
|
is_need_sort_);
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER_SIMPLE(ObTableLoadSegmentID,
|
OB_SERIALIZE_MEMBER_SIMPLE(ObTableLoadSegmentID,
|
||||||
id_);
|
id_);
|
||||||
|
|||||||
@ -11,49 +11,33 @@
|
|||||||
#include "lib/oblog/ob_log_module.h"
|
#include "lib/oblog/ob_log_module.h"
|
||||||
#include "lib/utility/ob_print_utils.h"
|
#include "lib/utility/ob_print_utils.h"
|
||||||
#include "share/rc/ob_tenant_base.h"
|
#include "share/rc/ob_tenant_base.h"
|
||||||
|
#include "sql/resolver/cmd/ob_load_data_stmt.h"
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
{
|
{
|
||||||
namespace table
|
namespace table
|
||||||
{
|
{
|
||||||
|
|
||||||
static const int64_t TABLE_LOAD_CTX_ID = common::ObCtxIds::WORK_AREA;
|
|
||||||
|
|
||||||
struct ObTableLoadFlag
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
static const uint64_t BIT_IS_NEED_SORT = 1;
|
|
||||||
static const uint64_t BIT_DATA_TYPE = 2;
|
|
||||||
static const uint64_t BIT_DUP_ACTION_TYPE = 2;
|
|
||||||
static const uint64_t BIT_RESERVED = 59;
|
|
||||||
|
|
||||||
union {
|
|
||||||
uint64_t flag_;
|
|
||||||
struct {
|
|
||||||
uint64_t is_need_sort_ : BIT_IS_NEED_SORT;
|
|
||||||
uint64_t data_type_ : BIT_DATA_TYPE;
|
|
||||||
uint64_t dup_action_ : BIT_DUP_ACTION_TYPE;
|
|
||||||
uint64_t reserved_ : BIT_RESERVED;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
ObTableLoadFlag() : flag_(0) {}
|
|
||||||
void reset() { flag_ = 0; }
|
|
||||||
TO_STRING_KV(K_(is_need_sort), K_(data_type), K_(dup_action));
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ObTableLoadConfig final
|
struct ObTableLoadConfig final
|
||||||
{
|
{
|
||||||
OB_UNIS_VERSION(1);
|
OB_UNIS_VERSION(1);
|
||||||
public:
|
public:
|
||||||
ObTableLoadConfig() : session_count_(0), batch_size_(0), max_error_row_count_(0) {}
|
ObTableLoadConfig()
|
||||||
int32_t session_count_;
|
: parallel_(0),
|
||||||
|
batch_size_(0),
|
||||||
|
max_error_row_count_(0),
|
||||||
|
dup_action_(sql::ObLoadDupActionType::LOAD_INVALID_MODE),
|
||||||
|
is_need_sort_(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(parallel), K_(batch_size), K_(max_error_row_count), K_(dup_action),
|
||||||
|
K_(is_need_sort));
|
||||||
|
public:
|
||||||
|
int32_t parallel_;
|
||||||
int32_t batch_size_;
|
int32_t batch_size_;
|
||||||
uint64_t max_error_row_count_;
|
uint64_t max_error_row_count_;
|
||||||
ObTableLoadFlag flag_;
|
sql::ObLoadDupActionType dup_action_;
|
||||||
|
bool is_need_sort_;
|
||||||
TO_STRING_KV(K_(session_count), K_(batch_size), K_(max_error_row_count), K_(flag));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ObTableLoadPartitionId
|
struct ObTableLoadPartitionId
|
||||||
@ -391,6 +375,44 @@ static int table_load_trans_status_to_string(ObTableLoadTransStatusType trans_st
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class ObTableLoadClientStatus : int64_t
|
||||||
|
{
|
||||||
|
RUNNING = 0,
|
||||||
|
COMMITTING = 1,
|
||||||
|
COMMIT = 2,
|
||||||
|
ERROR = 3,
|
||||||
|
ABORT = 4,
|
||||||
|
MAX_STATUS
|
||||||
|
};
|
||||||
|
|
||||||
|
static int table_load_client_status_to_string(ObTableLoadClientStatus client_status,
|
||||||
|
common::ObString &status_str)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
switch (client_status) {
|
||||||
|
case ObTableLoadClientStatus::RUNNING:
|
||||||
|
status_str = "RUNNING";
|
||||||
|
break;
|
||||||
|
case ObTableLoadClientStatus::COMMITTING:
|
||||||
|
status_str = "COMMITTING";
|
||||||
|
break;
|
||||||
|
case ObTableLoadClientStatus::COMMIT:
|
||||||
|
status_str = "COMMIT";
|
||||||
|
break;
|
||||||
|
case ObTableLoadClientStatus::ERROR:
|
||||||
|
status_str = "ERROR";
|
||||||
|
break;
|
||||||
|
case ObTableLoadClientStatus::ABORT:
|
||||||
|
status_str = "ABORT";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
OB_LOG(WARN, "unexpected client status", KR(ret), K(client_status));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
struct ObTableLoadResultInfo
|
struct ObTableLoadResultInfo
|
||||||
{
|
{
|
||||||
OB_UNIS_VERSION(1);
|
OB_UNIS_VERSION(1);
|
||||||
|
|||||||
@ -167,7 +167,6 @@ int64_t ObTableLoadRow<T>::get_serialize_size() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef ObTableLoadRow<common::ObObj> ObTableLoadObjRow;
|
typedef ObTableLoadRow<common::ObObj> ObTableLoadObjRow;
|
||||||
typedef ObTableLoadRow<common::ObString> ObTableLoadStrRow;
|
|
||||||
|
|
||||||
class ObTableLoadTabletObjRow
|
class ObTableLoadTabletObjRow
|
||||||
{
|
{
|
||||||
|
|||||||
@ -133,7 +133,6 @@ const T &ObTableLoadRowArray<T>::at(int64_t idx) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef ObTableLoadRowArray<ObTableLoadObjRow> ObTableLoadObjRowArray;
|
typedef ObTableLoadRowArray<ObTableLoadObjRow> ObTableLoadObjRowArray;
|
||||||
typedef ObTableLoadRowArray<ObTableLoadStrRow> ObTableLoadStrRowArray;
|
|
||||||
typedef ObTableLoadRowArray<ObTableLoadTabletObjRow> ObTableLoadTabletObjRowArray;
|
typedef ObTableLoadRowArray<ObTableLoadTabletObjRow> ObTableLoadTabletObjRowArray;
|
||||||
|
|
||||||
} // namespace table
|
} // namespace table
|
||||||
|
|||||||
@ -1,331 +0,0 @@
|
|||||||
// Copyright (c) 2022-present Oceanbase Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// suzhi.yt <>
|
|
||||||
|
|
||||||
#define USING_LOG_PREFIX CLIENT
|
|
||||||
|
|
||||||
#include "ob_table_load_rpc_struct.h"
|
|
||||||
#include "observer/table_load/ob_table_load_utils.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace table
|
|
||||||
{
|
|
||||||
using namespace common;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* begin
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadBeginRequest,
|
|
||||||
credential_,
|
|
||||||
table_name_,
|
|
||||||
config_,
|
|
||||||
timeout_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadBeginResult,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
column_names_,
|
|
||||||
status_,
|
|
||||||
error_code_);
|
|
||||||
|
|
||||||
OB_DEF_SERIALIZE(ObTableLoadPreBeginPeerRequest)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
LST_DO_CODE(OB_UNIS_ENCODE, credential_, table_id_, config_, column_count_, dup_action_, px_mode_,
|
|
||||||
online_opt_stat_gather_, snapshot_version_, dest_table_id_, task_id_, schema_version_,
|
|
||||||
snapshot_version_, data_version_, partition_id_array_, target_partition_id_array_);
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (OB_ISNULL(session_info_)) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("session info is null", K(ret));
|
|
||||||
} else {
|
|
||||||
OB_UNIS_ENCODE(*session_info_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
OB_DEF_DESERIALIZE(ObTableLoadPreBeginPeerRequest)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
LST_DO_CODE(OB_UNIS_DECODE, credential_, table_id_, config_, column_count_, dup_action_, px_mode_,
|
|
||||||
online_opt_stat_gather_, snapshot_version_, dest_table_id_, task_id_, schema_version_,
|
|
||||||
snapshot_version_, data_version_, partition_id_array_, target_partition_id_array_);
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (OB_FAIL(observer::ObTableLoadUtils::create_session_info(session_info_, free_session_ctx_))) {
|
|
||||||
LOG_WARN("fail to init session info", KR(ret));
|
|
||||||
} else {
|
|
||||||
OB_UNIS_DECODE(*session_info_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
OB_DEF_SERIALIZE_SIZE(ObTableLoadPreBeginPeerRequest)
|
|
||||||
{
|
|
||||||
int ret = OB_SUCCESS;
|
|
||||||
int64_t len = 0;
|
|
||||||
LST_DO_CODE(OB_UNIS_ADD_LEN, credential_, table_id_, config_, column_count_, dup_action_,
|
|
||||||
px_mode_, online_opt_stat_gather_, snapshot_version_, dest_table_id_, task_id_,
|
|
||||||
schema_version_, snapshot_version_, data_version_, partition_id_array_,
|
|
||||||
target_partition_id_array_);
|
|
||||||
if (OB_SUCC(ret)) {
|
|
||||||
if (OB_ISNULL(session_info_)) {
|
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LOG_WARN("session info is null", K(ret), K(session_info_));
|
|
||||||
} else {
|
|
||||||
OB_UNIS_ADD_LEN(*session_info_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadPreBeginPeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadConfirmBeginPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_)
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadConfirmBeginPeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* finish
|
|
||||||
*/
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadFinishRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadFinishResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadPreMergePeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
committed_trans_id_array_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadPreMergePeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadStartMergePeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadStartMergePeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* commit
|
|
||||||
*/
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadCommitRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadCommitResult,
|
|
||||||
ret_code_,
|
|
||||||
result_info_,
|
|
||||||
sql_statistics_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadCommitPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadCommitPeerResult,
|
|
||||||
ret_code_,
|
|
||||||
result_info_,
|
|
||||||
sql_statistics_);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* abort
|
|
||||||
*/
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadAbortRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadAbortResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadAbortPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadAbortPeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get status
|
|
||||||
*/
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadGetStatusRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadGetStatusResult,
|
|
||||||
status_,
|
|
||||||
error_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadGetStatusPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadGetStatusPeerResult,
|
|
||||||
status_,
|
|
||||||
error_code_);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load
|
|
||||||
*/
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_,
|
|
||||||
session_id_,
|
|
||||||
sequence_no_,
|
|
||||||
payload_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_,
|
|
||||||
session_id_,
|
|
||||||
sequence_no_,
|
|
||||||
payload_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadPeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start trans
|
|
||||||
*/
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadStartTransRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
segment_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadStartTransResult,
|
|
||||||
trans_id_,
|
|
||||||
trans_status_,
|
|
||||||
error_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadPreStartTransPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadPreStartTransPeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadConfirmStartTransPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadConfirmStartTransPeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* finish trans
|
|
||||||
*/
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadFinishTransRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadFinishTransResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadPreFinishTransPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadPreFinishTransPeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadConfirmFinishTransPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadConfirmFinishTransPeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* abandon trans
|
|
||||||
*/
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadAbandonTransRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadAbandonTransResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadAbandonTransPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadAbandonTransPeerResult,
|
|
||||||
ret_code_);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get trans status
|
|
||||||
*/
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadGetTransStatusRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadGetTransStatusResult,
|
|
||||||
trans_status_,
|
|
||||||
error_code_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadGetTransStatusPeerRequest,
|
|
||||||
credential_,
|
|
||||||
table_id_,
|
|
||||||
task_id_,
|
|
||||||
trans_id_);
|
|
||||||
|
|
||||||
OB_SERIALIZE_MEMBER(ObTableLoadGetTransStatusPeerResult,
|
|
||||||
trans_status_,
|
|
||||||
error_code_);
|
|
||||||
|
|
||||||
} // namespace table
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -1,723 +0,0 @@
|
|||||||
// Copyright (c) 2022-present Oceanbase Inc. All Rights Reserved.
|
|
||||||
// Author:
|
|
||||||
// suzhi.yt <>
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common/ob_store_range.h"
|
|
||||||
#include "lib/net/ob_addr.h"
|
|
||||||
#include "ob_table_load_array.h"
|
|
||||||
#include "ob_table_load_define.h"
|
|
||||||
#include "share/table/ob_table_load_sql_statistics.h"
|
|
||||||
#include "share/table/ob_table_load_row_array.h"
|
|
||||||
#include "sql/resolver/cmd/ob_load_data_stmt.h"
|
|
||||||
#include "sql/session/ob_sql_session_info.h"
|
|
||||||
#include "observer/table_load/ob_table_load_utils.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
|
||||||
{
|
|
||||||
namespace table
|
|
||||||
{
|
|
||||||
using common::ObString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* begin
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadBeginRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadBeginRequest() {}
|
|
||||||
TO_STRING_KV(K_(table_name), K_(config), K_(timeout));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
ObString table_name_;
|
|
||||||
ObTableLoadConfig config_;
|
|
||||||
int64_t timeout_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadBeginResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadBeginResult()
|
|
||||||
: table_id_(common::OB_INVALID_ID),
|
|
||||||
task_id_(0),
|
|
||||||
status_(ObTableLoadStatusType::NONE),
|
|
||||||
error_code_(common::OB_SUCCESS)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(column_names), K_(status), K_(error_code));
|
|
||||||
public:
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadArray<ObString> column_names_;
|
|
||||||
ObTableLoadStatusType status_;
|
|
||||||
int32_t error_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreBeginPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPreBeginPeerRequest()
|
|
||||||
: table_id_(common::OB_INVALID_ID),
|
|
||||||
column_count_(0),
|
|
||||||
dup_action_(sql::ObLoadDupActionType::LOAD_INVALID_MODE),
|
|
||||||
px_mode_(false),
|
|
||||||
online_opt_stat_gather_(false),
|
|
||||||
dest_table_id_(common::OB_INVALID_ID),
|
|
||||||
task_id_(0),
|
|
||||||
schema_version_(0),
|
|
||||||
snapshot_version_(0),
|
|
||||||
data_version_(0),
|
|
||||||
session_info_(nullptr)
|
|
||||||
{
|
|
||||||
free_session_ctx_.sessid_ = sql::ObSQLSessionInfo::INVALID_SESSID;
|
|
||||||
}
|
|
||||||
~ObTableLoadPreBeginPeerRequest()
|
|
||||||
{
|
|
||||||
if (nullptr != session_info_) {
|
|
||||||
if (free_session_ctx_.sessid_ != sql::ObSQLSessionInfo::INVALID_SESSID) {
|
|
||||||
observer::ObTableLoadUtils::free_session_info(session_info_, free_session_ctx_);
|
|
||||||
}
|
|
||||||
session_info_ = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TO_STRING_KV(K_(table_id),
|
|
||||||
K_(config),
|
|
||||||
K_(column_count),
|
|
||||||
K_(dup_action),
|
|
||||||
K_(px_mode),
|
|
||||||
K_(online_opt_stat_gather),
|
|
||||||
K_(dest_table_id),
|
|
||||||
K_(task_id),
|
|
||||||
K_(schema_version),
|
|
||||||
K_(snapshot_version),
|
|
||||||
K_(data_version),
|
|
||||||
K_(partition_id_array),
|
|
||||||
K_(target_partition_id_array));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
ObTableLoadConfig config_;
|
|
||||||
uint64_t column_count_;
|
|
||||||
sql::ObLoadDupActionType dup_action_;
|
|
||||||
bool px_mode_;
|
|
||||||
bool online_opt_stat_gather_;
|
|
||||||
// ddl param
|
|
||||||
uint64_t dest_table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
int64_t schema_version_;
|
|
||||||
int64_t snapshot_version_;
|
|
||||||
int64_t data_version_;
|
|
||||||
// partition info
|
|
||||||
ObTableLoadArray<ObTableLoadLSIdAndPartitionId> partition_id_array_;//orig table
|
|
||||||
ObTableLoadArray<ObTableLoadLSIdAndPartitionId> target_partition_id_array_;//FIXME: target table
|
|
||||||
sql::ObSQLSessionInfo *session_info_;
|
|
||||||
sql::ObFreeSessionCtx free_session_ctx_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreBeginPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPreBeginPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadConfirmBeginPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadConfirmBeginPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadConfirmBeginPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadConfirmBeginPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* finish
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadFinishRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadFinishRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadFinishResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadFinishResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
public:
|
|
||||||
int32_t ret_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreMergePeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPreMergePeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(committed_trans_id_array));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadArray<ObTableLoadTransId> committed_trans_id_array_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreMergePeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPreMergePeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
public:
|
|
||||||
int32_t ret_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadStartMergePeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadStartMergePeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadStartMergePeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadStartMergePeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
public:
|
|
||||||
int32_t ret_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* commit
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadCommitRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadCommitRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadCommitResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadCommitResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
TO_STRING_KV(K_(ret_code), K_(result_info), K_(sql_statistics));
|
|
||||||
public:
|
|
||||||
int32_t ret_code_;
|
|
||||||
ObTableLoadResultInfo result_info_;
|
|
||||||
ObTableLoadSqlStatistics sql_statistics_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadCommitPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadCommitPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadCommitPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadCommitPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
TO_STRING_KV(K_(ret_code), K_(result_info), K_(sql_statistics));
|
|
||||||
public:
|
|
||||||
int32_t ret_code_;
|
|
||||||
ObTableLoadResultInfo result_info_;
|
|
||||||
ObTableLoadSqlStatistics sql_statistics_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* abort
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadAbortRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadAbortRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadAbortResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadAbortResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadAbortPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadAbortPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadAbortPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadAbortPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get status
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadGetStatusRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadGetStatusRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadGetStatusResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadGetStatusResult()
|
|
||||||
: status_(ObTableLoadStatusType::NONE), error_code_(common::OB_SUCCESS)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
TO_STRING_KV(K_(status), K_(error_code));
|
|
||||||
public:
|
|
||||||
ObTableLoadStatusType status_;
|
|
||||||
int32_t error_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadGetStatusPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadGetStatusPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadGetStatusPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadGetStatusPeerResult()
|
|
||||||
: status_(ObTableLoadStatusType::NONE), error_code_(common::OB_SUCCESS)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
TO_STRING_KV(K_(status), K_(error_code));
|
|
||||||
public:
|
|
||||||
ObTableLoadStatusType status_;
|
|
||||||
int32_t error_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadRequest()
|
|
||||||
: table_id_(common::OB_INVALID_ID),
|
|
||||||
task_id_(0),
|
|
||||||
session_id_(0),
|
|
||||||
sequence_no_(common::OB_INVALID_ID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id), K_(session_id), K_(sequence_no),
|
|
||||||
K(payload_.length()));
|
|
||||||
public:
|
|
||||||
ObString credential_; //这个里面会包含tenant_id, database等信息
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
int32_t session_id_; // 从1开始
|
|
||||||
uint64_t sequence_no_; // 从1开始
|
|
||||||
ObString payload_; //里面包的是ObTableLoadObjArray / ObTableLoadStrArray / Raw String
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPeerRequest()
|
|
||||||
: table_id_(common::OB_INVALID_ID),
|
|
||||||
task_id_(0),
|
|
||||||
session_id_(0),
|
|
||||||
sequence_no_(common::OB_INVALID_ID) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id), K_(session_id), K_(sequence_no));
|
|
||||||
public:
|
|
||||||
ObString credential_; //这个里面会包含tenant_id, database等信息
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
int32_t session_id_; // 从1开始
|
|
||||||
uint64_t sequence_no_; // 从1开始
|
|
||||||
ObString payload_; //里面包的是ObTableLoadObjArray
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start trans
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadStartTransRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadStartTransRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(segment_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadSegmentID segment_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadStartTransResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadStartTransResult()
|
|
||||||
: trans_status_(ObTableLoadTransStatusType::NONE), error_code_(common::OB_SUCCESS)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
TO_STRING_KV(K_(trans_id), K_(trans_status), K_(error_code));
|
|
||||||
public:
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
ObTableLoadTransStatusType trans_status_;
|
|
||||||
int32_t error_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreStartTransPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPreStartTransPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreStartTransPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPreStartTransPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ObTableLoadConfirmStartTransPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadConfirmStartTransPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadConfirmStartTransPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadConfirmStartTransPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* finish trans
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadFinishTransRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadFinishTransRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadFinishTransResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadFinishTransResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreFinishTransPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPreFinishTransPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadPreFinishTransPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadPreFinishTransPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ObTableLoadConfirmFinishTransPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadConfirmFinishTransPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadConfirmFinishTransPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadConfirmFinishTransPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* abandon trans
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadAbandonTransRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadAbandonTransRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadAbandonTransResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadAbandonTransResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadAbandonTransPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadAbandonTransPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadAbandonTransPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadAbandonTransPeerResult() : ret_code_(common::OB_SUCCESS) {}
|
|
||||||
|
|
||||||
int32_t ret_code_;
|
|
||||||
|
|
||||||
TO_STRING_KV(K_(ret_code));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get trans status
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ObTableLoadGetTransStatusRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadGetTransStatusRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadGetTransStatusResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadGetTransStatusResult()
|
|
||||||
: trans_status_(ObTableLoadTransStatusType::NONE), error_code_(common::OB_SUCCESS)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
TO_STRING_KV(K_(trans_status), K_(error_code));
|
|
||||||
public:
|
|
||||||
ObTableLoadTransStatusType trans_status_;
|
|
||||||
int32_t error_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadGetTransStatusPeerRequest final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadGetTransStatusPeerRequest() : table_id_(common::OB_INVALID_ID), task_id_(0) {}
|
|
||||||
TO_STRING_KV(K_(table_id), K_(task_id), K_(trans_id));
|
|
||||||
public:
|
|
||||||
ObString credential_;
|
|
||||||
uint64_t table_id_;
|
|
||||||
int64_t task_id_;
|
|
||||||
ObTableLoadTransId trans_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObTableLoadGetTransStatusPeerResult final
|
|
||||||
{
|
|
||||||
OB_UNIS_VERSION(1);
|
|
||||||
public:
|
|
||||||
ObTableLoadGetTransStatusPeerResult()
|
|
||||||
: trans_status_(ObTableLoadTransStatusType::NONE), error_code_(common::OB_SUCCESS)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
TO_STRING_KV(K_(trans_status), K_(error_code));
|
|
||||||
public:
|
|
||||||
ObTableLoadTransStatusType trans_status_;
|
|
||||||
int32_t error_code_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace table
|
|
||||||
} // namespace oceanbase
|
|
||||||
@ -14,7 +14,6 @@
|
|||||||
#define _OB_TABLE_RPC_PROXY_H 1
|
#define _OB_TABLE_RPC_PROXY_H 1
|
||||||
#include "rpc/obrpc/ob_rpc_proxy.h"
|
#include "rpc/obrpc/ob_rpc_proxy.h"
|
||||||
#include "share/table/ob_table_rpc_struct.h"
|
#include "share/table/ob_table_rpc_struct.h"
|
||||||
#include "share/table/ob_table_load_rpc_struct.h"
|
|
||||||
#include "share/config/ob_server_config.h"
|
#include "share/config/ob_server_config.h"
|
||||||
#include "observer/ob_server_struct.h"
|
#include "observer/ob_server_struct.h"
|
||||||
|
|
||||||
@ -32,36 +31,7 @@ public:
|
|||||||
RPC_SS(PR5 execute_query, obrpc::OB_TABLE_API_EXECUTE_QUERY, (table::ObTableQueryRequest), table::ObTableQueryResult);
|
RPC_SS(PR5 execute_query, obrpc::OB_TABLE_API_EXECUTE_QUERY, (table::ObTableQueryRequest), table::ObTableQueryResult);
|
||||||
RPC_S(PR5 query_and_mutate, obrpc::OB_TABLE_API_QUERY_AND_MUTATE, (table::ObTableQueryAndMutateRequest), table::ObTableQueryAndMutateResult);
|
RPC_S(PR5 query_and_mutate, obrpc::OB_TABLE_API_QUERY_AND_MUTATE, (table::ObTableQueryAndMutateRequest), table::ObTableQueryAndMutateResult);
|
||||||
RPC_S(PR5 execute_query_sync, obrpc::OB_TABLE_API_EXECUTE_QUERY_SYNC, (table::ObTableQuerySyncRequest), table::ObTableQuerySyncResult);
|
RPC_S(PR5 execute_query_sync, obrpc::OB_TABLE_API_EXECUTE_QUERY_SYNC, (table::ObTableQuerySyncRequest), table::ObTableQuerySyncResult);
|
||||||
|
RPC_S(PR5 direct_load, obrpc::OB_TABLE_API_DIRECT_LOAD, (table::ObTableDirectLoadRequest), table::ObTableDirectLoadResult);
|
||||||
/**
|
|
||||||
* table load
|
|
||||||
*/
|
|
||||||
// client -> server
|
|
||||||
RPC_S(PR5 load_begin, obrpc::OB_TABLE_API_LOAD_BEGIN, (table::ObTableLoadBeginRequest), table::ObTableLoadBeginResult);
|
|
||||||
RPC_S(PR5 load_finish, obrpc::OB_TABLE_API_LOAD_FINISH, (table::ObTableLoadFinishRequest), table::ObTableLoadFinishResult);
|
|
||||||
RPC_S(PR5 load_commit, obrpc::OB_TABLE_API_LOAD_COMMIT, (table::ObTableLoadCommitRequest), table::ObTableLoadCommitResult);
|
|
||||||
RPC_S(PR5 load_abort, obrpc::OB_TABLE_API_LOAD_ABORT, (table::ObTableLoadAbortRequest), table::ObTableLoadAbortResult);
|
|
||||||
RPC_S(PR5 load_get_status, obrpc::OB_TABLE_API_LOAD_GET_STATUS, (table::ObTableLoadGetStatusRequest), table::ObTableLoadGetStatusResult);
|
|
||||||
RPC_S(PR5 load, obrpc::OB_TABLE_API_LOAD, (table::ObTableLoadRequest), table::ObTableLoadResult);
|
|
||||||
RPC_S(PR5 load_start_trans, obrpc::OB_TABLE_API_LOAD_START_TRANS, (table::ObTableLoadStartTransRequest), table::ObTableLoadStartTransResult);
|
|
||||||
RPC_S(PR5 load_finish_trans, obrpc::OB_TABLE_API_LOAD_FINISH_TRANS, (table::ObTableLoadFinishTransRequest), table::ObTableLoadFinishTransResult);
|
|
||||||
RPC_S(PR5 load_abandon_trans, obrpc::OB_TABLE_API_LOAD_ABANDON_TRANS, (table::ObTableLoadAbandonTransRequest), table::ObTableLoadAbandonTransResult);
|
|
||||||
RPC_S(PR5 load_get_trans_status, obrpc::OB_TABLE_API_LOAD_GET_TRANS_STATUS, (table::ObTableLoadGetTransStatusRequest), table::ObTableLoadGetTransStatusResult);
|
|
||||||
// coordinator -> peer
|
|
||||||
RPC_S(PR5 load_pre_begin_peer, obrpc::OB_TABLE_API_LOAD_PRE_BEGIN_PEER, (table::ObTableLoadPreBeginPeerRequest), table::ObTableLoadPreBeginPeerResult);
|
|
||||||
RPC_S(PR5 load_confirm_begin_peer, obrpc::OB_TABLE_API_LOAD_CONFIRM_BEGIN_PEER, (table::ObTableLoadConfirmBeginPeerRequest), table::ObTableLoadConfirmBeginPeerResult);
|
|
||||||
RPC_S(PR5 load_pre_merge_peer, obrpc::OB_TABLE_API_LOAD_PRE_MERGE_PEER, (table::ObTableLoadPreMergePeerRequest), table::ObTableLoadPreMergePeerResult);
|
|
||||||
RPC_S(PR5 load_start_merge_peer, obrpc::OB_TABLE_API_LOAD_START_MERGE_PEER, (table::ObTableLoadStartMergePeerRequest), table::ObTableLoadStartMergePeerResult);
|
|
||||||
RPC_S(PR5 load_commit_peer, obrpc::OB_TABLE_API_LOAD_COMMIT_PEER, (table::ObTableLoadCommitPeerRequest), table::ObTableLoadCommitPeerResult);
|
|
||||||
RPC_S(PR5 load_abort_peer, obrpc::OB_TABLE_API_LOAD_ABORT_PEER, (table::ObTableLoadAbortPeerRequest), table::ObTableLoadAbortPeerResult);
|
|
||||||
RPC_S(PR5 load_get_status_peer, obrpc::OB_TABLE_API_LOAD_GET_STATUS_PEER, (table::ObTableLoadGetStatusPeerRequest), table::ObTableLoadGetStatusPeerResult);
|
|
||||||
RPC_S(PR5 load_peer, obrpc::OB_TABLE_API_LOAD_PEER, (table::ObTableLoadPeerRequest), table::ObTableLoadPeerResult);
|
|
||||||
RPC_S(PR5 load_pre_start_trans_peer, obrpc::OB_TABLE_API_LOAD_PRE_START_TRANS_PEER, (table::ObTableLoadPreStartTransPeerRequest), table::ObTableLoadPreStartTransPeerResult);
|
|
||||||
RPC_S(PR5 load_confirm_start_trans_peer, obrpc::OB_TABLE_API_LOAD_CONFIRM_START_TRANS_PEER, (table::ObTableLoadConfirmStartTransPeerRequest), table::ObTableLoadConfirmStartTransPeerResult);
|
|
||||||
RPC_S(PR5 load_pre_finish_trans_peer, obrpc::OB_TABLE_API_LOAD_PRE_FINISH_TRANS_PEER, (table::ObTableLoadPreFinishTransPeerRequest), table::ObTableLoadPreFinishTransPeerResult);
|
|
||||||
RPC_S(PR5 load_confirm_finish_trans_peer, obrpc::OB_TABLE_API_LOAD_CONFIRM_FINISH_TRANS_PEER, (table::ObTableLoadConfirmFinishTransPeerRequest), table::ObTableLoadConfirmFinishTransPeerResult);
|
|
||||||
RPC_S(PR5 load_abandon_trans_peer, obrpc::OB_TABLE_API_LOAD_ABANDON_TRANS_PEER, (table::ObTableLoadAbandonTransPeerRequest), table::ObTableLoadAbandonTransPeerResult);
|
|
||||||
RPC_S(PR5 load_get_trans_status_peer, obrpc::OB_TABLE_API_LOAD_GET_TRANS_STATUS_PEER, (table::ObTableLoadGetTransStatusPeerRequest), table::ObTableLoadGetTransStatusPeerResult);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // end namespace obrpc
|
}; // end namespace obrpc
|
||||||
|
|||||||
@ -91,3 +91,12 @@ OB_SERIALIZE_MEMBER((ObTableQuerySyncRequest, ObTableQueryRequest),
|
|||||||
query_session_id_,
|
query_session_id_,
|
||||||
query_type_
|
query_type_
|
||||||
);
|
);
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
OB_SERIALIZE_MEMBER(ObTableDirectLoadRequest,
|
||||||
|
credential_,
|
||||||
|
operation_type_,
|
||||||
|
arg_content_);
|
||||||
|
|
||||||
|
OB_SERIALIZE_MEMBER(ObTableDirectLoadResult,
|
||||||
|
operation_type_,
|
||||||
|
res_content_);
|
||||||
|
|||||||
@ -260,6 +260,92 @@ public:
|
|||||||
ObQueryOperationType query_type_;
|
ObQueryOperationType query_type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ObTableDirectLoadRequest
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadRequest() : operation_type_(ObTableDirectLoadOperationType::MAX_TYPE) {}
|
||||||
|
template <class Arg>
|
||||||
|
int set_arg(const Arg &arg, common::ObIAllocator &allocator)
|
||||||
|
{
|
||||||
|
int ret = common::OB_SUCCESS;
|
||||||
|
const int64_t size = arg.get_serialize_size();
|
||||||
|
char *buf = nullptr;
|
||||||
|
int64_t pos = 0;
|
||||||
|
if (OB_ISNULL(buf = static_cast<char *>(allocator.alloc(size)))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
SERVER_LOG(WARN, "fail to alloc memory", K(ret), K(size));
|
||||||
|
} else if (OB_FAIL(arg.serialize(buf, size, pos))) {
|
||||||
|
SERVER_LOG(WARN, "fail to serialize arg", K(ret), K(arg));
|
||||||
|
} else {
|
||||||
|
arg_content_.assign_ptr(buf, size);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template <class Arg>
|
||||||
|
int get_arg(Arg &arg) const
|
||||||
|
{
|
||||||
|
int ret = common::OB_SUCCESS;
|
||||||
|
int64_t pos = 0;
|
||||||
|
if (OB_UNLIKELY(arg_content_.empty())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
SERVER_LOG(WARN, "invalid args", K(ret), KPC(this));
|
||||||
|
} else if (OB_FAIL(arg.deserialize(arg_content_.ptr(), arg_content_.length(), pos))) {
|
||||||
|
SERVER_LOG(WARN, "fail to deserialize arg content", K(ret), KPC(this));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
TO_STRING_KV("credential", common::ObHexStringWrap(credential_), K_(operation_type),
|
||||||
|
"arg_content", common::ObHexStringWrap(arg_content_));
|
||||||
|
public:
|
||||||
|
ObString credential_;
|
||||||
|
ObTableDirectLoadOperationType operation_type_;
|
||||||
|
ObString arg_content_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ObTableDirectLoadResult
|
||||||
|
{
|
||||||
|
OB_UNIS_VERSION(1);
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadResult() : operation_type_(ObTableDirectLoadOperationType::MAX_TYPE) {}
|
||||||
|
template <class Res>
|
||||||
|
int set_res(const Res &res, common::ObIAllocator &allocator)
|
||||||
|
{
|
||||||
|
int ret = common::OB_SUCCESS;
|
||||||
|
const int64_t size = res.get_serialize_size();
|
||||||
|
if (size > 0) {
|
||||||
|
char *buf = nullptr;
|
||||||
|
int64_t pos = 0;
|
||||||
|
if (OB_ISNULL(buf = static_cast<char *>(allocator.alloc(size)))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
SERVER_LOG(WARN, "fail to alloc memory", K(ret), K(size));
|
||||||
|
} else if (OB_FAIL(res.serialize(buf, size, pos))) {
|
||||||
|
SERVER_LOG(WARN, "fail to serialize res", K(ret), K(res));
|
||||||
|
} else {
|
||||||
|
res_content_.assign_ptr(buf, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template <class Res>
|
||||||
|
int get_res(Res &res) const
|
||||||
|
{
|
||||||
|
int ret = common::OB_SUCCESS;
|
||||||
|
int64_t pos = 0;
|
||||||
|
if (OB_UNLIKELY(res_content_.empty())) {
|
||||||
|
ret = OB_INVALID_ARGUMENT;
|
||||||
|
SERVER_LOG(WARN, "invalid args", K(ret), KPC(this));
|
||||||
|
} else if (OB_FAIL(res.deserialize(res_content_.ptr(), res_content_.length(), pos))) {
|
||||||
|
SERVER_LOG(WARN, "fail to deserialize res content", K(ret), KPC(this));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
TO_STRING_KV(K_(operation_type), "res_content", common::ObHexStringWrap(res_content_));
|
||||||
|
public:
|
||||||
|
ObTableDirectLoadOperationType operation_type_;
|
||||||
|
ObString res_content_;
|
||||||
|
};
|
||||||
|
|
||||||
} // end namespace table
|
} // end namespace table
|
||||||
} // end namespace oceanbase
|
} // end namespace oceanbase
|
||||||
|
|
||||||
|
|||||||
@ -2089,7 +2089,6 @@ int ObLoadDataDirectImpl::init_execute_context()
|
|||||||
load_param.max_error_row_count_ = execute_param_.max_error_rows_;
|
load_param.max_error_row_count_ = execute_param_.max_error_rows_;
|
||||||
load_param.column_count_ = execute_param_.store_column_idxs_.count();
|
load_param.column_count_ = execute_param_.store_column_idxs_.count();
|
||||||
load_param.need_sort_ = execute_param_.need_sort_;
|
load_param.need_sort_ = execute_param_.need_sort_;
|
||||||
load_param.data_type_ = ObTableLoadDataType::OBJ_ARRAY;
|
|
||||||
load_param.dup_action_ = execute_param_.dup_action_;
|
load_param.dup_action_ = execute_param_.dup_action_;
|
||||||
load_param.sql_mode_ = execute_param_.sql_mode_;
|
load_param.sql_mode_ = execute_param_.sql_mode_;
|
||||||
load_param.px_mode_ = false;
|
load_param.px_mode_ = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user