提交 58698cf4 编写于 作者: D dz0 提交者: LINGuanRen

fix tableapi whitescan

上级 d475941c
......@@ -94,7 +94,8 @@ bool ObHTableColumnTracker::is_done(int64_t timestamp) const
ObHTableExplicitColumnTracker::ObHTableExplicitColumnTracker()
:columns_(),
curr_column_idx_(0),
curr_column_(NULL)
curr_column_(NULL),
current_count_(0)
{}
int ObHTableExplicitColumnTracker::init(const table::ObHTableFilter &htable_filter, common::ObQueryFlag::ScanOrder &scan_order)
......
......@@ -66,7 +66,8 @@ public:
ObHTableColumnTracker()
:max_versions_(1),
min_versions_(0),
oldest_stamp_(0)
oldest_stamp_(0),
tracker_scan_order_(common::ObQueryFlag::ScanOrder::ImplementedOrder)
{}
virtual ~ObHTableColumnTracker() {}
virtual int init(const table::ObHTableFilter &htable_filter, common::ObQueryFlag::ScanOrder &scan_order) = 0;
......
......@@ -936,7 +936,7 @@ int ObTableApiUpdateRowIterator::cons_new_row(const ObTableOperation &table_oper
int ObTableApiUpdateRowIterator::obj_increment(
const common::ObObj &delta,
const common::ObObj &src,
const sql::ObExprResType target_type,
const sql::ObExprResType &target_type,
common::ObObj &target)
{
int ret = OB_SUCCESS;
......@@ -988,7 +988,7 @@ int ObTableApiUpdateRowIterator::obj_increment(
int ObTableApiUpdateRowIterator::obj_append(
const common::ObObj &delta,
const common::ObObj &src,
const sql::ObExprResType target_type,
const sql::ObExprResType &target_type,
common::ObObj &target)
{
int ret = OB_SUCCESS;
......
......@@ -135,12 +135,12 @@ private:
int obj_increment(
const common::ObObj &delta,
const common::ObObj &src,
const sql::ObExprResType target_type,
const sql::ObExprResType &target_type,
common::ObObj &target);
int obj_append(
const common::ObObj &delta,
const common::ObObj &src,
const sql::ObExprResType target_type,
const sql::ObExprResType &target_type,
common::ObObj &target);
int int_add_int_with_check(
int64_t old_int,
......
......@@ -113,22 +113,32 @@ ObQuerySyncMgr::ObQuerySyncMgr() : session_id_(0)
ObQuerySyncMgr &ObQuerySyncMgr::get_instance()
{
int ret = OB_SUCCESS;
ObQuerySyncMgr *instance = NULL;
while (OB_UNLIKELY(once_ < 2)) {
if (ATOMIC_BCAS(&once_, 0, 1)) {
instance = OB_NEW(ObQuerySyncMgr, ObModIds::TABLE_PROC);
if (OB_LIKELY(OB_NOT_NULL(instance))) {
if (common::OB_SUCCESS != instance->init()) {
if (OB_NOT_NULL(instance)) {
if (OB_FAIL(instance->init())) {
LOG_WARN("failed to init ObQuerySyncMgr instance");
OB_DELETE(ObQuerySyncMgr, ObModIds::TABLE_PROC, instance);
instance = NULL;
ATOMIC_BCAS(&once_, 1, 0);
if (OB_UNLIKELY(!ATOMIC_BCAS(&once_, 1, 0))) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("unexpected error, once_ should be 1", K(ret));
}
} else {
instance_ = instance;
(void)ATOMIC_BCAS(&once_, 1, 2);
if (OB_UNLIKELY(!ATOMIC_BCAS(&once_, 1, 2))) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("unexpected error, once_ should be 1", K(ret));
}
}
} else {
(void)ATOMIC_BCAS(&once_, 1, 0);
if(OB_UNLIKELY(!ATOMIC_BCAS(&once_, 1, 0))) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("unexpected error, once_ should be 1", K(ret));
}
}
}
}
......@@ -268,7 +278,8 @@ ObTableQuerySyncP::ObTableQuerySyncP(const ObGlobalContext &gctx)
result_row_count_(0),
query_session_id_(0),
allocator_(ObModIds::TABLE_PROC),
query_session_(nullptr)
query_session_(nullptr),
timeout_ts_(0)
{}
int ObTableQuerySyncP::deserialize()
......@@ -562,19 +573,24 @@ int ObTableQuerySyncP::try_process()
int ObTableQuerySyncP::destory_query_session(bool need_rollback_trans)
{
int ret = OB_SUCCESS;
if (OB_FAIL(end_trans(need_rollback_trans, req_, timeout_ts_))) {
LOG_WARN("failed to end trans", K(ret), K(need_rollback_trans));
}
int tmp_ret = ret;
ObQuerySyncMgr::get_instance().get_locker(query_session_id_).lock();
if (OB_ISNULL(query_session_) || OB_ISNULL(table_service_ctx_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("Unexpected null value", K(ret), K(query_session_), K(table_service_ctx_));
LOG_WARN("Unexpected null value", K(ret), KP_(query_session), KP_(table_service_ctx));
} else if (OB_FAIL(ObQuerySyncMgr::get_instance().get_query_session_map()->erase_refactored(query_session_id_))) {
LOG_WARN("fail to erase query session from query sync mgr", K(ret));
} else {
table_service_ctx_->destroy_result_iterator(part_service_);
end_trans(need_rollback_trans, req_, timeout_ts_);
OB_DELETE(ObTableQuerySyncSession, ObModIds::TABLE_PROC, query_session_);
LOG_DEBUG("destory query session success", K(ret), K(query_session_id_), K(need_rollback_trans));
}
ObQuerySyncMgr::get_instance().get_locker(query_session_id_).unlock();
ret = (OB_SUCCESS == ret) ? tmp_ret : ret;
return ret;
}
......
......@@ -550,7 +550,7 @@ int ObTableApiProcessorBase::end_trans(bool is_rollback, rpc::ObRequest *req, in
if (trans_state_ptr_->is_start_participant_executed() && trans_state_ptr_->is_start_participant_success()) {
if (OB_SUCCESS != (end_ret = part_service_->end_participant(
is_rollback, *trans_desc_ptr_, participants_ptr_->get_partitions()))) {
ret = (OB_SUCCESS == ret) ? end_ret : ret;
ret = end_ret;
LOG_WARN("fail to end participant", K(ret), K(end_ret),
K(is_rollback));
}
......@@ -705,7 +705,7 @@ static int set_audit_name(const char *info_name, char *&audit_name, int64_t &aud
ret = OB_ALLOCATE_MEMORY_FAILED;
SERVER_LOG(WARN, "fail to alloc memory", K(ret), K(buf_size));
} else {
strcpy(buf, info_name);
strncpy(buf, info_name, buf_size);
audit_name = buf;
audit_name_length = name_length;
}
......@@ -773,17 +773,18 @@ void ObTableApiProcessorBase::end_audit()
// append request string to query_sql
if (NULL != request_string_ && request_string_len_ > 0) {
static const char request_print_prefix[] = ", \nrequest: ";
const int64_t buf_size = audit_record_.sql_len_ + sizeof(request_print_prefix) + request_string_len_;
const int64_t request_print_prefix_size = sizeof(request_print_prefix);
const int64_t buf_size = audit_record_.sql_len_ + request_print_prefix_size + request_string_len_;
char *buf = reinterpret_cast<char *>(audit_allocator_.alloc(buf_size));
if (NULL == buf) {
SERVER_LOG(WARN, "fail to alloc audit memory", K(buf_size), K(audit_record_.sql_), K(request_string_));
} else {
memset(buf, 0, buf_size);
if (OB_NOT_NULL(audit_record_.sql_)) {
strcat(buf, audit_record_.sql_);
strncat(buf, audit_record_.sql_, audit_record_.sql_len_);
}
strcat(buf, request_print_prefix);
strcat(buf, request_string_);
strncat(buf, request_print_prefix, request_print_prefix_size);
strncat(buf, request_string_, request_string_len_);
audit_record_.sql_ = buf;
audit_record_.sql_len_ = buf_size;
}
......@@ -1594,12 +1595,15 @@ int ObHTableIncrementExecutor::add_to_results(table::ObTableQueryResult &results
objs[1] = cq;
objs[2] = ts;
int64_t timestamp = 0;
objs[2].get_int(timestamp);
objs[2].set_int(-timestamp); // negate_htable_timestamp
objs[3] = value;
common::ObNewRow row(objs, 4);
if (OB_FAIL(results.add_row(row))) { // deep copy
LOG_WARN("failed to add row to results", K(ret), K(row));
if (OB_FAIL(objs[2].get_int(timestamp))) {
LOG_WARN("failed to get int from object", K(ret));
} else {
objs[2].set_int(-timestamp); // negate_htable_timestamp
objs[3] = value;
common::ObNewRow row(objs, 4);
if (OB_FAIL(results.add_row(row))) { // deep copy
LOG_WARN("failed to add row to results", K(ret), K(row));
}
}
}
return ret;
......
......@@ -2117,7 +2117,10 @@ int ObTableService::execute_query(ObTableServiceQueryCtx &ctx, const ObTableQuer
} else {
if (query.get_htable_filter().is_valid()) {
ctx.htable_result_iterator_->set_scan_result(ctx.scan_result_);
if (p_hcolumn_desc->get_time_to_live() > 0) {
if (OB_ISNULL(p_hcolumn_desc)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null p_hcolumn_desc", K(ret));
} else if (p_hcolumn_desc->get_time_to_live() > 0) {
ctx.htable_result_iterator_->set_ttl(p_hcolumn_desc->get_time_to_live());
}
} else {
......
......@@ -87,7 +87,7 @@ class ObTableOperationRequest final
OB_UNIS_VERSION(1);
public:
ObTableOperationRequest() : credential_(), table_name_(), table_id_(common::OB_INVALID_ID),
partition_id_(common::OB_INVALID_ID), entity_type_(), table_operation_(),
partition_id_(common::OB_INVALID_ID), entity_type_(ObTableEntityType::ET_DYNAMIC), table_operation_(),
consistency_level_(), returning_rowkey_(false), returning_affected_entity_(false),
returning_affected_rows_(false),
binlog_row_image_type_(ObBinlogRowImageType::FULL)
......@@ -137,7 +137,7 @@ class ObTableBatchOperationRequest final
OB_UNIS_VERSION(1);
public:
ObTableBatchOperationRequest() : credential_(), table_name_(), table_id_(common::OB_INVALID_ID),
partition_id_(common::OB_INVALID_ID), entity_type_(), batch_operation_(),
partition_id_(common::OB_INVALID_ID), entity_type_(ObTableEntityType::ET_DYNAMIC), batch_operation_(),
consistency_level_(), returning_rowkey_(false), returning_affected_entity_(false),
returning_affected_rows_(false),
binlog_row_image_type_(ObBinlogRowImageType::FULL)
......@@ -223,6 +223,7 @@ public:
ObTableQueryAndMutateRequest()
:table_id_(common::OB_INVALID_ID),
partition_id_(common::OB_INVALID_ID),
entity_type_(ObTableEntityType::ET_DYNAMIC),
binlog_row_image_type_(ObBinlogRowImageType::FULL)
{}
TO_STRING_KV("credential", common::ObHexStringWrap(credential_),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册