[SCN REFACTOR] replace flash back snapshot and remove read snapshot session

This commit is contained in:
wangt1xiuyi 2022-11-28 01:54:50 +00:00 committed by ob-robot
parent c4c13f6296
commit 11485d6a98
268 changed files with 6763 additions and 7737 deletions

1
.gitignore vendored
View File

@ -323,3 +323,4 @@ tools/deploy/single.yaml
tools/ob-configserver/bin/*
tools/ob-configserver/tests/*.log
tools/ob-configserver/tests/*.out
.history/*

View File

@ -30,6 +30,7 @@
http://www.python.org/*
https://oracle.github.io/*
https://en.wikipedia.org/wiki/*
http://en.wikipedia.org/wiki/*
https://mariadb.com/*
https://github.com/akopytov/sysbench*
http://foo.bar.com*
@ -125,6 +126,59 @@
https://github.com/jsteemann/atoi
https://tools.ietf.org/html/rfc1951
hewei@mail.ied.ac.cn
http://trade.taobao.com/trade/*
http://buy.tmall.com/order/*
http://unit.buyer.trade.taobao.com/trade/*
http://abc.com/*
https://oceanbase.slack.com/
https://ask.oceanbase.com/
https://cdn.nlark.com/yuque/*
https://h5.dingtalk.com/circle/*
https://gw.alipayobjects.com/*
http://yum-test.obvos.alibaba-inc.com/*
http://yum.tbsite.net/taobao/*
https://www.cnblogs.com/*
http://murmurhash.googlepages.com/
rbrown64@csc.com.au
http://bazaar.launchpad.net/*
http://stackoverflow.com/*
https://cloud.tencent.com/*
http://k3.alibaba-inc.com/*
libecb@schmorp.de
http://software.schmorp.de/*
http://www-01.ibm.com/*
http://msdn.microsoft.com/*
http://www.open-std.org/*
http://forums.freebsd.org/*
http://www.ussg.indiana.edu/*
https://www.qqxiuzi.cn/daohang.htm
https://blog.csdn.net/*
https://es5.github.io/*
http://rapidjson.org/*
https://tools.ietf.org/*
https://github.com/madler/zlib/*
http://www.zlib.net
http://www.oberhumer.com/*
http://www.quicklz.com/
http://www.goof.com/*
http://www.fastlz.org/*
http://baike.corp.taobao.com/*
http://gitlab.alibaba-inc.com/*
https://gerry.lamost.org/*
https://www.techonthenet.com/oracle/*
http://review.alibaba-inc.com/*
https://gw.alicdn.com/*
http://docs.oracle.com/*
https://oracle-base.com/*
https://www.kernel.org/doc/*
https://www.atatech.org/*
http://oceanbase.alibaba-inc.com/*
https://community.oracle.com/tech/*
https://docs.docker.com/*
http://helloworld.com/*
http://1.1.1.1:8080/*
https://mirrors.aliyun.com/*
https://bixense.com/clicolors/
**/Doxyfile
www.doxygen.org)
https://www.gnu.org/software/libiconv/
@ -146,8 +200,9 @@
http://docs.mathjax.org/en/latest/output.html)
https://www.mathjax.org
https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/.
https://issues.apache.org/*
https://www.atatech.org/*
**/*.result
http://trade.taobao.com/trade/*
https://workitem.aone.alibaba-inc.com/*
http://oracle.chinaitlab.com*
http://bugfree.corp.taobao.com*
@ -385,9 +440,10 @@
/tools/codestyle/**
/src/objit/deps/googletest/**
/.git/**
/deps/oblib/src/lib/compress/**
--------------------------------------------------------
# Config the ignored fold to escape the Chinese scan by GLOB wildcard
--------------------------------------------------------
# Set md5 of pemFile string to filter
# This section must be end up with '--------------------------------------------------------'!!!
--------------------------------------------------------
--------------------------------------------------------

View File

@ -1,138 +0,0 @@
# 以下代码目录或者文件,只属于商业版,不属于开源社区版
# 本文件的目录pattern格式与CODEOWNERS相同
# 开源裁剪方案参考: https://yuque.antfin-inc.com/docs/share/a24792b6-95f7-4a44-89cb-dd5f9bc59a58?#
#deps part
deps/oblib/src/lib/xml/**
deps/reasy
deps/oblib/src/lib/oracleclient
#source part
src/sql/parser/sql_parser_oracle_mode.l
src/sql/parser/sql_parser_oracle_mode.y
src/share/inner_table/sys_package/catodci.sql
src/share/inner_table/sys_package/dbms_any.sql
src/share/inner_table/sys_package/dbms_any_body.sql
src/share/inner_table/sys_package/dbms_application.sql
src/share/inner_table/sys_package/dbms_application_body.sql
src/share/inner_table/sys_package/dbms_audit_mgmt.sql
src/share/inner_table/sys_package/dbms_audit_mgmt_body.sql
src/share/inner_table/sys_package/dbms_crypto.sql
src/share/inner_table/sys_package/dbms_crypto_body.sql
src/share/inner_table/sys_package/dbms_debug.sql
src/share/inner_table/sys_package/dbms_debug_body.sql
src/share/inner_table/sys_package/dbms_describe.sql
src/share/inner_table/sys_package/dbms_describe_body.sql
src/share/inner_table/sys_package/dbms_errlog.sql
src/share/inner_table/sys_package/dbms_errlog_body.sql
src/share/inner_table/sys_package/dbms_ijob.sql
src/share/inner_table/sys_package/dbms_ijob_body.sql
src/share/inner_table/sys_package/dbms_ischeduler.sql
src/share/inner_table/sys_package/dbms_ischeduler_body.sql
src/share/inner_table/sys_package/dbms_job.sql
src/share/inner_table/sys_package/dbms_job_body.sql
src/share/inner_table/sys_package/dbms_lob.sql
src/share/inner_table/sys_package/dbms_lob_body.sql
src/share/inner_table/sys_package/dbms_lock.sql
src/share/inner_table/sys_package/dbms_lock_body.sql
src/share/inner_table/sys_package/dbms_metadata.sql
src/share/inner_table/sys_package/dbms_metadata_body.sql
src/share/inner_table/sys_package/dbms_monitor.sql
src/share/inner_table/sys_package/dbms_monitor_body.sql
src/share/inner_table/sys_package/dbms_output.sql
src/share/inner_table/sys_package/dbms_output_body.sql
src/share/inner_table/sys_package/dbms_plancache.sql
src/share/inner_table/sys_package/dbms_plancache_body.sql
src/share/inner_table/sys_package/dbms_preprocessor.sql
src/share/inner_table/sys_package/dbms_preprocessor_body.sql
src/share/inner_table/sys_package/dbms_random.sql
src/share/inner_table/sys_package/dbms_random_body.sql
src/share/inner_table/sys_package/dbms_resource_manager.sql
src/share/inner_table/sys_package/dbms_resource_manager_body.sql
src/share/inner_table/sys_package/dbms_scheduler.sql
src/share/inner_table/sys_package/dbms_scheduler_body.sql
src/share/inner_table/sys_package/dbms_session.sql
src/share/inner_table/sys_package/dbms_session_body.sql
src/share/inner_table/sys_package/dbms_spm.sql
src/share/inner_table/sys_package/dbms_spm_body.sql
src/share/inner_table/sys_package/dbms_spm_mysql.sql
src/share/inner_table/sys_package/dbms_spm_body_mysql.sql
src/share/inner_table/sys_package/dbms_sql.sql
src/share/inner_table/sys_package/dbms_sql_body.sql
src/share/inner_table/sys_package/dbms_standard.sql
src/share/inner_table/sys_package/dbms_stats.sql
src/share/inner_table/sys_package/dbms_stats_body.sql
src/share/inner_table/sys_package/dbms_sys_error.sql
src/share/inner_table/sys_package/dbms_sys_error_body.sql
src/share/inner_table/sys_package/dbms_utility.sql
src/share/inner_table/sys_package/dbms_utility_body.sql
src/share/inner_table/sys_package/dbms_utl_encode.sql
src/share/inner_table/sys_package/dbms_utl_encode_body.sql
src/share/inner_table/sys_package/dbms_warning.sql
src/share/inner_table/sys_package/dbms_warning_body.sql
src/share/inner_table/sys_package/dbms_xa.sql
src/share/inner_table/sys_package/dbms_xa_body.sql
src/share/inner_table/sys_package/odciconst.sql
src/share/inner_table/sys_package/sa_components.sql
src/share/inner_table/sys_package/sa_components_body.sql
src/share/inner_table/sys_package/sa_label_admin.sql
src/share/inner_table/sys_package/sa_label_admin_body.sql
src/share/inner_table/sys_package/sa_policy_admin.sql
src/share/inner_table/sys_package/sa_policy_admin_body.sql
src/share/inner_table/sys_package/sa_session.sql
src/share/inner_table/sys_package/sa_session_body.sql
src/share/inner_table/sys_package/sa_sysdba.sql
src/share/inner_table/sys_package/sa_sysdba_body.sql
src/share/inner_table/sys_package/sa_user_admin.sql
src/share/inner_table/sys_package/sa_user_admin_body.sql
src/share/inner_table/sys_package/utl_file.sql
src/share/inner_table/sys_package/utl_file_body.sql
src/share/inner_table/sys_package/utl_i18n.sql
src/share/inner_table/sys_package/utl_i18n_body.sql
src/share/inner_table/sys_package/utl_inaddr.sql
src/share/inner_table/sys_package/utl_inaddr_body.sql
src/share/inner_table/sys_package/utl_raw.sql
src/share/inner_table/sys_package/utl_raw_body.sql
src/share/inner_table/sys_package/utlpwdmg.sql
src/share/inner_table/sys_package/xml_type.sql
src/share/inner_table/sys_package/xml_type_body.sql
src/logservice/libobcdc/tests/conf
#tool
tools/agentserver
tools/codestyle
tools/ob_bench
tools/obmeter
tools/obproxy
tools/obtest
tools/script
tools/upgrade/README.md
tools/ob_admin/log_miner
#script
script/backup_restore
script/ha
script/supervisor
script/deploy
script/remove_old_branches.pl
script/tpcc_create_table_3zone.sql
script/obstat
#rpm part
rpm/oceanbase-build.sh
rpm/oceanbase-cdc-build.sh
#other part
hotfuncs.txt
observer.prof
test
mittest
gdb-macros
asan_ignore_list.txt
CODEOWNERS
INSTALL
.akfarm
.aone.yml
.akconfig
.ak_scan_switch
.obdev

View File

@ -3,12 +3,6 @@ cmake_minimum_required(VERSION 3.20)
include(cmake/Utils.cmake)
include(cmake/Env.cmake)
#project(OceanBase
# VERSION 4.0.0.0
# DESCRIPTION "OceanBase distributed database system"
# HOMEPAGE_URL "http://oceanbase.alipay.com"
# LANGUAGES CXX C ASM)
project("OceanBase_CE"
VERSION 4.0.0.0
DESCRIPTION "OceanBase distributed database system"

3
NEWS
View File

@ -1,3 +0,0 @@
1.0 will be released.
Kick MySQL's ass.
perf_dev merged into master

View File

@ -1707,14 +1707,6 @@ static int easy_ssl_dhparam(easy_ssl_ctx_t *ssl, char *file)
DH *dh;
BIO *bio;
/*
* -----BEGIN DH PARAMETERS-----
* MIGHAoGBALu8LcrYRnSQfEP89YDpz9vZWKP1aLQtSwju1OsPs1BMbAMCducQgAxc
* y7qokiYUxb7spWWl/fHSh6K8BJvmd4Bg6RqSp1fjBI9osHb302zI8pul34HcLKcl
* 7OZicMyaUDXYzs7vnqAnSmOrHlj6/UmI0PZdFGdX2gcd8EXP4WubAgEC
* -----END DH PARAMETERS-----
*/
static unsigned char dh1024_p[] = {
0xBB, 0xBC, 0x2D, 0xCA, 0xD8, 0x46, 0x74, 0x90, 0x7C, 0x43, 0xFC, 0xF5,
0x80, 0xE9, 0xCF, 0xDB, 0xD9, 0x58, 0xA3, 0xF5, 0x68, 0xB4, 0x2D, 0x4B,
@ -1782,19 +1774,6 @@ static int easy_ssl_dhparam_mysql(easy_ssl_ctx_t *ssl)
{
DH *dh;
/*
Diffie-Hellman key.
Generated using: >openssl dhparam -5 -C 2048
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAil36wGZ2TmH6ysA3V1xtP4MKofXx5n88xq/aiybmGnReZMviCPEJ
46+7VCktl/RZ5iaDH1XNG1dVQmznt9pu2G3usU+k1/VB4bQL4ZgW4u0Wzxh9PyXD
glm99I9Xyj4Z5PVE4MyAsxCRGA1kWQpD9/zKAegUBPLNqSo886Uqg9hmn8ksyU9E
BV5eAEciCuawh6V0O+Sj/C3cSfLhgA0GcXp3OqlmcDu6jS5gWjn3LdP1U0duVxMB
h/neTSCSvtce4CAMYMjKNVh9P1nu+2d9ZH2Od2xhRIqMTfAS1KTqF3VmSWzPFCjG
mjxx/bg6bOOjpgZapvB6ABWlWmRmAAWFtwIBBQ==
-----END DH PARAMETERS-----
*/
static unsigned char dh2048_p[]=
{
0x8A, 0x5D, 0xFA, 0xC0, 0x66, 0x76, 0x4E, 0x61, 0xFA, 0xCA, 0xC0, 0x37,

View File

@ -1,4 +1 @@
This is a common library for OceanBase project.
lib code clone from http://gitlab.alibaba-inc.com/oceanbase/oceanbase/commits/master : c1e9d22c09fcbee932f50a026c8084c826734036
2016-10-29 22:19:33

View File

@ -65,7 +65,7 @@ int ObStoreFormat::find_row_store_type(const ObString &row_store, ObRowStoreType
}
if (!is_row_store_type_valid(row_store_type)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("Unexpected row store type", K(row_store_type), K(row_store), K(ret));
LOG_WARN("Unexpected row store type", K(row_store_type), K(row_store), K(ret));
}
}
@ -85,7 +85,7 @@ int ObStoreFormat::find_store_format_type(const ObString &store_format,
} else if (!(OB_STORE_FORMAT_INVALID < start && start <= OB_STORE_FORMAT_MAX)
|| !(OB_STORE_FORMAT_INVALID < end && end <= OB_STORE_FORMAT_MAX)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("Unexpected store format type", K(start), K(end), K(ret));
LOG_WARN("Unexpected store format type", K(start), K(end), K(ret));
} else {
for (int64_t i = start; i < end && !is_store_format_valid(store_format_type); i++) {
if (0 == store_format.case_compare(get_store_format_name(static_cast<ObStoreFormatType> (i)))) {
@ -94,7 +94,7 @@ int ObStoreFormat::find_store_format_type(const ObString &store_format,
}
if (!is_store_format_valid(store_format_type)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("Unexpected store format type", K(store_format), K(store_format_type), K(ret));
LOG_WARN("Unexpected store format type", K(store_format), K(store_format_type), K(ret));
}
}

View File

@ -104,6 +104,10 @@ public:
{
return ht_.size();
}
int64_t bucket_count() const
{
return ht_.get_bucket_count();
}
bool empty() const
{
return 0 == ht_.size();

View File

@ -1331,6 +1331,8 @@ public:
return size_;
}
int64_t get_bucket_count() const { return bucket_num_; }
public:
template<class _archive>
int serialization(_archive &archive)

View File

@ -1936,7 +1936,7 @@ int ObIJsonBase::to_number(ObIAllocator *allocator, number::ObNumber &number) co
int ObIJsonBase::to_datetime(int64_t &value) const
{
INIT_SUCC(ret);
int64_t datetime;
int64_t datetime = 0;
switch (json_type()) {
case ObJsonNodeType::J_DATETIME:
@ -1985,7 +1985,7 @@ int ObIJsonBase::to_datetime(int64_t &value) const
int ObIJsonBase::to_date(int32_t &value) const
{
INIT_SUCC(ret);
int32_t date;
int32_t date = 0;
switch (json_type()) {
case ObJsonNodeType::J_DATETIME:
@ -2032,7 +2032,7 @@ int ObIJsonBase::to_date(int32_t &value) const
int ObIJsonBase::to_time(int64_t &value) const
{
INIT_SUCC(ret);
int64_t time;
int64_t time = 0;
switch (json_type()) {
case ObJsonNodeType::J_TIME: {
@ -2077,7 +2077,7 @@ int ObIJsonBase::to_time(int64_t &value) const
int ObIJsonBase::to_bit(uint64_t &value) const
{
INIT_SUCC(ret);
uint64_t bit;
uint64_t bit = 0;
const ObJsonNodeType j_type = json_type();
ObDTMode dt_mode = 0;

View File

@ -2398,7 +2398,7 @@ int ObJsonBin::rebuild_with_meta(const char *data, uint64_t length, ObJsonBuffer
old_val_entry += key_entry_size * count;
}
uint64_t new_val_entry_offset;
uint64_t new_val_entry_offset = 0;
if (OB_FAIL(result.append(reinterpret_cast<const char*>(&new_header), OB_JSON_BIN_HEADER_LEN))) {
LOG_WARN("failed to append header", K(ret));
} else if (OB_FAIL(ObJsonVar::append_var(count, new_header.count_size_, result))) {
@ -2840,7 +2840,7 @@ int ObJsonBin::insert_internal_v0(ObJBNodeMeta& meta, int64_t pos, const ObStrin
meta_len += key_entry_size * count;
}
uint64_t new_val_entry_offset;
uint64_t new_val_entry_offset = 0;
if (OB_FAIL(result.reserve(meta.obj_size_))) {
LOG_WARN("failed to reserve mem", K(ret), K(meta.obj_size_));
} else if (OB_FAIL(result.append(reinterpret_cast<const char*>(&new_header), OB_JSON_BIN_HEADER_LEN))) {
@ -3300,7 +3300,7 @@ int ObJsonBin::remove_v0(size_t index)
ObJsonNodeType node_type = this->json_type();
ObJBVerType ver_type = this->get_vertype();
// 1. move into element index, get used bytes
uint64_t used_bytes;
uint64_t used_bytes = 0;
if (OB_FAIL(this->element(index))) {
LOG_WARN("failed to get element ", K(index), K(ret));
} else {

View File

@ -119,7 +119,7 @@ int ObBucketLock::try_wrlock(const uint64_t bucket_idx)
return ret;
}
int ObBucketLock::rdlock(const uint64_t bucket_idx)
int ObBucketLock::rdlock(const uint64_t bucket_idx, const int64_t abs_timeout_us)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!is_inited_)) {
@ -128,13 +128,13 @@ int ObBucketLock::rdlock(const uint64_t bucket_idx)
} else if(OB_UNLIKELY(bucket_idx >= bucket_cnt_)) {
ret = OB_INVALID_ARGUMENT;
COMMON_LOG(WARN, "Invalid argument, ", K(bucket_idx), K_(bucket_cnt), K(ret));
} else if (OB_FAIL(latches_[bucket_to_latch_idx(bucket_idx)].rdlock(latch_id_))) {
COMMON_LOG(WARN, "Fail to read lock latch, ", K(bucket_idx), K_(latch_id), K(ret));
} else if (OB_FAIL(latches_[bucket_to_latch_idx(bucket_idx)].rdlock(latch_id_, abs_timeout_us))) {
COMMON_LOG(WARN, "Fail to read lock latch, ", K(bucket_idx), K_(latch_id), K(abs_timeout_us), K(ret));
}
return ret;
}
int ObBucketLock::wrlock(const uint64_t bucket_idx)
int ObBucketLock::wrlock(const uint64_t bucket_idx, const int64_t abs_timeout_us)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!is_inited_)) {
@ -143,8 +143,8 @@ int ObBucketLock::wrlock(const uint64_t bucket_idx)
} else if(OB_UNLIKELY(bucket_idx >= bucket_cnt_)) {
ret = OB_INVALID_ARGUMENT;
COMMON_LOG(ERROR, "Invalid argument, ", K(bucket_idx), K_(bucket_cnt), K(ret));
} else if (OB_FAIL(latches_[bucket_to_latch_idx(bucket_idx)].wrlock(latch_id_))) {
COMMON_LOG(WARN, "Fail to write lock latch, ", K(bucket_idx), K_(latch_id), K(ret));
} else if (OB_FAIL(latches_[bucket_to_latch_idx(bucket_idx)].wrlock(latch_id_, abs_timeout_us))) {
COMMON_LOG(WARN, "Fail to write lock latch, ", K(bucket_idx), K_(latch_id), K(abs_timeout_us), K(ret));
}
return ret;
}

View File

@ -34,8 +34,8 @@ public:
void destroy();
int try_rdlock(const uint64_t bucket_idx);
int try_wrlock(const uint64_t bucket_idx);
int rdlock(const uint64_t bucket_idx);
int wrlock(const uint64_t bucket_idx);
int rdlock(const uint64_t bucket_idx, const int64_t abs_timeout_us = INT64_MAX);
int wrlock(const uint64_t bucket_idx, const int64_t abs_timeout_us = INT64_MAX);
int unlock(const uint64_t bucket_idx);
int try_wrlock_all();
int try_rdlock_all();

View File

@ -27,7 +27,6 @@ class MySQLResultWrapper
{
public:
//see this for template virtual function
//http://cxh.me/2014/07/01/nvi-usage-of-virtual-template/
DEFINE_ALLOCATOR_WRAPPER
MySQLResultWrapper() {}
virtual ~MySQLResultWrapper() {}

View File

@ -118,7 +118,6 @@ int ObMySQLConnection::connect(const char *user, const char *pass, const char *d
const static int MAX_IP_BUFFER_LEN = 32;
char host[MAX_IP_BUFFER_LEN];
host[0] = '\0';
// https://baike.baidu.com/item/mysql_real_connect/4007597
// if db is NULL, the default database is used.
if (OB_ISNULL(user) || OB_ISNULL(pass) /*|| OB_ISNULL(db)*/) {
ret = OB_INVALID_ARGUMENT;

View File

@ -161,9 +161,9 @@ int ObMySQLConnectionPool::set_db_param(const char *db_user, const char *db_pass
} else if (OB_UNLIKELY(w_len <= 0) || OB_UNLIKELY(w_len > OB_MAX_USER_NAME_LENGTH)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("fill db user error", KCSTRING(db_user), K(ret));
} else if (FALSE_IT(w_len = snprintf(db_pass_, OB_MAX_PASS_WORD_LENGTH, "%s", db_pass))) {
} else if (FALSE_IT(w_len = snprintf(db_pass_, OB_MAX_PASSWORD_BUF_LENGTH, "%s", db_pass))) {
// impossible
} else if (OB_UNLIKELY(w_len < 0) || OB_UNLIKELY(w_len >= OB_MAX_PASS_WORD_LENGTH)) {
} else if (OB_UNLIKELY(w_len < 0) || OB_UNLIKELY(w_len >= OB_MAX_PASSWORD_BUF_LENGTH)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("fill db password error", KCSTRING(db_pass), K(ret));
} else if (FALSE_IT(w_len = snprintf(db_name_, OB_MAX_DATABASE_NAME_BUF_LENGTH, "%s", db_name))) {
@ -180,7 +180,7 @@ int ObMySQLConnectionPool::set_db_param(const ObString &db_user, const ObString
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(db_user.length() > OB_MAX_USER_NAME_LENGTH)
|| OB_UNLIKELY(db_pass.length() > OB_MAX_PASS_WORD_LENGTH)
|| OB_UNLIKELY(db_pass.length() > OB_MAX_PASSWORD_LENGTH)
|| OB_UNLIKELY(db_name.length() > OB_MAX_DATABASE_NAME_LENGTH)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("db param buffer is not enough", K(db_user), K(db_pass), K(db_name), K(ret));

View File

@ -207,7 +207,6 @@ private:
int get_server_pool_(const ObAddr &addr, ObServerConnectionPool *&pool);
int purge_tenant_server_pool_map_(const ObIArray<uint64_t> &tenant_array);
protected:
static const int64_t OB_MAX_PASS_WORD_LENGTH = 64;
static const int MAX_SERVER_GONE_INTERVAL = 1000 * 1000 * 1; // 1 sec
bool is_updated_;
@ -221,7 +220,7 @@ protected:
volatile int64_t busy_conn_count_;
char db_user_[OB_MAX_USER_NAME_BUF_LENGTH];
char db_pass_[OB_MAX_PASS_WORD_LENGTH];
char db_pass_[OB_MAX_PASSWORD_BUF_LENGTH];
char db_name_[OB_MAX_DATABASE_NAME_BUF_LENGTH];
char init_sql_[OB_MAX_SQL_LENGTH];
ObConnPoolConfigParam config_;

View File

@ -108,7 +108,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", "column_name", #column_name); \
SQL_LOG(TRACE, "null value, ignore", "column_name", #column_name); \
(obj).set_##column_name(default_value); \
ret = OB_SUCCESS; \
} \
@ -152,7 +152,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", K(column_name)); \
SQL_LOG(TRACE, "null value, ignore", K(column_name)); \
field = static_cast<type>(default_value); \
ret = OB_SUCCESS; \
} \
@ -298,7 +298,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", "column_name", #column_name); \
SQL_LOG(TRACE, "null value, ignore", "column_name", #column_name); \
(obj).set_##column_name(static_cast<type>(default_value)); \
ret = OB_SUCCESS; \
} \
@ -361,7 +361,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", "column_name", #column_name); \
SQL_LOG(TRACE, "null value, ignore", "column_name", #column_name); \
(obj).set_##column_name(static_cast<type>(default_value)); \
ret = OB_SUCCESS; \
} \
@ -452,7 +452,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", "column_name", #column_name); \
SQL_LOG(TRACE, "null value, ignore", "column_name", #column_name); \
(obj).set_##column_name(static_cast<type>(default_value)); \
ret = OB_SUCCESS; \
} \
@ -651,7 +651,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", "column_name", #column_name); \
SQL_LOG(TRACE, "null value, ignore", "column_name", #column_name); \
ret = OB_SUCCESS; \
} \
else \
@ -719,7 +719,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", "column_name", #column_name); \
SQL_LOG(TRACE, "null value, ignore", "column_name", #column_name); \
ret = OB_SUCCESS; \
} \
else \
@ -834,7 +834,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", "column_name", #column_name); \
SQL_LOG(TRACE, "null value, ignore", "column_name", #column_name); \
ret = OB_SUCCESS; \
} \
else \
@ -1061,7 +1061,7 @@
if (OB_ERR_NULL_VALUE == ret \
|| OB_SIZE_OVERFLOW == ret \
|| OB_INVALID_ARGUMENT == ret) { \
SQL_LOG(WARN, "get column failed, so set default value", K(ret), "obj", #obj); \
SQL_LOG(TRACE, "get column failed, so set default value", K(ret), "obj", #obj); \
ret = OB_SUCCESS; \
obj = default_value; \
} else { \
@ -1146,7 +1146,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", "column_name", #column_name); \
SQL_LOG(TRACE, "null value, ignore", "column_name", #column_name); \
(obj).set_##column_name(static_cast<uint64_t>(default_value)); \
ret = OB_SUCCESS; \
} \
@ -1187,7 +1187,7 @@
{ \
if (skip_null_error) \
{ \
SQL_LOG(INFO, "null value, ignore", "column_name", #column_name); \
SQL_LOG(TRACE, "null value, ignore", "column_name", #column_name); \
(obj).set_##column_name(static_cast<uint64_t>(default_value)); \
ret = OB_SUCCESS; \
} \
@ -1258,7 +1258,6 @@ class ObMySQLResult
{
public:
//see this for template virtual function
//http://cxh.me/2014/07/01/nvi-usage-of-virtual-template/
DEFINE_ALLOCATOR_WRAPPER
ObMySQLResult();
virtual ~ObMySQLResult();

View File

@ -202,7 +202,6 @@ int ObServerConnectionPool::init_dblink(uint64_t dblink_id, const ObAddr &server
cluster_str.length(), cluster_str.ptr());
}
(void)snprintf(db_pass_, sizeof(db_pass_), "%.*s", db_pass.length(), db_pass.ptr());
// https://baike.baidu.com/item/mysql_real_connect/4007597
// if db is NULL, the default database is used.
if (!db_name.empty()) {
(void)snprintf(db_name_, sizeof(db_name_), "%.*s", db_name.length(), db_name.ptr());

View File

@ -309,6 +309,7 @@ const int64_t OB_SERVER_TYPE_LENGTH = 64;
const int64_t OB_MAX_HOSTNAME_LENGTH = 60;
const int64_t OB_MAX_USERNAME_LENGTH = 32;
const int64_t OB_MAX_PASSWORD_LENGTH = 128;
const int64_t OB_MAX_PASSWORD_BUF_LENGTH = OB_MAX_PASSWORD_LENGTH + 1;
// After each sha1 is 41 characters, the incremental backup is up to 64 times, and the maximum password required for recovery is 64*(41+1)=2,688
const int64_t OB_MAX_PASSWORD_ARRAY_LENGTH = 4096;
const int64_t OB_MAX_ERROR_MSG_LEN = 512;

View File

@ -407,24 +407,13 @@ public:
return blk_size;
}
static ObFixedClassAllocator<T> *get(const lib::ObLabel &label = common::ObModIds::OB_CONCURRENCY_OBJ_POOL)
static ObFixedClassAllocator<T> *get(const char* label = "ConcurObjPool")
{
ObFixedClassAllocator<T> *instance = NULL;
while (OB_UNLIKELY(once_ < 2)) {
if (ATOMIC_BCAS(&once_, 0, 1)) {
instance = new (std::nothrow) ObFixedClassAllocator(sizeof(T),
ObMemAttr(common::OB_SERVER_TENANT_ID, label),
choose_blk_size(sizeof(T)),
common::get_cpu_count());
if (OB_LIKELY(NULL != instance)) {
instance_ = instance;
(void)ATOMIC_BCAS(&once_, 1, 2);
} else {
(void)ATOMIC_BCAS(&once_, 1, 0);
}
}
}
return (ObFixedClassAllocator<T> *)instance_;
static ObFixedClassAllocator<T> instance(sizeof(T),
ObMemAttr(common::OB_SERVER_TENANT_ID, label),
choose_blk_size(sizeof(T)),
common::get_cpu_count());
return &instance;
}
void *alloc()
@ -441,10 +430,6 @@ public:
}
}
protected:
static volatile int64_t once_;
static volatile ObFixedClassAllocator<T> *instance_;
private:
ObSliceAlloc allocator_;
};
@ -735,10 +720,6 @@ template<class T>
volatile int64_t ObClassAllocator<T>::once_ = 0;
template<class T>
volatile ObClassAllocator<T> *ObClassAllocator<T>::instance_ = NULL;
template<class T>
volatile int64_t ObFixedClassAllocator<T>::once_ = 0;
template<class T>
volatile ObFixedClassAllocator<T> *ObFixedClassAllocator<T>::instance_ = NULL;
template <class T>
struct OPNum
@ -832,7 +813,7 @@ inline void call_destructor(T *ptr) {
({ \
type *ret = NULL; \
common::ObFixedClassAllocator<type> *instance = \
common::ObFixedClassAllocator<type>::get(common::OPNum<type>::LABEL); \
common::ObFixedClassAllocator<type>::get(#type); \
if (OB_LIKELY(NULL != instance)) { \
void *tmp = instance->alloc(); \
if (OB_LIKELY(NULL != tmp)) { \
@ -847,7 +828,7 @@ inline void call_destructor(T *ptr) {
OLD_STATIC_ASSERT((std::is_default_constructible<type>::value), "type is not default constructible"); \
type *ret = NULL; \
common::ObFixedClassAllocator<type> *instance = \
common::ObFixedClassAllocator<type>::get(common::OPNum<type>::LABEL); \
common::ObFixedClassAllocator<type>::get(#type); \
if (OB_LIKELY(NULL != instance)) { \
void *tmp = instance->alloc(); \
if (OB_LIKELY(NULL != tmp)) { \
@ -860,7 +841,7 @@ inline void call_destructor(T *ptr) {
#define op_free(ptr) \
({ \
common::ObFixedClassAllocator<__typeof__(*ptr)> *instance = \
common::ObFixedClassAllocator<__typeof__(*ptr)>::get(common::OPNum<__typeof__(*ptr)>::LABEL); \
common::ObFixedClassAllocator<__typeof__(*ptr)>::get(); \
if (OB_LIKELY(NULL != instance)) { \
instance->free(ptr); \
} \

View File

@ -383,6 +383,7 @@ int ObLogger::set_probe(char *str)
auto &probe = probes_[probe_cnt_++];
probe.action_ = action;
strncpy(probe.file_, file, sizeof probe.file_);
probe.file_[sizeof probe.file_ - 1] = '\0';
probe.line_ = atoi(line);
char location[256];
snprintf(location, sizeof location, "%s:%s", file, line);

View File

@ -1113,6 +1113,8 @@ inline void ObLogger::do_log_message(const bool is_async,
Function &log_data_func)
{
int ret = OB_SUCCESS;
bool old_val = set_disable_logging(true);
DEFER(set_disable_logging(old_val));
bool allow = true;
bool force_bt = false;

View File

@ -55,7 +55,6 @@ private:
// COS domain name structure: bucket_name-appid.endpoint
// For example https://bucket-appid.cos.ap-guangzhou.myqcloud.com,
// cos.ap-guangzhou.myqcloud.com is the endpoint.
struct OB_PUBLIC_API ObCosAccount
{

View File

@ -234,9 +234,8 @@ int ObObjectDevice::open_for_appender(const char *pathname, ObIODOpts *opts, voi
OB_LOG(WARN, "Invalid append strategy!", KCSTRING(append_strategy), K(ret));
}
param.strategy_ = strategy;
param.version_param_.version_ = append_version;
if (-1 != append_version) {
param.version_param_.version_ = append_version;
param.version_param_.open_object_version_ = true;
if (param.version_param_.version_ <= 0) {
ret = OB_INVALID_ARGUMENT;

View File

@ -130,7 +130,9 @@ void close_socket_fd()
}
DLOG(INFO, "[CLOSEFD], close socket fd finish");
}
if (NULL != dir) {
closedir(dir);
}
}

View File

@ -135,6 +135,9 @@ void iter_task(Func &&cb, int exclude_tid, Args && ... args)
}
} while (nread > 0);
}
if (fd >= 0) {
::close(fd);
}
}
ObSignalWorker::ObSignalWorker()

View File

@ -39,14 +39,15 @@ public:
inline int divide()
{
int ret = OB_SUCCESS;
if (nullptr != str_) {
const char *p = str_;
int64_t word_length = 0;
words_.reset();
while(0 != *p) {
if (' ' == *p) {
if (0 != word_length) {
words_.push_back(ObString(word_length, p - word_length));
if (0 != word_length && OB_FAIL(words_.push_back(ObString(word_length, p - word_length)))) {
COMMON_LOG(WARN, "failed to push back word", K(ret), K(word_length));
}
word_length = 0;
} else {
@ -54,12 +55,12 @@ public:
}
++p;
}
if (0 != word_length) {
words_.push_back(ObString(word_length, p - word_length));
if (0 != word_length && OB_FAIL(words_.push_back(ObString(word_length, p - word_length)))) {
COMMON_LOG(WARN, "failed to push back word", K(ret), K(word_length));
}
}
count_ = words_.size();
return OB_SUCCESS;
return ret;
}
inline ObString &operator[](const int64_t idx) {return words_[idx];}

View File

@ -72,7 +72,6 @@ inline uint32_t ob_fast_digits10(uint64_t v)
/*
* The idea comes from the talk by Alexandrescu "Three Optimization Tips for C++".
* https://m.facebook.com/notes/facebook-engineering/three-optimization-tips-for-c/10151361643253920/?__tn__=H-R
* faster then databuff_print for 20~4 times(digits from 1~20), 20~7 times(digits from 1~9),
*
* usage:

View File

@ -1194,7 +1194,8 @@ static int read_pid(const char *pidfile, long &pid)
pid = strtol(buf, NULL, 10);
}
if (fd > 0) {
// POSIX file descriptors are non-negative integers.
if (fd >= 0) {
close(fd);
}

View File

@ -462,8 +462,8 @@ int ObReqTransport::post_session(easy_session_t *s) const
easy_addr_t ObReqTransport::to_ez_addr(const ObAddr &addr) const
{
easy_addr_t ez;
memset(&ez, 0, sizeof (ez));
if (addr.is_valid()) {
memset(&ez, 0, sizeof (ez));
ez.port = (htons)(static_cast<uint16_t>(addr.get_port()));
ez.cidx = 0;
if (addr.using_ipv4()) {

View File

@ -44,7 +44,6 @@ int ObMysqlCompressProtocolProcessor::do_decode(ObSMConnection& conn, ObICSMemPo
* 3B length of compressed payload
* 1B compressed sequence id
* 3B length of payload before compression
* http://imysql.com/mysql-internal-manual/compressed-packet-header.html
*/
uint32_t pktlen_before_compress = 0;
ObMySQLUtil::get_uint3(start, pktlen);
@ -125,7 +124,6 @@ inline int ObMysqlCompressProtocolProcessor::decode_compressed_packet(
K(pkt_body_size), K(ret));
} else {
// pktlen_before_compress==0 means do not use compress
// http://imysql.com/mysql-internal-manual/uncompressed-payload.html
if (0 == pktlen_before_compress) {
pkt_body = const_cast<char *>(comp_buf);
} else {

View File

@ -372,7 +372,6 @@ public:
* 3B length of compressed payload
* 1B compressed sequence id
* 3B length of payload before compression
* http://imysql.com/mysql-internal-manual/compressed-packet-header.html
*/
class ObMySQLCompressedPacketHeader
{

View File

@ -58,8 +58,6 @@ static int64_t get_max_comp_pkt_size(const int64_t uncomp_pkt_size)
*
* the body is compressed packet(orig header + orig body)
*
* http://imysql.com/mysql-internal-manual/compressed-packet-header.html
*
* NOTE: In standard mysql compress protocol, if src_pktlen < 50B, or compr_pktlen >= src_pktlen
* mysql will do not compress it and set pktlen_before_compression = 0,
* it can not ensure checksum.

View File

@ -33,7 +33,6 @@ OMPKChangeUser::OMPKChangeUser() : cmd_(COM_CHANGE_USER),
}
// see com_change_user packet
// http://imysql.com/mysql-internal-manual/com-change-user.html
// for proxy, add session vars as connect attrs
int64_t OMPKChangeUser::get_serialize_size() const
{

View File

@ -1,6 +1,6 @@
# Description
The latest dooba stable version is 1.0, download address: http://gitlab.alibaba-inc.com/fufeng.syd/dooba/repository/archive?ref=v1.0
The latest dooba stable version is 1.0
`dooba' is a easy tools monitoring oceanbase cluster for oceanbase admins. It's based on python curses library, and is a powerful tool for watching oceanbase cluster status with straightfoward vision.
@ -52,26 +52,33 @@ Please look into dooba script file header.
## version 1.0
### dooba offline index
![screenshot v1.0](/fufeng.syd/dooba/raw/master/screenshot/v1_0-offline.png "screenshot for dooba v1_0 offline index")
### dooba machine
![screenshot v1.0](/fufeng.syd/dooba/raw/master/screenshot/v1_0-machine.png "screenshot for dooba v1_0 machine")
### dooba help
![screenshot v1.0](/fufeng.syd/dooba/raw/master/screenshot/v1_0-help.png "screenshot for dooba v1_0 help")
## version 0.4
### dooba shell
![screenshot v0.4](/fufeng.syd/dooba/raw/master/screenshot/v0_4-shell.png "screenshot for dooba v0.2 gallery")
### dooba sql
![screenshot v0.4](/fufeng.syd/dooba/raw/master/screenshot/v0_4-sql.png "screenshot for dooba v0.2 gallery")
### dooba UpdateServer
![screenshot v0.4](/fufeng.syd/dooba/raw/master/screenshot/v0_4-ups.png "screenshot for dooba v0.2 gallery")
### dooba ChunkServer
![screenshot v0.4](/fufeng.syd/dooba/raw/master/screenshot/v0_4-cs.png "screenshot for dooba v0.2 gallery")
## version 0.2, 0.3

View File

@ -21,6 +21,7 @@
#include "logservice/palf/lsn.h" // LSN
#include "logservice/palf/scn.h" // LSN
#include "share/backup/ob_backup_connectivity.h"
#include "share/ob_debug_sync.h"
namespace oceanbase
{
@ -265,6 +266,7 @@ void ObArchiveService::do_check_switch_archive_()
int ObArchiveService::load_archive_round_attr_(ObTenantArchiveRoundAttr &attr)
{
DEBUG_SYNC(BEFORE_LOAD_ARCHIVE_ROUND);
return persist_mgr_.load_archive_round_attr(attr);
}

View File

@ -91,10 +91,9 @@ int PriorityV1::get_scn_(const share::ObLSID &ls_id, palf::SCN &scn)
COORDINATOR_LOG_(WARN, "open_palf failed");
} else if (OB_FAIL(palf_handle_guard.get_palf_handle()->get_access_mode(access_mode))) {
COORDINATOR_LOG_(WARN, "get_access_mode failed");
} else if (palf::AccessMode::APPEND != access_mode) {
// Set scn to 0 when current access mode is not APPEND.
scn.set_min();
} else {
// } else if (palf::AccessMode::APPEND != access_mode) {
// // Set log_ts to 0 when current access mode is not APPEND.
// log_ts = 0;
common::ObRole role;
int64_t unused_pid = -1;
palf::SCN min_unreplay_scn;

View File

@ -713,7 +713,6 @@ int ObCDCPartTransResolver::handle_commit_(
transaction::ObTxCommitLogTempRef tmp_ref;
transaction::ObTxCommitLog commit_log(tmp_ref);
PartTransTask *part_trans_task = NULL;
PartTransTask::CDCTransType trans_type = PartTransTask::CDCTransType::UNKNOWN;
int64_t trans_commit_version = OB_INVALID_VERSION;
bool is_redo_complete = false;
is_served = false;
@ -725,7 +724,7 @@ int ObCDCPartTransResolver::handle_commit_(
KR(ret), K_(tls_id), K(tx_id), K(lsn), K(missing_info));
} else if (OB_FAIL(tx_log_block.deserialize_log_body(commit_log))) {
LOG_ERROR("deserialize_log_body failed", KR(ret), K_(tls_id), K(tx_id), K(lsn), K(commit_log));
} else if (OB_UNLIKELY(!is_valid_trans_type_(commit_log.get_trans_type(), trans_type))) {
} else if (OB_UNLIKELY(!is_valid_trans_type_(commit_log.get_trans_type()))) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("invalid trans_type", KR(ret), K_(tls_id), K(tx_id), K(commit_log), K(lsn));
} else if (OB_UNLIKELY(OB_INVALID_VERSION ==
@ -734,7 +733,7 @@ int ObCDCPartTransResolver::handle_commit_(
LOG_ERROR("invalid trans_commit_version", KR(ret), K_(tls_id), K(tx_id), K(lsn), K(submit_ts), K(commit_log));
} else if (!serve_info.is_served(trans_commit_version)) {
LOG_WARN("found trans not served", K_(tls_id), K(tx_id), K(lsn),
K(commit_log), K(trans_type), K(serve_info));
K(commit_log), K(serve_info));
if (OB_FAIL(part_trans_dispatcher_.remove_task(tls_id_.is_sys_log_stream(), tx_id))) {
LOG_ERROR("handle unserverd PartTransTask failed", KR(ret), K_(tls_id), K(tx_id));
}
@ -783,7 +782,7 @@ int ObCDCPartTransResolver::handle_commit_(
LOG_ERROR("unexpected found redo log entry not complete if have read commit_info log", KR(ret),
K_(tls_id), K(tx_id), K(commit_log), K(lsn), KPC(part_trans_task));
} else if (OB_UNLIKELY(part_trans_task->is_sys_ls_not_serve_trans())
&& PartTransTask::CDCTransType::SINGLE_LS_TRANS == trans_type) {
&& transaction::TransType::SP_TRANS == commit_log.get_trans_type()) {
// remove part_trans_task if is single_sys_logstream trans but not has valid MultiDataSourceInfo(means not DDL/LS_TABLE_CHANGE/TABLET_CHANGE)
LOG_DEBUG("[FILTER_PART_TRANS] sys_ls_trans without valid multi_data_source_info(not ddl/ls_table or tablet_change)",
K_(tls_id), K(tx_id), K(commit_log), KPC(part_trans_task));
@ -791,16 +790,16 @@ int ObCDCPartTransResolver::handle_commit_(
LOG_ERROR("handle unserverd single CommitLog(commit_log with invalid prev_log_lsn in dist_trans) failed",
KR(ret), K_(tls_id), K(tx_id), K(commit_log), K(lsn));
}
} else if (PartTransTask::CDCTransType::SINGLE_LS_TRANS == trans_type
} else if (transaction::TransType::SP_TRANS == commit_log.get_trans_type()
&& OB_FAIL(part_trans_task->prepare(lsn, submit_ts, part_trans_dispatcher_))) {
// prepare single_ls_trans while resolving its commit_log.
LOG_ERROR("prepare part_trans_task for single_ls_trans failed", KR(ret), K_(tls_id), K(tx_id), K(trans_type),
LOG_ERROR("prepare part_trans_task for single_ls_trans failed", KR(ret), K_(tls_id), K(tx_id),
K(lsn), K(submit_ts), K(commit_log), KPC(part_trans_task));
} else if (OB_FAIL(part_trans_task->commit(
cluster_id,
tx_id,
trans_commit_version,
trans_type,
(transaction::TransType)commit_log.get_trans_type(),
commit_log.get_ls_log_info_arr(),
lsn,
submit_ts))) {
@ -947,22 +946,5 @@ int ObCDCPartTransResolver::check_redo_log_list_(
return ret;
}
bool ObCDCPartTransResolver::is_valid_trans_type_(
const int32_t trans_type_int,
PartTransTask::CDCTransType &trans_type) const
{
bool b_ret = false;
if (transaction::TransType::SP_TRANS == trans_type_int) {
b_ret = true;
trans_type = PartTransTask::CDCTransType::SINGLE_LS_TRANS;
} else if (transaction::TransType::DIST_TRANS == trans_type_int) {
b_ret = true;
trans_type = PartTransTask::CDCTransType::DIST_TRANS;
}
return b_ret;
}
} // end namespace cdc
} // end namespace oceanbase

View File

@ -378,9 +378,10 @@ private:
PartTransTask &part_trans_task,
MissingLogInfo &missing_info);
bool is_valid_trans_type_(
const int32_t trans_type_int,
PartTransTask::CDCTransType &trans_type) const;
inline bool is_valid_trans_type_(const int32_t trans_type) const
{
return transaction::TransType::SP_TRANS == trans_type || transaction::TransType::DIST_TRANS == trans_type;
}
// trans_commit_version of single LS trans is log submit_ts, otherwise is trans_commit_version recorded in trans_log.
inline int64_t get_trans_commit_version_(const int64_t commit_log_submit_ts, const int64_t commit_version_in_tx_log) const
@ -389,10 +390,6 @@ private:
commit_log_submit_ts : commit_version_in_tx_log;
}
int check_and_handle_not_served_sys_ls_trans_(
PartTransTask &part_trans_task,
const PartTransTask::CDCTransType &trans_type);
private:
bool offlined_ CACHE_ALIGNED; // Is the partition deleted
TenantLSID tls_id_;

View File

@ -2028,7 +2028,7 @@ PartTransTask::PartTransTask() :
prepare_log_lsn_(),
commit_ts_(OB_INVALID_TIMESTAMP),
commit_log_lsn_(),
trans_type_(CDCTransType::UNKNOWN),
trans_type_(transaction::TransType::UNKNOWN_TRANS),
is_xa_or_dup_(false),
participant_count_(0),
participants_(NULL),
@ -2162,7 +2162,7 @@ void PartTransTask::reset()
prepare_log_lsn_.reset();
commit_ts_ = OB_INVALID_TIMESTAMP;
commit_log_lsn_.reset();
trans_type_ = CDCTransType::UNKNOWN;
trans_type_ = transaction::TransType::UNKNOWN_TRANS;
is_xa_or_dup_ = false;
participant_count_ = 0;
participants_ = NULL;
@ -2723,7 +2723,7 @@ int PartTransTask::commit(
const uint64_t cluster_id,
const transaction::ObTransID &tx_id,
const int64_t trans_commit_version,
const CDCTransType &trans_type,
const transaction::TransType &trans_type,
const transaction::ObLSLogInfoArray &ls_info_array,
const palf::LSN &commit_log_lsn,
const int64_t commit_log_submit_ts)

View File

@ -716,13 +716,6 @@ struct TransCommitInfo;
class PartTransTask : public TransTaskBase<PartTransTask>, public ObLogResourceRecycleTask, public ObILogCallback
{
public:
// TODO, 需要替换为事务层统一定义的结构
enum CDCTransType
{
UNKNOWN = -1,
SINGLE_LS_TRANS = 0,
DIST_TRANS = 1
};
enum TaskType
{
TASK_TYPE_UNKNOWN = 0,
@ -817,7 +810,7 @@ public:
const uint64_t cluster_id,
const transaction::ObTransID &tx_id,
const int64_t trans_commit_version,
const CDCTransType &trans_type,
const transaction::TransType &trans_type,
const transaction::ObLSLogInfoArray &ls_info_array,
const palf::LSN &commit_log_lsn,
const int64_t commit_log_submit_ts);
@ -1017,8 +1010,8 @@ public:
const ObString &get_part_trans_info() const { return part_trans_info_str_; }
bool is_served() const { return SERVED == serve_state_; }
bool is_single_ls_trans() const { return CDCTransType::SINGLE_LS_TRANS == trans_type_; }
bool is_dist_trans() const { return CDCTransType::DIST_TRANS == trans_type_; }
bool is_single_ls_trans() const { return transaction::TransType::SP_TRANS == trans_type_; }
bool is_dist_trans() const { return transaction::TransType::DIST_TRANS == trans_type_; }
void is_part_trans_sort_finish() const { sorted_redo_list_.is_dml_stmt_iter_end(); }
bool is_part_dispatch_finish() const { return sorted_redo_list_.is_dispatch_finish(); }
void inc_sorted_br() { ATOMIC_INC(&output_br_count_by_turn_); }
@ -1089,7 +1082,7 @@ public:
K_(exec_tenant_id),
K_(tls_id),
K_(trans_id),
K_(trans_type),
"trans_type", transaction::trans_type_to_cstr(trans_type_),
K_(is_xa_or_dup),
K_(is_trans_committed),
K_(trans_commit_version),
@ -1188,7 +1181,7 @@ private:
palf::LSN prepare_log_lsn_; // PrepareLog LSN(same with commit_log_lsn_ if SINGLE_LS_TRANS)
int64_t commit_ts_; // Transaction timestamp, usually set to the Commit log timestamp
palf::LSN commit_log_lsn_; // CommitLog LSN
CDCTransType trans_type_;
transaction::TransType trans_type_;
bool is_xa_or_dup_; // true if xa dist trans or duplicate table trans.
int64_t participant_count_;

View File

@ -1,19 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDAzCCAeugAwIBAgIBATANBgkqhkiG9w0BAQsFADA8MTowOAYDVQQDDDFNeVNR
TF9TZXJ2ZXJfNS43LjI0X0F1dG9fR2VuZXJhdGVkX0NBX0NlcnRpZmljYXRlMB4X
DTE5MDQyOTA5MDc1NVoXDTI5MDQyNjA5MDc1NVowPDE6MDgGA1UEAwwxTXlTUUxf
U2VydmVyXzUuNy4yNF9BdXRvX0dlbmVyYXRlZF9DQV9DZXJ0aWZpY2F0ZTCCASIw
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALjwNXZC8Tr9kndc6WheAsynLxs2
wqRhpIqASTH25xVS50F151VM8QeoTpPLYSNx7Iy+grQ6R8b0aSpF8lqav3Op/VVz
zAePtcNthoDBcqDoI0pgS/mbYYagjCnDeWFA37Gm3iPf417aWa8ngC2JLHcArjx8
9m1EPp917/owdIo/xLUYkTsyZkKc5IWBx8368/UaILEwdK7yBVHcc4zpKSeRTAIh
q8oUMT4MJ6E5WSbFyLI3ooc3WuXPpkDkC3+pcPszs2lgyWZSnpmFMo/STnK/WERA
YXOZur76Sd21YhuO0tYaVa1RcMFUbru08ECGz2dnMYgn4WsjyqwaZDmLXwUCAwEA
AaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEABGpcpi40J4n1
Swa3+VYgdlmXExM2boJjR+Yl9v367aT6FM0cxnPrnHZiWaAOnuTMkuimsPpRxzb4
yj9aix/fTMBhxu5KJ/EIovT3tBWvWbFjdTqRe9NCZ8ALyweWzfixu9A4cFbs6HfK
aBjZtnIl4rPGXhryjSdBWIVBRnIaIuVzAmFHu/To0Ws6UPelhCcLdI7LtwpyX1wd
lcob5pEfy2vsoS5F/bMCIXXvXTkFWPvQAOGkndSV3IxPY0Vxc1JUxB74WTPIO2+q
hREu1LTlmuISUKhWtAQjhsXUyufPUKPGZW/VhpsQecrSjv5HN3B2DW56en9ZejbK
vde8+i/gFg==
-----END CERTIFICATE-----

View File

@ -1,19 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDBDCCAeygAwIBAgIBAzANBgkqhkiG9w0BAQsFADA8MTowOAYDVQQDDDFNeVNR
TF9TZXJ2ZXJfNS43LjI0X0F1dG9fR2VuZXJhdGVkX0NBX0NlcnRpZmljYXRlMB4X
DTE5MDQyOTA5MDc1NVoXDTI5MDQyNjA5MDc1NVowQDE+MDwGA1UEAww1TXlTUUxf
U2VydmVyXzUuNy4yNF9BdXRvX0dlbmVyYXRlZF9DbGllbnRfQ2VydGlmaWNhdGUw
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDBe+87EmlgsUJscpOW4fm9
pW/ZFDRUcPQxBdKZMFVy2p8uW7sXEQ+wHZhRgemnBdT4kYmGSfMLJAlrzYe6HjKJ
8t/3RH90f0qjmdlM4f5jRoU74fPG2rpG+UxklR26DAsbPCd/wnQtDUzG6zO1yj53
6xa7veRNXMBg/N9wUSw1oGab2H9/6EkfC4JmXNVcSZ75Nxtg08g2OGYwH+rsV5NZ
yydxoYkizbM8aIR27F96QaeAlZf/oZ5mjcAeIgdzhQMJi9njU71YLvktnhDpQGwo
utALQYWcUyJfH8or23u+A+WjHRd9wnsvl3Ea+lqg2fmBzwTxmkXOE42QnKc6OshJ
AgMBAAGjDTALMAkGA1UdEwQCMAAwDQYJKoZIhvcNAQELBQADggEBACbNmYOhrLbD
elG0GOHzwVjPmOZewHfVs4l9TEpEliZedRWuIOWq0wPqf5NrimAhYjUBfMmns1/Y
xbl4XO/s7ma/qXmKvXF2aHMK1YU5zvsJUc8vm62x8GmMDuaqnsltGiS4jorOZ5wh
Fgd4GenkASy7XE/MLEuZwpKGfZQ4rm7KKh1XRVfCfz7PlZuCKKEwT2dOwjKe7S+y
5NeWeiDUa2mfkWdrNocExa2USHlgvxplSsFxjJlbP3Fl2EvS15Ke1vLALcPHR8ZV
UYGO0yuNZY6aT9vODB7eEDSAa76X8h6cKmNB2edKALfQDZuGkDWObhtc/hmuCNsK
QbZq3sMaA9Q=
-----END CERTIFICATE-----

View File

@ -1,27 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAwXvvOxJpYLFCbHKTluH5vaVv2RQ0VHD0MQXSmTBVctqfLlu7
FxEPsB2YUYHppwXU+JGJhknzCyQJa82Huh4yifLf90R/dH9Ko5nZTOH+Y0aFO+Hz
xtq6RvlMZJUdugwLGzwnf8J0LQ1Mxusztco+d+sWu73kTVzAYPzfcFEsNaBmm9h/
f+hJHwuCZlzVXEme+TcbYNPINjhmMB/q7FeTWcsncaGJIs2zPGiEduxfekGngJWX
/6GeZo3AHiIHc4UDCYvZ41O9WC75LZ4Q6UBsKLrQC0GFnFMiXx/KK9t7vgPlox0X
fcJ7L5dxGvpaoNn5gc8E8ZpFzhONkJynOjrISQIDAQABAoIBADwkHNl8wJqYnq/8
8VleBnXnfZu5RwbUUWMHj02kk3ru77nGM6JY4Ep6+ISlYA5VprxY6KmARPa6jd8f
dMfqaQUuJGXEueVpR7cQtFXMjXkoS3OwqUivZmV3SkKdgy74XV9q1FBHDjuOvcW7
CEjCg6ZcwaU7wkI1yWqcT4um/5nvJbwGb/LCcgsl82iI83MyZ6Ese1sDVVZ53aza
XLEsO8MmdGCHFQsRhx+EVnrZQZprMEvKQJTbtJHLt8LrLk4K6jzwlJqyyD/+byeX
uMw/TdI8xWFiTzn4fZgPQSJvQ6gMoZ1zl0bf9540wI1j4EhfS72PHqMo8afzvFB+
SEDt7zECgYEA9tfgM/tNk2ZB3QhhKLdksilAZ5bb9MLDvfwIoiMhklPM9E2sJj/4
6Y3fgASE8RcfCK2kXV0jwFRPPfPt3iXejMKdHDOMHnKXTfi7V/afZJRN5O/879Kc
WNfLsn52trJJ8cvWQAEX8aVOhdxfhjDHrAb+APnYNCQJ5olzOy9Kym0CgYEAyKlW
qPm1znib0fLFP1XjWANfl2gdGE6us5rs4HYoSCJ0SL4/vMM0q7WN5+rvs2id9JSn
aBAImbnrpeJvXHKeh16vr6IjzKfa9mtG00nRGNo6ILo69rmx3dE2CunMMauF9Hfd
yTe71e6dO7IqG+cMJ/G9GDJs8Xgaw+Qn0RC0C80CgYBnQgDY3dwit9j/dFzoYmcu
HBGEA9h5N+wYElEuOhH2GzYWUFOeII6obJ+89qcCD1D9GV4zbB3je6E2Yk7z6dWB
/nsoa+vGZNskU9NSxakBswQuq7GcRPcANy1PupVAca57BnDWj16LyEHjvz76bHdq
X/ZrRBiMHzNBC+h3Lp5TtQKBgBbR0y4iP7+8TZQhtLbQMKuIrq1MRMrH3+xC+R9J
sKkLagf/wsXXuTyxx/KQ8DOJ+TSgVy1pbWD2GMtjpeBwlIC2juo9WS7kA+20I3jR
0zqtTqD8LMp0MbsVGL1C+1rGs9QqcYl5kh3xJeZtC4bizqoYPrXqviLz0q9mWfTX
nnIdAoGBAJZq5xvDiCmO1rrg9s6cwGRU/3Hoe/GR1iJWBbpPzP9/ACTXoWP7/QHU
WL3OcvgKJlwC9c0yP79fCt0pHK8DSbeoABwgFC/YFwGxoHm2t+Bb6tSdDnHizRUr
oalDqfereEjKxfg7TkwRzQ4dgHUag4+pcGggDjGdH1tNdWQQLO+N
-----END RSA PRIVATE KEY-----

View File

@ -177,7 +177,7 @@ int LogIteratorImpl<ENTRY>::init(IteratorStorage *log_storage)
log_storage_ = log_storage;
curr_entry_size_ = 0;
is_inited_ = true;
PALF_LOG(INFO, "LogIteratorImpl init success", K(ret), KPC(this));
PALF_LOG(TRACE, "LogIteratorImpl init success", K(ret), KPC(this));
}
return ret;
}

View File

@ -718,14 +718,9 @@ int PalfEnvImpl::try_recycle_blocks()
}
}
// step3. notify each palf instance stop writing when reach limit usage threshold.
// step3. reset diskspace_enough_.
if (diskspace_enough_ != curr_diskspace_enough) {
if (OB_FAIL(notify_diskspace_enough_(curr_diskspace_enough))) {
PALF_LOG(WARN, "notify_diskspace_enough_ failed", K(ret), KPC(this),
K(usable_disk_limit_size_to_stop_writing), K(total_used_size_byte));
} else {
diskspace_enough_ = curr_diskspace_enough;
}
ATOMIC_STORE(&diskspace_enough_, curr_diskspace_enough);
}
if ((true == need_recycle && false == has_recycled && false == is_shrinking) || false == diskspace_enough_) {
PALF_LOG(ERROR, "clog disk space is almost full",
@ -747,26 +742,7 @@ int PalfEnvImpl::try_recycle_blocks()
bool PalfEnvImpl::check_disk_space_enough()
{
int ret = OB_SUCCESS;
bool bool_ret = true;
int64_t total_used_disk_space = 0;
int64_t total_size_byte = 0;
if (OB_FAIL(get_disk_usage(total_used_disk_space, total_size_byte))) {
PALF_LOG(WARN, "get_disk_usage failed", K(ret), KPC(this));
} else {
PalfDiskOptions disk_opts_for_stopping_writing;
PalfDiskOptions disk_opts_for_recycling_blocks;
PalfDiskOptionsWrapper::Status status = PalfDiskOptionsWrapper::Status::INVALID_STATUS;
disk_options_wrapper_.get_disk_opts(disk_opts_for_stopping_writing,
disk_opts_for_recycling_blocks,
status);
const int64_t usable_limit_disk_size =
total_size_byte * disk_opts_for_stopping_writing.log_disk_utilization_limit_threshold_ / 100LL;
if (usable_limit_disk_size < total_used_disk_space) {
bool_ret = false;
}
}
return bool_ret;
return true == ATOMIC_LOAD(&diskspace_enough_);
}
// TODO by yunlong
@ -803,25 +779,6 @@ bool PalfEnvImpl::GetTotalUsedDiskSpace::operator() (const LSKey &ls_key, PalfHa
return bool_ret;
}
PalfEnvImpl::NotifyDiskEnough::NotifyDiskEnough(const bool diskspace_enough)
: diskspace_enough_(diskspace_enough),
ret_code_(OB_SUCCESS) {}
PalfEnvImpl::NotifyDiskEnough::~NotifyDiskEnough() {}
bool PalfEnvImpl::NotifyDiskEnough::operator()(const LSKey &palf_id, PalfHandleImpl *palf_handle_impl)
{
bool bool_ret = true;
if (NULL == palf_handle_impl) {
ret_code_ = OB_ERR_UNEXPECTED;
bool_ret = false;
} else {
(void) palf_handle_impl->set_diskspace_enough(diskspace_enough_);
PALF_LOG(WARN, "NotifyDiskEnough execute", K(palf_id), K(palf_handle_impl));
}
return bool_ret;
}
int PalfEnvImpl::get_disk_usage(int64_t &used_size_byte, int64_t &total_usable_size_byte)
{
int ret = OB_SUCCESS;
@ -1051,18 +1008,6 @@ int PalfEnvImpl::recycle_blocks_(bool &has_recycled, int64_t &oldest_palf_id, SC
return ret;
}
int PalfEnvImpl::notify_diskspace_enough_(const bool diskspace_enough)
{
int ret = OB_SUCCESS;
NotifyDiskEnough functor(diskspace_enough);
if (OB_FAIL(palf_handle_impl_map_.for_each(functor))) {
PALF_LOG(WARN, "palf_handle_impl_map_ for_each failed", K(ret), K(functor));
} else {
PALF_LOG(INFO, "notify_diskspace_enough_ success", K(ret), K(diskspace_enough), KPC(this));
}
return ret;
}
int PalfEnvImpl::wait_until_reference_count_to_zero_(const int64_t palf_id)
{
int ret = OB_SUCCESS;

View File

@ -271,15 +271,6 @@ private:
int64_t palf_id_;
int ret_code_;
};
struct NotifyDiskEnough
{
NotifyDiskEnough(const bool diskspace_enough);
~NotifyDiskEnough();
bool operator()(const LSKey &palf_id, PalfHandleImpl *palf_handle_impl);
TO_STRING_KV(K_(diskspace_enough), K_(ret_code));
bool diskspace_enough_;
int ret_code_;
};
private:
int scan_all_palf_handle_impl_director_();
@ -293,7 +284,6 @@ private:
int64_t &palf_id,
int64_t &maximum_used_size);
int recycle_blocks_(bool &has_recycled, int64_t &oldest_palf_id, SCN &oldest_scn);
int notify_diskspace_enough_(const bool diskspace_enough);
int wait_until_reference_count_to_zero_(const int64_t palf_id);
// check the diskspace whether is enough to hold a new palf instance.
bool check_can_create_palf_handle_impl_() const;

View File

@ -61,7 +61,6 @@ PalfHandleImpl::PalfHandleImpl()
last_record_append_lsn_(PALF_INITIAL_LSN_VAL),
has_set_deleted_(false),
palf_env_impl_(NULL),
diskspace_enough_(true),
append_cost_stat_("[PALF STAT WRITE LOG]", 2 * 1000 * 1000),
flush_cb_cost_stat_("[PALF STAT FLUSH CB]", 2 * 1000 * 1000),
replica_meta_lock_(),
@ -195,7 +194,6 @@ void PalfHandleImpl::destroy()
if (IS_INIT) {
PALF_EVENT("PalfHandleImpl destroy", palf_id_, KPC(this));
is_inited_ = false;
diskspace_enough_ = true;
lc_cb_ = NULL;
self_.reset();
palf_id_ = INVALID_PALF_ID;
@ -370,7 +368,7 @@ int PalfHandleImpl::submit_log(
PALF_LOG(WARN, "invalid argument", K(ret), K_(palf_id), KP(buf), K(buf_len), K(ref_scn));
} else {
RLockGuard guard(lock_);
if (false == diskspace_enough_) {
if (false == palf_env_impl_->check_disk_space_enough()) {
ret = OB_LOG_OUTOF_DISK_SPACE;
if (palf_reach_time_interval(1 * 1000 * 1000, log_disk_full_warn_time_)) {
PALF_LOG(WARN, "log outof disk space", K(ret), KPC(this), K(opts), K(ref_scn));
@ -2425,7 +2423,7 @@ int PalfHandleImpl::receive_log(const common::ObAddr &server,
} else {
// rdlock
RLockGuard guard(lock_);
if (false == diskspace_enough_) {
if (false == palf_env_impl_->check_disk_space_enough()) {
ret = OB_LOG_OUTOF_DISK_SPACE;
if (palf_reach_time_interval(1 * 1000 * 1000, log_disk_full_warn_time_)) {
PALF_LOG(WARN, "log outof disk space", K(ret), KPC(this), K(server), K(push_log_type), K(lsn));
@ -2509,7 +2507,7 @@ int PalfHandleImpl::submit_group_log(const PalfAppendOptions &opts,
while (true) {
do {
RLockGuard guard(lock_);
if (false == diskspace_enough_) {
if (false == palf_env_impl_->check_disk_space_enough()) {
ret = OB_LOG_OUTOF_DISK_SPACE;
if (palf_reach_time_interval(1 * 1000 * 1000, log_disk_full_warn_time_)) {
PALF_LOG(WARN, "log outof disk space", K(ret), KPC(this), K(opts), K(lsn));
@ -3454,11 +3452,5 @@ int PalfHandleImpl::stat(PalfStat &palf_stat)
return ret;
}
void PalfHandleImpl::set_diskspace_enough(const bool diskspace_enough)
{
WLockGuard guard(lock_);
diskspace_enough_ = diskspace_enough;
}
} // end namespace palf
} // end namespace oceanbase

View File

@ -576,7 +576,6 @@ public:
// ==================== Callback end ========================
virtual int revoke_leader(const int64_t proposal_id) = 0;
virtual int stat(PalfStat &palf_stat) = 0;
virtual void set_diskspace_enough(const bool diskspace_enough) = 0;
virtual int get_palf_epoch(int64_t &palf_epoch) const = 0;
};
@ -842,7 +841,6 @@ public:
const LogCandidateList &candidate_list,
const RegisterReturn reg_ret) override final;
int handle_learner_req(const LogLearner &server, const LogLearnerReqType req_type) override final;
void set_diskspace_enough(const bool diskspace_enough) override final;
int get_palf_epoch(int64_t &palf_epoch) const;
TO_STRING_KV(K_(palf_id), K_(self), K_(has_set_deleted));
private:
@ -1006,7 +1004,6 @@ private:
// NB: only set has_set_deleted_ to true when this palf_handle has been deleted.
bool has_set_deleted_;
PalfEnvImpl *palf_env_impl_;
bool diskspace_enough_;
ObMiniStat::ObStatItem append_cost_stat_;
ObMiniStat::ObStatItem flush_cb_cost_stat_;
// a spin lock for read/write replica_meta mutex

View File

@ -37,7 +37,7 @@ public:
} else if (OB_FAIL(iterator_impl_.init(&iterator_storage_))) {
PALF_LOG(WARN, "PalfIterator init failed", K(ret));
} else {
PALF_LOG(INFO, "PalfIterator init success", K(ret), K(start_offset), KPC(this));
PALF_LOG(TRACE, "PalfIterator init success", K(ret), K(start_offset), KPC(this));
is_inited_ = true;
}
return ret;

View File

@ -111,7 +111,7 @@ public:
int get_restore_sync_scn(const share::ObLSID &id, palf::SCN &log_scn);
void mark_error(share::ObTaskId &trace_id, const int ret_code);
int get_restore_error(share::ObTaskId &trace_id, int &ret_code, bool &error_exist);
TO_STRING_KV(K_(is_inited), K_(is_in_stop_state), K_(id), K_(proposal_id), K_(role), KPC_(parent), K_(context));
TO_STRING_KV(K_(is_inited), K_(is_in_stop_state), K_(id), K_(proposal_id), K_(role), KP_(parent), K_(context));
private:
bool is_valid() const;

View File

@ -1138,6 +1138,8 @@ typedef enum ObItemType
T_INDEX_HINT,
T_NO_INDEX_HINT,
T_FULL_HINT,
T_USE_DAS_HINT,
T_NO_USE_DAS_HINT,
T_USE_MERGE,
T_USE_HASH,
T_NO_USE_HASH,

View File

@ -677,6 +677,7 @@ int ObDBMSSchedJobMaster::register_job(
CK (OB_LIKELY(inited_));
CK (job_info.valid());
OZ (table_operator_.check_job_timeout(job_info));
OZ (table_operator_.check_auto_drop(job_info));
if (OB_FAIL(ret)) {
} else if (job_info.is_broken() || job_info.is_running() || job_info.is_disabled()) {
execute_at = now + MIN_SCHEDULER_INTERVAL;

View File

@ -194,6 +194,21 @@ int ObDBMSSchedTableOperator::check_job_timeout(ObDBMSSchedJobInfo &job_info)
return ret;
}
int ObDBMSSchedTableOperator::check_auto_drop(ObDBMSSchedJobInfo &job_info)
{
int ret = OB_SUCCESS;
if (job_info.is_running()) {
// running job not check
} else if (ObTimeUtility::current_time() > (job_info.end_date_) &&
(true == job_info.auto_drop_)) {
OZ(update_for_end(job_info.get_tenant_id(), job_info, 0, NULL));
LOG_WARN("auto drop miss out job", K(job_info), K(ObTimeUtility::current_time()));
} else {
LOG_DEBUG("job no need to drop", K(job_info));
}
return ret;
}
int ObDBMSSchedTableOperator::check_job_can_running(int64_t tenant_id, bool &can_running)
{
int ret = OB_SUCCESS;

View File

@ -71,6 +71,9 @@ public:
int check_job_can_running(int64_t tenant_id, bool &can_running);
int check_job_timeout(ObDBMSSchedJobInfo &job_info);
int check_auto_drop(ObDBMSSchedJobInfo &job_info);
private:
DISALLOW_COPY_AND_ASSIGN(ObDBMSSchedTableOperator);

View File

@ -209,7 +209,7 @@ void ObDumpTaskGenerator::dump_memory_leak()
ob_free(buf);
}
}
if (fd > 0) {
if (fd >= 0) {
::close(fd);
}
}

View File

@ -949,7 +949,8 @@ int ObInnerSQLConnection::execute(ParamStore &params,
ObVirtualTableIteratorFactory *vt_iter_factory,
bool is_from_pl,
bool is_dynamic,
bool is_forall)
bool is_forall,
int64_t array_binding_count)
{
int ret = OB_SUCCESS;
ObExecRecord exec_record;
@ -1037,15 +1038,9 @@ int ObInnerSQLConnection::execute(ParamStore &params,
if (enable_sql_audit) {
exec_record.record_start();
}
if (is_forall) {
const ObSqlArrayObj *array_obj = NULL;
CK (params.count() > 0);
CK (params.at(0).is_ext_sql_array());
CK (OB_NOT_NULL(array_obj = reinterpret_cast<const ObSqlArrayObj*>(params.at(0).get_ext())));
if (OB_SUCC(ret)) {
res.sql_ctx().multi_stmt_item_.set_ps_mode(true);
res.sql_ctx().multi_stmt_item_.set_ab_cnt(array_obj->count_);
}
if (OB_SUCC(ret) && is_forall) {
res.sql_ctx().multi_stmt_item_.set_ps_mode(true);
res.sql_ctx().multi_stmt_item_.set_ab_cnt(array_binding_count);
}
const uint64_t tenant_id = get_session().get_effective_tenant_id();
@ -2259,7 +2254,8 @@ int ObInnerSQLConnection::execute(const uint64_t tenant_id,
ObISQLClient::ReadResult &res,
bool is_from_pl,
bool is_dynamic,
bool is_forall)
bool is_forall,
int64_t array_binding_count)
{
int ret = OB_SUCCESS;
FLTSpanGuard(inner_execute);
@ -2301,7 +2297,7 @@ int ObInnerSQLConnection::execute(const uint64_t tenant_id,
get_session().store_query_string(ps_info->get_ps_sql());
if (OB_FAIL(execute(params, read_ctx->get_result(), &read_ctx->get_vt_iter_factory(),
is_from_pl, is_dynamic, is_forall))) {
is_from_pl, is_dynamic, is_forall, array_binding_count))) {
LOG_WARN("execute sql failed", K(ret), K(tenant_id), K(stmt_id));
}
}
@ -2493,8 +2489,6 @@ int ObInnerSQLConnection::get_session_variable(const ObString &name, int64_t &va
if (!inited_) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret));
} else if (0 == name.case_compare("ob_read_snapshot_version")) { //fake system variable
val = get_session().get_read_snapshot_version();
} else if (0 == name.case_compare("tx_isolation")) {
// 隔离级别是一个varchar值
ObObj obj;
@ -2516,11 +2510,6 @@ int ObInnerSQLConnection::set_session_variable(const ObString &name, int64_t val
if (!inited_) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret));
} else if (0 == name.case_compare("ob_read_snapshot_version")) { //fake system variable
if (val > 0) {
LOG_INFO("inner sql with read snapshot version", K(name), K(val));
}
(void)get_session().set_read_snapshot_version(val);
} else if (0 == name.case_compare("ob_check_sys_variable")) { // fake system variable
if (0 == val) {
LOG_TRACE("disable inner sql check sys variable");

View File

@ -244,7 +244,8 @@ public:
common::ObISQLClient::ReadResult &res,
bool is_from_pl = false,
bool is_dynamic = false,
bool is_forall = false);
bool is_forall = false,
int64_t array_binding_count = 0);
virtual int execute(const uint64_t tenant_id, sqlclient::ObIExecutor &executor) override;
@ -333,7 +334,8 @@ private:
ObVirtualTableIteratorFactory *vt_iter_factory = NULL,
bool is_from_pl = false,
bool is_dynamic = false,
bool is_forall = false);
bool is_forall = false,
int64_t array_binding_count = 0);
int do_execute(const ParamStore &params, ObInnerSQLResult &res);
int switch_tenant(const uint64_t tenant_id);

View File

@ -1928,10 +1928,11 @@ int ObRpcRemoteWriteDDLPrepareLogP::process()
int64_t prepare_log_ts = 0;
if (OB_FAIL(sstable_redo_writer.write_prepare_log(table_key,
arg_.table_id_,
arg_.schema_version_,
arg_.execution_id_,
arg_.ddl_task_id_,
prepare_log_ts))) {
LOG_WARN("fail to remote write commit log", K(ret), K(table_key), K_(arg));
} else if (OB_FAIL(ddl_kv_mgr->ddl_prepare(arg_.start_log_ts_, prepare_log_ts, arg_.table_id_, arg_.schema_version_))) {
} else if (OB_FAIL(ddl_kv_mgr->ddl_prepare(arg_.start_log_ts_, prepare_log_ts, arg_.table_id_, arg_.execution_id_, arg_.ddl_task_id_))) {
LOG_WARN("failed to do ddl kv prepare", K(ret), K(arg_));
} else {
result_ = prepare_log_ts;

View File

@ -565,7 +565,7 @@ int ObService::calc_column_checksum_request(const obrpc::ObCalcColumnChecksumReq
LOG_WARN("error unexpected, dag scheduler must not be nullptr", KR(ret));
} else if (OB_FAIL(dag_scheduler->alloc_dag(dag))) {
STORAGE_LOG(WARN, "fail to alloc dag", KR(ret));
} else if (OB_FAIL(dag->init(arg.tenant_id_, arg.ls_id_, arg.tablet_id_, arg.calc_table_id_ == arg.target_table_id_, arg.target_table_id_, arg.schema_version_, arg.execution_id_, arg.snapshot_version_))) {
} else if (OB_FAIL(dag->init(arg.tenant_id_, arg.ls_id_, arg.tablet_id_, arg.calc_table_id_ == arg.target_table_id_, arg.target_table_id_, arg.schema_version_, arg.task_id_, arg.execution_id_, arg.snapshot_version_))) {
STORAGE_LOG(WARN, "fail to init ObUniqueCheckingDag", KR(ret));
} else if (OB_FAIL(dag->alloc_global_index_task_callback(arg.tablet_id_, arg.target_table_id_, arg.source_table_id_, arg.schema_version_, arg.task_id_, callback))) {
STORAGE_LOG(WARN, "fail to alloc global index task callback", KR(ret));

View File

@ -98,7 +98,6 @@ int ObSQLClientRetryWeak::weak_read(ReadResult &res, const uint64_t tenant_id, c
sqlclient::ObISQLConnection *conn = NULL;
int64_t old_read_consistency = 0;
ObString ob_read_consistency = ObString::make_string("ob_read_consistency");
ObString read_snapshot_version_name= ObString::make_string("ob_read_snapshot_version");
ObString tx_isolation = ObString::make_string("tx_isolation");
int64_t old_tx_isolation = 0;
int64_t read_committed = 1; // ObTransIsolation::READ_COMMITTED
@ -117,9 +116,6 @@ int ObSQLClientRetryWeak::weak_read(ReadResult &res, const uint64_t tenant_id, c
// Mandatory set to READ-COMMITTED isolation level
else if (OB_FAIL(conn->set_session_variable(tx_isolation, read_committed))) {
LOG_WARN("failed to set session variable ob_read_consistency", K(ret));
} else if (snapshot_timestamp_ > 0 &&
OB_FAIL(conn->set_session_variable(read_snapshot_version_name, snapshot_timestamp_))) {
LOG_WARN("failed to set session variable ob_read_snapshot_version", K(ret), K_(snapshot_timestamp));
} else {
if (check_sys_variable_) {
@ -149,13 +145,6 @@ int ObSQLClientRetryWeak::weak_read(ReadResult &res, const uint64_t tenant_id, c
}
ret = (OB_SUCCESS == ret) ? tmp_ret : ret;
// reset ob_read_snapshot_version
tmp_ret = conn->set_session_variable(read_snapshot_version_name, OB_INVALID_VERSION);
if (OB_SUCCESS != tmp_ret) {
LOG_WARN("failed to set session variable ob_read_snapshot_version", K(ret));
}
ret = (OB_SUCCESS == ret) ? tmp_ret : ret;
}
return ret;
}

View File

@ -578,7 +578,8 @@ int ObMultiTenant::create_tenant_without_unit(const uint64_t tenant_id,
return ret;
}
int ObMultiTenant::convert_hidden_to_real_sys_tenant(const ObUnitInfoGetter::ObTenantConfig &unit)
int ObMultiTenant::convert_hidden_to_real_sys_tenant(const ObUnitInfoGetter::ObTenantConfig &unit,
const int64_t abs_timeout_us)
{
int ret = OB_SUCCESS;
@ -590,12 +591,14 @@ int ObMultiTenant::convert_hidden_to_real_sys_tenant(const ObUnitInfoGetter::ObT
ObTenantSuperBlock new_super_block;
bool lock_succ = false;
int64_t bucket_lock_idx = -1;
int64_t lock_timeout_ts = abs_timeout_us - 3000000; // reserve 3s for converting tenant
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret));
} else if (OB_FAIL(bucket_lock_.try_wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id)))) {
LOG_WARN("fail to try_wrlock for convert_hidden_to_real_sys_tenant", K(ret), K(bucket_lock_idx));
} else if (OB_FAIL(bucket_lock_.wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id), lock_timeout_ts))) {
LOG_WARN("fail to wrlock for convert_hidden_to_real_sys_tenant", K(ret), K(bucket_lock_idx), K(lock_timeout_ts));
} else if (FALSE_IT(lock_succ = true)) {
} else if (OB_FAIL(get_tenant(tenant_id, tenant))) {
LOG_WARN("fail to get sys tenant", K(tenant_id), K(ret));
@ -622,7 +625,7 @@ int ObMultiTenant::convert_hidden_to_real_sys_tenant(const ObUnitInfoGetter::ObT
return ret;
}
int ObMultiTenant::create_tenant(const ObTenantMeta &meta, bool write_slog)
int ObMultiTenant::create_tenant(const ObTenantMeta &meta, bool write_slog, const int64_t abs_timeout_us)
{
int ret = OB_SUCCESS;
@ -635,6 +638,7 @@ int ObMultiTenant::create_tenant(const ObTenantMeta &meta, bool write_slog)
ObTenantCreateStep create_step = ObTenantCreateStep::STEP_BEGIN; // step0
bool lock_succ = false;
int64_t bucket_lock_idx = -1;
int64_t lock_timeout_ts = abs_timeout_us - 5000000; // reserve 5s for creating tenant
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
@ -645,8 +649,8 @@ int ObMultiTenant::create_tenant(const ObTenantMeta &meta, bool write_slog)
} else if (OB_ISNULL(malloc_allocator)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("malloc allocator is NULL", K(ret));
} else if (OB_FAIL(bucket_lock_.try_wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id)))) {
LOG_WARN("fail to try_wrlock for create tenant", K(ret), K(tenant_id), K(bucket_lock_idx));
} else if (OB_FAIL(bucket_lock_.wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id), lock_timeout_ts))) {
LOG_WARN("fail to wrlock for create tenant", K(ret), K(tenant_id), K(bucket_lock_idx), K(lock_timeout_ts));
} else if (FALSE_IT(lock_succ = true)) {
} else if (OB_SUCC(get_tenant(tenant_id, tenant))) {
ret = OB_TENANT_EXIST;
@ -854,7 +858,7 @@ int ObMultiTenant::update_tenant_unit(const ObUnitInfoGetter::ObTenantConfig &un
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret));
} else if (OB_FAIL(bucket_lock_.try_wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id)))) {
} else if (OB_FAIL(bucket_lock_.wrlock(bucket_lock_idx = get_tenant_lock_bucket_idx(tenant_id)))) {
LOG_WARN("fail to try_wrlock for update tenant unit", K(ret), K(tenant_id), K(bucket_lock_idx));
} else if (FALSE_IT(lock_succ = true)) {
} else if (OB_FAIL(update_tenant_unit_no_lock(unit))) {
@ -1283,13 +1287,6 @@ int ObMultiTenant::remove_tenant(const uint64_t tenant_id)
} else if (OB_FAIL(GCTX.session_mgr_->kill_tenant(tenant_id))) {
LOG_ERROR("fail to kill tenant session", K(ret), K(tenant_id));
} else {
LOG_INFO("removed_tenant begin to stop", K(tenant_id));
removed_tenant->stop();
LOG_INFO("removed_tenant begin to wait", K(tenant_id));
removed_tenant->wait();
// wait for some outstanding requests to complete, which may need to switch tenant,
// so here call try_wrlock after wait, otherwise, some req may be hang in the th_worker.
// https://work.aone.alibaba-inc.com/issue/44705579
LOG_INFO("removed_tenant begin to try wlock", K(tenant_id));
bool locked = false;
ObLDHandle handle;
@ -1305,6 +1302,10 @@ int ObMultiTenant::remove_tenant(const uint64_t tenant_id)
LOG_WARN("can't get tenant wlock to remove tenant", K(tenant_id), K(ret));
removed_tenant->lock_.ld_.print();
} else {
LOG_INFO("removed_tenant begin to stop", K(tenant_id));
removed_tenant->stop();
LOG_INFO("removed_tenant begin to wait", K(tenant_id));
removed_tenant->wait();
ObTenant *removed_tenant_tmp = nullptr;
SpinWLockGuard guard(lock_);
@ -1560,13 +1561,20 @@ int ObMultiTenant::get_tenant_with_tenant_lock(
const uint64_t tenant_id, ObLDHandle &handle, ObTenant *&tenant) const
{
SpinRLockGuard guard(lock_);
int ret = get_tenant_unsafe(tenant_id, tenant);
ObTenant *tenant_tmp = nullptr;
int ret = get_tenant_unsafe(tenant_id, tenant_tmp);
if (OB_SUCC(ret)) {
if (OB_FAIL(tenant->try_rdlock(handle)) && tenant->has_stopped()) {
// in some cases this error code is handled specially
ret = OB_IN_STOP_STATE;
LOG_WARN("fail to try rdlock tenant", K(ret), K(tenant_id));
} else if (OB_UNLIKELY(tenant->has_stopped())) {
if (OB_FAIL(tenant_tmp->try_rdlock(handle))) {
if (tenant_tmp->has_stopped()) {
// in some cases this error code is handled specially
ret = OB_IN_STOP_STATE;
LOG_WARN("fail to try rdlock tenant", K(ret), K(tenant_id));
}
} else {
// assign tenant when get rdlock succ
tenant = tenant_tmp;
}
if (OB_UNLIKELY(tenant_tmp->has_stopped())) {
LOG_WARN("get rdlock when tenant has stopped", K(tenant_id), K(lbt()));
}
}

View File

@ -99,9 +99,9 @@ public:
void destroy();
int create_hidden_sys_tenant();
int convert_hidden_to_real_sys_tenant(const share::ObUnitInfoGetter::ObTenantConfig &unit);
int convert_hidden_to_real_sys_tenant(const share::ObUnitInfoGetter::ObTenantConfig &unit, const int64_t abs_timeout_us = INT64_MAX);
int create_tenant_without_unit(const uint64_t tenant_id, const double min_cpu, const double max_cpu);
int create_tenant(const ObTenantMeta &meta, bool write_slog);
int create_tenant(const ObTenantMeta &meta, bool write_slog, const int64_t abs_timeout_us = INT64_MAX);
int update_tenant_unit(const share::ObUnitInfoGetter::ObTenantConfig &unit);
int get_tenant_unit(const uint64_t tenant_id, share::ObUnitInfoGetter::ObTenantConfig &unit);

View File

@ -157,8 +157,12 @@ int ObTenantNodeBalancer::notify_create_tenant(const obrpc::TenantServerUnitConf
const bool has_memstore = (unit.replica_type_ != REPLICA_TYPE_LOGONLY);
const int64_t create_timestamp = ObTimeUtility::current_time();
basic_tenant_unit.unit_status_ = ObUnitInfoGetter::ObUnitStatus::UNIT_NORMAL;
const int64_t create_tenant_timeout_ts = THIS_WORKER.get_timeout_ts();
if (OB_FAIL(basic_tenant_unit.init(tenant_id,
if (create_tenant_timeout_ts < create_timestamp) {
ret = OB_TIMEOUT;
LOG_WARN("notify_create_tenant has timeout", K(ret), K(create_timestamp), K(create_tenant_timeout_ts));
} else if (OB_FAIL(basic_tenant_unit.init(tenant_id,
unit.unit_id_,
ObUnitInfoGetter::ObUnitStatus::UNIT_NORMAL,
unit.unit_config_,
@ -170,19 +174,19 @@ int ObTenantNodeBalancer::notify_create_tenant(const obrpc::TenantServerUnitConf
} else if (is_user_tenant(tenant_id)
&& OB_FAIL(basic_tenant_unit.divide_meta_tenant(meta_tenant_unit))) {
LOG_WARN("divide meta tenant failed", KR(ret), K(unit), K(basic_tenant_unit));
} else if (OB_FAIL(check_new_tenant(basic_tenant_unit))) {
LOG_WARN("failed to create new tenant", KR(ret), K(basic_tenant_unit));
} else if (OB_FAIL(check_new_tenant(basic_tenant_unit, create_tenant_timeout_ts))) {
LOG_WARN("failed to create new tenant", KR(ret), K(basic_tenant_unit), K(create_tenant_timeout_ts));
} else {
ret = OB_SUCCESS;
LOG_INFO("succ to create new user tenant", KR(ret), K(unit), K(basic_tenant_unit));
LOG_INFO("succ to create new user tenant", KR(ret), K(unit), K(basic_tenant_unit), K(create_tenant_timeout_ts));
}
// create meta tenant
if (OB_SUCC(ret) && is_user_tenant(tenant_id)) {
if (OB_FAIL(check_new_tenant(meta_tenant_unit))) {
LOG_WARN("failed to create meta tenant", KR(ret), K(meta_tenant_unit));
if (OB_FAIL(check_new_tenant(meta_tenant_unit, create_tenant_timeout_ts))) {
LOG_WARN("failed to create meta tenant", KR(ret), K(meta_tenant_unit), K(create_tenant_timeout_ts));
} else {
ret = OB_SUCCESS;
LOG_INFO("succ to create meta tenant", KR(ret), K(meta_tenant_unit));
LOG_INFO("succ to create meta tenant", KR(ret), K(meta_tenant_unit), K(create_tenant_timeout_ts));
}
}
}
@ -305,7 +309,7 @@ int ObTenantNodeBalancer::check_new_tenants(TenantUnits &units)
return ret;
}
int ObTenantNodeBalancer::check_new_tenant(const ObUnitInfoGetter::ObTenantConfig &unit)
int ObTenantNodeBalancer::check_new_tenant(const ObUnitInfoGetter::ObTenantConfig &unit, const int64_t abs_timeout_us)
{
int ret = OB_SUCCESS;
@ -318,7 +322,7 @@ int ObTenantNodeBalancer::check_new_tenant(const ObUnitInfoGetter::ObTenantConfi
if (OB_SYS_TENANT_ID == tenant_id) {
if (OB_SUCC(omt_->get_tenant(tenant_id, tenant))) {
if (tenant->is_hidden()) {
if (OB_FAIL(omt_->convert_hidden_to_real_sys_tenant(unit))) {
if (OB_FAIL(omt_->convert_hidden_to_real_sys_tenant(unit, abs_timeout_us))) {
LOG_WARN("fail to create real sys tenant", K(unit));
}
} else { // is real sys tenant
@ -357,7 +361,7 @@ int ObTenantNodeBalancer::check_new_tenant(const ObUnitInfoGetter::ObTenantConfi
ObTenantSuperBlock super_block(tenant_id, false/*is_hidden*/); // empty super block
if (OB_FAIL(tenant_meta.build(unit, super_block))) {
LOG_WARN("fail to build tenant meta", K(ret));
} else if (OB_FAIL(omt_->create_tenant(tenant_meta, true/* write_slog */))) {
} else if (OB_FAIL(omt_->create_tenant(tenant_meta, true/* write_slog */, abs_timeout_us))) {
LOG_WARN("fail to create new tenant", K(ret), K(tenant_id));
}
} else if (OB_FAIL(omt_->update_tenant_unit(unit))) {

View File

@ -79,7 +79,7 @@ private:
~ObTenantNodeBalancer();
int check_new_tenants(share::TenantUnits &units);
int check_new_tenant(const share::ObUnitInfoGetter::ObTenantConfig &unit);
int check_new_tenant(const share::ObUnitInfoGetter::ObTenantConfig &unit, const int64_t abs_timeout_us = INT64_MAX);
int check_del_tenants(const share::TenantUnits &local_units, share::TenantUnits &units);
void periodically_check_tenant();
int fetch_effective_tenants(const share::TenantUnits &old_tenants, share::TenantUnits &new_tenants);

View File

@ -125,6 +125,10 @@ int ObAllVirtualSessionWait::inner_get_next_row(ObNewRow *&row)
ret = OB_ITER_END;
}
if (OB_SUCCESS == ret && session_status_.count() != 0) {
if (OB_ISNULL(event_desc) || OB_ISNULL(collect_)) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "event_desc or collect_ is NULL", K(ret), KP(event_desc), KP(collect_));
}
uint64_t cell_idx = 0;
int64_t curr_time = ObTimeUtility::current_time();
for (int64_t i = 0; OB_SUCC(ret) && i < col_count; ++i) {

View File

@ -147,9 +147,9 @@ int ObAllVirtualSessionWaitHistory::inner_get_next_row(ObNewRow *&row)
ret = OB_ITER_END;
}
if (OB_SUCCESS == ret && session_status_.count() != 0) {
if (nullptr == event_desc) {
if (OB_ISNULL(event_desc) || OB_ISNULL(collect_)) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "event_desc is NULL", K(ret));
SERVER_LOG(WARN, "event_desc or collect_ is NULL", K(ret), KP(event_desc), KP(collect_));
}
uint64_t cell_idx = 0;
double value = 0;

View File

@ -46,6 +46,8 @@ class ObTenantVirtualOutlineBase: public common::ObVirtualTableIterator
protected:
struct DBInfo
{
DBInfo() : db_name_(), is_recycle_(false) {}
common::ObString db_name_;
bool is_recycle_;
};

View File

@ -13,21 +13,10 @@
#define USING_LOG_PREFIX SERVER
#include "ob_virtual_open_cursor_table.h"
#include "lib/container/ob_array_serialization.h"
#include "share/schema/ob_schema_getter_guard.h"
#include "share/schema/ob_table_schema.h"
#include "sql/session/ob_sql_session_mgr.h"
#include "lib/oblog/ob_log_module.h"
#include "common/object/ob_object.h"
#include "observer/ob_req_time_service.h"
#include "observer/ob_server.h"
#include "lib/allocator/ob_mod_define.h"
#include "sql/plan_cache/ob_plan_cache_manager.h"
#include "sql/plan_cache/ob_plan_cache.h"
#include "sql/plan_cache/ob_plan_cache_callback.h"
#include "sql/plan_cache/ob_plan_cache_value.h"
#include "sql/plan_cache/ob_plan_cache_util.h"
#include "sql/session/ob_sql_session_info.h"
#include "sql/privilege_check/ob_ora_priv_check.h"
using namespace oceanbase::common;
using namespace oceanbase::share::schema;
@ -37,74 +26,11 @@ namespace oceanbase
{
namespace observer
{
void ObVirtualOpenCursorTable::ObEachSessionId::reset()
{
is_success_ = false;
sids_map_.destroy();
}
int ObVirtualOpenCursorTable::ObEachSessionId::init(int64_t item_cnt, ObIAllocator *allocator)
{
int ret = OB_SUCCESS;
OZ (sids_map_.create(item_cnt * 4 / 3, ObModIds::OB_HASH_BUCKET));
OX (allocator_ = allocator);
return ret;
}
bool ObVirtualOpenCursorTable::ObEachSessionId::operator()(sql::ObSQLSessionMgr::Key key,
sql::ObSQLSessionInfo *sess_info)
{
UNUSED(key);
SessionInfo vsp;
is_success_ = true;
int ret = OB_SUCCESS;
CK (OB_NOT_NULL(sess_info));
CK (OB_NOT_NULL(allocator_));
if (OB_SUCC(ret)) {
char *sql_id = nullptr;
sql::ObSQLSessionInfo::LockGuard lock_guard(sess_info->get_thread_data_lock());
if (OB_ISNULL(sql_id = reinterpret_cast<char*>(allocator_->alloc(common::OB_MAX_SQL_ID_LENGTH + 1)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
SERVER_LOG(WARN, "failed to alloc buf", K(ret));
} else if (FALSE_IT(sess_info->get_cur_sql_id(sql_id, OB_MAX_SQL_ID_LENGTH + 1))) {
} else if (sql_id[0] != '\0') {
vsp.id = sess_info->get_sessid();
vsp.addr = reinterpret_cast<uint64_t>(sess_info);
vsp.sql_id.assign(sql_id, common::OB_MAX_SQL_ID_LENGTH);
OZ (ob_write_string(*allocator_, sess_info->get_user_name(), vsp.user_name));
if (vsp.is_valid()) {
SessionInfoArray vsp_arr;
OZ (sids_map_.get_refactored(vsp.sql_id, vsp_arr));
if (OB_HASH_NOT_EXIST == ret) {
ret = OB_SUCCESS;
OZ (vsp_arr.push_back(vsp));
OZ (sids_map_.set_refactored(vsp.sql_id, vsp_arr));
} else if (OB_SUCCESS != ret) {
// do nothing
} else {
OZ (vsp_arr.push_back(vsp));
OZ (sids_map_.set_refactored(vsp.sql_id, vsp_arr, 1));
}
}
}
}
return is_success_ && (OB_SUCCESS == ret);
}
ObVirtualOpenCursorTable::ObVirtualOpenCursorTable()
: ObVirtualTableScannerIterator(),
sess_mgr_(NULL),
pcm_(NULL),
plan_id_array_idx_(0),
plan_cache_(NULL),
sess_arr_(NULL),
sess_id_array_idx_(0),
oesid_(allocator_),
tenant_id_(OB_INVALID_ID),
port_(0),
is_travs_sess_(false),
plan_id_(0)
session_mgr_(NULL),
port_(0)
{
}
@ -113,6 +39,15 @@ ObVirtualOpenCursorTable::~ObVirtualOpenCursorTable()
reset();
}
void ObVirtualOpenCursorTable::reset()
{
session_mgr_ = NULL;
ipstr_.reset();
port_ = 0;
fill_scanner_.reset();
ObVirtualTableScannerIterator::reset();
}
int ObVirtualOpenCursorTable::set_addr(const common::ObAddr &addr)
{
int ret = OB_SUCCESS;
@ -130,245 +65,337 @@ int ObVirtualOpenCursorTable::set_addr(const common::ObAddr &addr)
return ret;
}
void ObVirtualOpenCursorTable::reset()
{
sess_mgr_ = NULL;
pcm_ = NULL;
plan_id_array_idx_ = 0;
plan_cache_ = NULL;
sess_id_array_idx_ = 0;
sess_arr_ = NULL;
oesid_.reset();
tenant_id_ = OB_INVALID_ID;
ipstr_.reset();
port_ = 0;
is_travs_sess_ = false;
ObVirtualTableScannerIterator::reset();
}
int ObVirtualOpenCursorTable::inner_open()
{
int ret = OB_SUCCESS;
int64_t sess_cnt = 0;
CK (OB_NOT_NULL(allocator_));
OZ (sess_mgr_->get_session_count(sess_cnt));
OZ (oesid_.init(sess_cnt, allocator_));
OZ (sess_mgr_->for_each_session(oesid_));
if (OB_SUCC(ret)) {
// !!! 引用plan cache资源前必须加ObReqTimeGuard
ObReqTimeGuard req_timeinfo_guard;
if (OB_UNLIKELY(NULL == pcm_)) {
ret = OB_NOT_INIT;
SERVER_LOG(WARN, "pcm_ is NULL", K(ret));
} else if (OB_UNLIKELY(NULL != plan_cache_)){
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "before get_plan_cache, the point of plan_cache must be NULL", K(ret));
} else if (OB_UNLIKELY(NULL == (plan_cache_ = pcm_->get_plan_cache(tenant_id_)))) {
SERVER_LOG(WARN, "plan cache is null", K(ret));
} else {
ObGetAllPlanIdOp plan_id_op(&plan_id_array_);
if (OB_FAIL(plan_cache_->foreach_cache_obj(plan_id_op))) {
SERVER_LOG(WARN, "fail to traverse id2stat_map");
} else {
plan_id_array_idx_ = 0;
}
}
}
return ret;
}
int ObVirtualOpenCursorTable::inner_get_next_row(ObNewRow *&row)
{
int ret = OB_SUCCESS;
bool is_end = false;
if (OB_ISNULL(sess_mgr_)) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(ERROR, "session mgr is null", K(ret));
if (OB_ISNULL(session_mgr_)) {
ret = OB_NOT_INIT;
SERVER_LOG(WARN, "sessionMgr is NULL", K(ret));
} else {
if (NULL == plan_cache_) {
ret = OB_ITER_END;
is_end = true;
} else if (OB_SUCC(ret)) {
if (is_travs_sess_) {
bool is_filled = false;
ObCacheObjGuard guard(GV_SQL_HANDLE);
ObPlanCacheObject *plan = NULL;
if (OB_FAIL(plan_cache_->ref_cache_obj(plan_id_, guard))) {
// this rarely happens this because other had hold ref_cnt of this cache obj.
SERVER_LOG(ERROR, "failed to get plan.", K(ret));
} else if (FALSE_IT(plan = static_cast<ObPlanCacheObject*>(guard.get_cache_obj()))) {
} else if (OB_FAIL(fill_cells(row, is_filled, plan))) {
SERVER_LOG(ERROR, "failed to fill cells", K(ret));
if (!start_to_read_) {
if (OB_FAIL(fill_scanner_.init(allocator_,
&scanner_,
session_,
&cur_row_,
output_column_ids_,
schema_guard_,
ipstr_,
port_))) {
SERVER_LOG(WARN, "init fill_scanner fail", K(ret));
} else if (OB_FAIL(session_mgr_->for_each_session(fill_scanner_))) {
SERVER_LOG(WARN, "fill scanner fail", K(ret));
} else {
scanner_it_ = scanner_.begin();
start_to_read_ = true;
}
}
if (OB_SUCCESS == ret && start_to_read_) {
if (OB_FAIL(scanner_it_.get_next_row(cur_row_))) {
if (OB_UNLIKELY(OB_ITER_END != ret)) {
SERVER_LOG(WARN, "fail to get next row", K(ret));
}
} else {
bool is_filled = false;
while (OB_SUCC(ret) && false == is_filled && false == is_end) {
if (plan_id_array_idx_ < 0) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "invalid plan_stat_array index", K(plan_id_array_idx_));
} else if (plan_id_array_idx_ >= plan_id_array_.count()) {
is_end = true;
plan_id_array_idx_ = OB_INVALID_ID;
plan_id_array_.reset();
ret = OB_ITER_END;
if (OB_UNLIKELY(NULL == plan_cache_)) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "plan cache is null", K(ret));
} else {
plan_cache_->dec_ref_count();
plan_cache_ = NULL;
}
} else {
ObPlanCacheObject *plan = NULL;
ObCacheObjGuard guard(GV_SQL_HANDLE);
is_end = false;
plan_id_ = plan_id_array_.at(plan_id_array_idx_);
++plan_id_array_idx_;
int tmp_ret = plan_cache_->ref_cache_obj(plan_id_, guard); //plan引用计数加1
//如果当前plan_id对应的plan已被淘汰, 则忽略继续获取下一个plan
// cache_obj = guard.get_cache_obj();
if (OB_HASH_NOT_EXIST == tmp_ret) {
//do nothing;
} else if (OB_SUCCESS != tmp_ret) {
ret = tmp_ret;
} else if (FALSE_IT(plan = static_cast<ObPlanCacheObject*>(guard.get_cache_obj()))) {
} else if (OB_FAIL(fill_cells(row, is_filled, plan))) { //plan exist
SERVER_LOG(WARN, "fail to fill cells", K(plan), K(tenant_id_));
} else {
}
}
} //while end:
row = &cur_row_;
}
}
}
return ret;
}
int ObVirtualOpenCursorTable::fill_cells(ObNewRow *&row, bool &is_filled, ObPlanCacheObject* cache_obj)
bool ObVirtualOpenCursorTable::FillScanner::operator()(sql::ObSQLSessionMgr::Key key,
ObSQLSessionInfo *sess_info)
{
int ret = OB_SUCCESS;
const ObPhysicalPlan *plan = NULL;
is_filled = false;
if (!cache_obj->is_sql_crsr()) {
if (OB_UNLIKELY(NULL == scanner_
|| NULL == allocator_
|| NULL == cur_row_
|| NULL == cur_row_->cells_
|| NULL == sess_info
|| NULL == my_session_)) {
ret = OB_NOT_INIT;
SERVER_LOG(WARN,
"parameter or data member is NULL",
K(ret),
K(scanner_),
K(allocator_),
K(cur_row_),
K(sess_info),
K(my_session_));
} else if (OB_UNLIKELY(cur_row_->count_ < output_column_ids_.count())) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(ERROR, "not a sql", K(ret));
} else if (OB_ISNULL(plan = dynamic_cast<const ObPhysicalPlan *>(cache_obj))) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN, "unexpected null plan", K(ret), K(plan));
} else if (OB_ISNULL(sess_arr_ = oesid_.get_sid_maps().get(plan->get_sql_id()))) {
is_filled = false;
SERVER_LOG(WARN,
"cells count is less than output column count",
K(ret),
K(cur_row_->count_),
K(output_column_ids_.count()));
} else {
SERVER_LOG(WARN, "sid array count", K(sess_arr_->count()));
if (sess_id_array_idx_ < sess_arr_->count()) {
OZ (fill_cells_impl(sess_arr_->at(sess_id_array_idx_), plan));
OX (sess_id_array_idx_++);
OX (row = &cur_row_);
is_filled = true;
}
#define RESET_TRAVS_STATUS() \
do { \
is_travs_sess_ = false; \
sess_id_array_idx_ = 0; \
} while(0)
// 如果失败,不管如何先释放对plan cache内部的引用
if (OB_FAIL(ret)) {
RESET_TRAVS_STATUS();
} else {
if (sess_id_array_idx_ == sess_arr_->count()) {
RESET_TRAVS_STATUS();
} else {
is_travs_sess_ = true;
ObServer &server = ObServer::get_instance();
uint64_t cell_idx = 0;
char ip_buf[common::OB_IP_STR_BUFF];
char peer_buf[common::OB_IP_PORT_STR_BUFF];
char sql_id[common::OB_MAX_SQL_ID_LENGTH + 1];
//If you are in system tenant, you can see all thread.
//Otherwise, you can show only the threads at the same Tenant with you.
//If you have the PROCESS privilege, you can show all threads at your Tenant.
//Otherwise, you can show only your own threads.
if (sess_info->is_shadow()) {
//this session info is logical free, shouldn't be added to scanner
} else if ((OB_SYS_TENANT_ID == my_session_->get_priv_tenant_id())
|| (sess_info->get_priv_tenant_id() == my_session_->get_priv_tenant_id()
&& my_session_->get_user_id() == sess_info->get_user_id())) {
ObSQLSessionInfo::LockGuard lock_guard(sess_info->get_thread_data_lock());
OZ (fill_cur_plan_cell(*sess_info));
for (sql::ObSQLSessionInfo::CursorCache::CursorMap::iterator iter =
sess_info->get_cursor_cache().pl_cursor_map_.begin(); //ignore ret
OB_SUCC(ret) && iter != sess_info->get_cursor_cache().pl_cursor_map_.end();
++iter) {
pl::ObPLCursorInfo *cursor_info = iter->second;
if (OB_ISNULL(cursor_info)) {
// do not report error
SERVER_LOG(WARN, "get a NULL cursor when record for v$open_cursor.");
} else {
OZ (fill_session_cursor_cell(*sess_info, cursor_info->get_id()));
}
}
}
// for(int i = 0; OB_SUCC(ret) && i < sess_arr_->count(); ++i) {
// OZ (fill_cells_impl(sess_arr_->at(i), plan, plan_cache));
// }
}
return ret;
return OB_SUCCESS == ret;
}
int ObVirtualOpenCursorTable::fill_cells_impl(const SessionInfo &sess_info,
const ObPhysicalPlan *plan)
int ObVirtualOpenCursorTable::FillScanner::fill_session_cursor_cell(ObSQLSessionInfo &sess_info,
const int64_t cursor_id)
{
int ret = OB_SUCCESS;
ObObj *cells = cur_row_.cells_;
const int64_t col_count = output_column_ids_.count();
ObCharsetType default_charset = ObCharset::get_default_charset();
ObCollationType default_collation = ObCharset::get_default_collation(default_charset);
if (OB_UNLIKELY(NULL == cells)) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(ERROR, "cur row cell is NULL", K(ret));
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < col_count; ++i) {
const uint64_t col_id = output_column_ids_.at(i);
switch (col_id) {
case TENANT_ID: {
cur_row_->cells_[i].set_int(sess_info.get_priv_tenant_id());
break;
}
case SVR_IP: {
cur_row_->cells_[i].set_varchar(ipstr_);
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case SVR_PORT: {
cur_row_->cells_[i].set_int(port_);
break;
}
case SADDR: {
ObSqlString addr;
ObString tmp_saddr;
addr.append_fmt("%lx", reinterpret_cast<uint64_t>(&sess_info));
OZ (ob_write_string(*allocator_, addr.string(), tmp_saddr));
// get last 8 char, for oracle compatiable
int64_t offset = tmp_saddr.length() > 8 ? tmp_saddr.length() - 8 : 0;
// if tmp_saddr.length() - offset > 8, offset is 0
// the length make sure (tmp_saddr.ptr() + offset) do not have out-of-bounds access
int64_t length = tmp_saddr.length() - offset > 8 ? 8 : tmp_saddr.length() - offset;
ObString saddr(length, tmp_saddr.ptr() + offset);
cur_row_->cells_[i].set_varchar(saddr);
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case SID: {
cur_row_->cells_[i].set_int(sess_info.get_sessid());
break;
}
case USER_NAME: {
cur_row_->cells_[i].set_varchar(sess_info.get_user_name());
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case ADDRESS: {
// session cursor not set now
cur_row_->cells_[i].set_null();
break;
}
case HASH_VALUE: {
// cur_row_->cells_[i].set_int(sess_info.id);
cur_row_->cells_[i].set_null();
break;
}
case SQL_ID: {
char sql_id[common::OB_MAX_SQL_ID_LENGTH + 1];
if (obmysql::COM_QUERY == sess_info.get_mysql_cmd() ||
obmysql::COM_STMT_EXECUTE == sess_info.get_mysql_cmd() ||
obmysql::COM_STMT_PREPARE == sess_info.get_mysql_cmd() ||
obmysql::COM_STMT_PREXECUTE == sess_info.get_mysql_cmd()) {
sess_info.get_cur_sql_id(sql_id, OB_MAX_SQL_ID_LENGTH + 1);
} else {
sql_id[0] = '\0';
}
cur_row_->cells_[i].set_varchar(ObString::make_string(sql_id));
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case SQL_TEXT: {
ObPsStmtId inner_stmt_id = OB_INVALID_ID;
if (0 == (cursor_id & (1L << 31))) {
if (OB_ISNULL(sess_info.get_ps_cache())) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN,"ps : ps cache is null.", K(ret), K(cursor_id));
} else if (OB_FAIL(sess_info.get_inner_ps_stmt_id(cursor_id, inner_stmt_id))) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN,"ps : get inner stmt id fail.", K(ret), K(cursor_id));
} else {
ObPsStmtInfoGuard guard;
ObPsStmtInfo *ps_info = NULL;
if (OB_FAIL(sess_info.get_ps_cache()->get_stmt_info_guard(inner_stmt_id, guard))) {
SERVER_LOG(WARN,"get stmt info guard failed", K(ret), K(cursor_id), K(inner_stmt_id));
} else if (OB_ISNULL(ps_info = guard.get_stmt_info())) {
ret = OB_ERR_UNEXPECTED;
SERVER_LOG(WARN,"get stmt info is null", K(ret));
} else {
ObString sql = ps_info->get_ps_sql();
int64_t len = 60 > sql.length() ? sql.length() : 60;
cur_row_->cells_[i].set_varchar(ObString(len, ps_info->get_ps_sql().ptr()));
cur_row_->cells_[i].set_collation_type(default_collation);
}
}
} else {
// refcursor can not get sql now
cur_row_->cells_[i].set_varchar("ref cursor");
cur_row_->cells_[i].set_collation_type(default_collation);
}
break;
}
case LAST_SQL_ACTIVE_TIME: {
// session cursor not set now
cur_row_->cells_[i].set_null();
break;
}
case SQL_EXEC_ID: {
cur_row_->cells_[i].set_null();
break;
}
case CURSOR_TYPE: {
cur_row_->cells_[i].set_varchar("SESSION CURSOR CACHED");
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case CHILD_ADDRESS: {
cur_row_->cells_[i].set_null();
break;
}
case CON_ID: {
cur_row_->cells_[i].set_int(1);
break;
}
default: {
break;
}
}
}
if (OB_UNLIKELY(OB_SUCCESS == ret && OB_SUCCESS != (ret = scanner_->add_row(*cur_row_)))) {
SERVER_LOG(WARN, "fail to add row", K(ret), K(*cur_row_));
}
return ret;
}
int ObVirtualOpenCursorTable::FillScanner::fill_cur_plan_cell(ObSQLSessionInfo &sess_info)
{
int ret = OB_SUCCESS;
const int64_t col_count = output_column_ids_.count();
ObCharsetType default_charset = ObCharset::get_default_charset();
ObCollationType default_collation = ObCharset::get_default_collation(default_charset);
ObPlanCache *plan_cache = sess_info.get_plan_cache();
if (OB_NOT_NULL(plan_cache)) {
for (int64_t i = 0; OB_SUCC(ret) && i < col_count; ++i) {
const uint64_t col_id = output_column_ids_.at(i);
switch (col_id) {
case TENANT_ID: {
cells[i].set_int(tenant_id_);
cur_row_->cells_[i].set_int(sess_info.get_priv_tenant_id());
break;
}
case SVR_IP: {
cells[i].set_varchar(ipstr_);
cells[i].set_collation_type(default_collation);
cur_row_->cells_[i].set_varchar(ipstr_);
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case SVR_PORT: {
cells[i].set_int(port_);
cur_row_->cells_[i].set_int(port_);
break;
}
case SADDR: {
ObSqlString addr;
ObString tmp_saddr;
OZ(addr.append_fmt("%lx", sess_info.addr));
addr.append_fmt("%lx", reinterpret_cast<uint64_t>(&sess_info));
OZ (ob_write_string(*allocator_, addr.string(), tmp_saddr));
// get last 8 char, for oracle compatiable
int64_t offset = tmp_saddr.length() > 8 ? tmp_saddr.length() - 8 : 0;
ObString saddr(8, tmp_saddr.ptr() + offset);
cells[i].set_varchar(saddr);
cells[i].set_collation_type(default_collation);
// if tmp_saddr.length() - offset > 8, offset is 0
// the length make sure (tmp_saddr.ptr() + offset) do not have out-of-bounds access
int64_t length = tmp_saddr.length() - offset > 8 ? 8 : tmp_saddr.length() - offset;
ObString saddr(length, tmp_saddr.ptr() + offset);
cur_row_->cells_[i].set_varchar(saddr);
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case SID: {
cells[i].set_int(sess_info.id);
cur_row_->cells_[i].set_int(sess_info.get_sessid());
break;
}
case USER_NAME: {
cells[i].set_varchar(sess_info.user_name);
cells[i].set_collation_type(default_collation);
cur_row_->cells_[i].set_varchar(sess_info.get_user_name());
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case ADDRESS: { // sql在plancache中的内存地址
// ObSqlString saddr;
// saddr.append_fmt("%lx", reinterpret_cast<uint64_t>(plan));
// ObString addr;
// OZ (ob_write_string(*allocator_, saddr.string(), addr));
// cells[i].set_raw(addr);
cells[i].set_null();
case ADDRESS: {
// plan not set now
cur_row_->cells_[i].set_null();
break;
}
case HASH_VALUE: {
// cells[i].set_int(sess_info.id);
cells[i].set_null();
// cur_row_->cells_[i].set_int(sess_info.id);
cur_row_->cells_[i].set_null();
break;
}
case SQL_ID: {
cells[i].set_varchar(sess_info.sql_id);
cells[i].set_collation_type(default_collation);
char sql_id[common::OB_MAX_SQL_ID_LENGTH + 1];
if (obmysql::COM_QUERY == sess_info.get_mysql_cmd() ||
obmysql::COM_STMT_EXECUTE == sess_info.get_mysql_cmd() ||
obmysql::COM_STMT_PREPARE == sess_info.get_mysql_cmd() ||
obmysql::COM_STMT_PREXECUTE == sess_info.get_mysql_cmd()) {
sess_info.get_cur_sql_id(sql_id, OB_MAX_SQL_ID_LENGTH + 1);
} else {
sql_id[0] = '\0';
}
cur_row_->cells_[i].set_varchar(ObString::make_string(sql_id));
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case SQL_TEXT: {
cells[i].set_varchar(ObString(60, plan->stat_.raw_sql_.ptr()));
cells[i].set_collation_type(default_collation);
ObString sql = sess_info.get_current_query_string();
int64_t len = 60 > sql.length() ? sql.length() : 60;
cur_row_->cells_[i].set_varchar(ObString(len, sql.ptr()));
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case LAST_SQL_ACTIVE_TIME: {
cells[i].set_datetime(plan->stat_.last_active_time_);
// session cursor not set now
cur_row_->cells_[i].set_timestamp(sess_info.get_query_start_time());
break;
}
case SQL_EXEC_ID: {
cells[i].set_null();
cur_row_->cells_[i].set_null();
break;
}
case CURSOR_TYPE: {
cur_row_->cells_[i].set_varchar("OPEN");
cur_row_->cells_[i].set_collation_type(default_collation);
break;
}
case CHILD_ADDRESS: {
cur_row_->cells_[i].set_null();
break;
}
case CON_ID: {
cur_row_->cells_[i].set_int(1);
break;
}
default: {
@ -377,8 +404,54 @@ int ObVirtualOpenCursorTable::fill_cells_impl(const SessionInfo &sess_info,
}
}
}
if (OB_UNLIKELY(OB_SUCCESS == ret && OB_SUCCESS != (ret = scanner_->add_row(*cur_row_)))) {
SERVER_LOG(WARN, "fail to add row", K(ret), K(*cur_row_));
}
return ret;
}
void ObVirtualOpenCursorTable::FillScanner::reset()
{
allocator_ = NULL;
scanner_ = NULL;
cur_row_ = NULL;
my_session_ = NULL;
output_column_ids_.reset();
ipstr_.reset();
port_ = 0;
}
int ObVirtualOpenCursorTable::FillScanner::init(ObIAllocator *allocator,
common::ObScanner *scanner,
sql::ObSQLSessionInfo *session_info,
common::ObNewRow *cur_row,
const ObIArray<uint64_t> &column_ids,
share::schema::ObSchemaGetterGuard* schema_guard,
common::ObString &ipstr,
uint32_t port)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(NULL == allocator
|| NULL == scanner
|| NULL == cur_row
|| NULL == session_info)) {
ret = OB_NOT_INIT;
SERVER_LOG(WARN,
"some parameter is NULL", K(ret), K(allocator), K(scanner), K(cur_row), K(session_info));
} else if (OB_FAIL(output_column_ids_.assign(column_ids))) {
SQL_ENG_LOG(WARN, "fail to assign output column ids", K(ret), K(column_ids));
} else {
allocator_ = allocator;
scanner_ = scanner;
cur_row_ = cur_row;
my_session_ = session_info;
schema_guard_ = schema_guard;
ipstr_ = ipstr;
port_ = port;
}
return ret;
}
} // namespace observer
} // namespace oceanbase

View File

@ -13,10 +13,26 @@
#ifndef OCEANBASE_OBSERVER_VIRTUAL_TABLE_OB_OPEN_CURSOR
#define OCEANBASE_OBSERVER_VIRTUAL_TABLE_OB_OPEN_CURSOR
#include "share/ob_virtual_table_scanner_iterator.h"
#include "lib/hash/ob_hashmap.h"
#include "lib/container/ob_se_array.h"
#include "sql/session/ob_sql_session_mgr.h"
/* __all_virtual_open_cursor
* The original implementation logic of open_cursor is:
*
* 1. lock each session and get cur_sql_id
* 2. get all plans through plan_cache, when the plan's sql_id == cur_sql_id, get the current plan, and get sql_text & last_active_time information
*
* the problem with this implementation is that:
*
* 1. when get a plan, since the current session is not locked, the risk is high
* 2. only sql_text & last_active_time information is read in the plan. These two values can be get on the session, and the cost of using the plan is relatively high
*
* new open_cursor implementation logic:
*
* 1. securely get session information through fore_each_session
* 2. referring to the show_processlist framework, put the results into the scanner for results, this framework is also conducive to subsequent expansion
* 3. cur_plan & session_cursor two kinds of information are currently recorded
*/
namespace oceanbase
{
namespace common
@ -46,91 +62,92 @@ class ObPlanCache;
namespace observer
{
class ObSessionOpenCursor {
public:
explicit ObSessionOpenCursor() {}
virtual ~ObSessionOpenCursor() {}
bool operator()(sql::ObSQLSessionMgr::Key key, sql::ObSQLSessionInfo *sess_info);
private:
DISALLOW_COPY_AND_ASSIGN(ObSessionOpenCursor);
};
class ObVirtualOpenCursorTable : public common::ObVirtualTableScannerIterator
{
public:
struct SessionInfo {
uint32_t id; // session id
uint64_t addr; // session addr
ObString user_name;
ObString sql_id; // ob_max_sql_id_length;
bool is_valid()
{
return 0 != addr && 0 != id;
}
TO_STRING_KV(K(id), K(addr), K(user_name), K(sql_id));
};
typedef common::ObSEArray<SessionInfo, 8> SessionInfoArray;
typedef common::hash::ObHashMap<ObString, SessionInfoArray> SidMap;
class ObEachSessionId {
public:
explicit ObEachSessionId(ObIAllocator *alloc):
is_success_(false),
allocator_(alloc) {}
virtual ~ObEachSessionId(){}
bool operator()(sql::ObSQLSessionMgr::Key key, sql::ObSQLSessionInfo *sess_info);
int init(int64_t sess_cnt, ObIAllocator *allocator);
void reset();
inline SidMap &get_sid_maps() { return sids_map_; }
private:
SidMap sids_map_;
bool is_success_;
ObIAllocator *allocator_;
DISALLOW_COPY_AND_ASSIGN(ObEachSessionId);
};
ObVirtualOpenCursorTable();
virtual ~ObVirtualOpenCursorTable();
virtual int inner_get_next_row(common::ObNewRow *&row);
virtual void reset();
virtual int inner_open();
void set_session_mgr(sql::ObSQLSessionMgr *sess_mgr) { sess_mgr_ = sess_mgr; }
void set_plan_cache_manager(sql::ObPlanCacheManager *pcm) { pcm_ = pcm; }
inline void set_tenant_id(uint64_t tid) { tenant_id_ = tid; }
void set_session_mgr(sql::ObSQLSessionMgr *sess_mgr) { session_mgr_ = sess_mgr; }
int set_addr(const common::ObAddr &addr);
protected:
int fill_cells(ObNewRow *&row, bool &is_filled, sql::ObPlanCacheObject* cache_obj);
int fill_cells_impl(const SessionInfo &sess_info, const sql::ObPhysicalPlan *plan);
private:
// https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/V-OPEN_CURSOR.html
enum {
TENANT_ID = common::OB_APP_MIN_COLUMN_ID,
SVR_IP,
SVR_PORT,
SADDR,
SID,
USER_NAME,
ADDRESS,
HASH_VALUE,
SQL_ID,
SQL_TEXT,
LAST_SQL_ACTIVE_TIME,
SQL_EXEC_ID,
SADDR, // session point addr
SID, // session id
USER_NAME, // cur user name
ADDRESS, // now is null
HASH_VALUE, // now is null
SQL_ID, // sql id
SQL_TEXT, // sql text, only 60
LAST_SQL_ACTIVE_TIME, // last sql active time
SQL_EXEC_ID, // now is null
CURSOR_TYPE, // cursor type, only support OPEN & SESSION CURSOR CACHED now
/*
* OPEN PL/SQL
* OPEN
* SESSION CURSOR CACHED
* OPEN-RECURSIVE
* DICTIONARY LOOKUP CURSOR CACHED
* BUNDLE DICTIONARY LOOKUP CACHED
* JAVA NAME TRANSLATION CURSOR CACHED
* REPLICATION TRIGGER CURSOR CACHED
* CONSTRAINTS CURSOR CACHED
* PL/SQL CURSOR CACHED
*/
CHILD_ADDRESS, // Address of the child cursor
CON_ID, // The ID of the container to which the data pertains, only support 1 now
};
class FillScanner
{
public:
FillScanner()
:allocator_(NULL),
scanner_(NULL),
cur_row_(NULL),
my_session_(NULL),
output_column_ids_()
{}
virtual ~FillScanner(){}
bool operator()(sql::ObSQLSessionMgr::Key key, sql::ObSQLSessionInfo* sess_info);
int fill_session_cursor_cell(sql::ObSQLSessionInfo &sess_info,
const int64_t cursor_id);
int fill_cur_plan_cell(sql::ObSQLSessionInfo &sess_info);
int init(ObIAllocator *allocator,
common::ObScanner *scanner,
sql::ObSQLSessionInfo * session_info,
common::ObNewRow *cur_row,
const ObIArray<uint64_t> &column_ids,
share::schema::ObSchemaGetterGuard* schema_guard,
common::ObString &ipstr,
uint32_t port);
inline void reset();
private:
ObIAllocator *allocator_;
common::ObScanner *scanner_;
common::ObNewRow *cur_row_;
sql::ObSQLSessionInfo *my_session_;
share::schema::ObSchemaGetterGuard* schema_guard_;
ObSEArray<uint64_t, common::OB_PREALLOCATED_NUM> output_column_ids_;
common::ObString ipstr_;
uint32_t port_;
DISALLOW_COPY_AND_ASSIGN(FillScanner);
};
private:
sql::ObSQLSessionMgr *sess_mgr_;
sql::ObPlanCacheManager *pcm_;
common::ObSEArray<uint64_t, 1024> plan_id_array_;
common::ObSEArray<SessionInfo, 1024> session_info_array_;
int64_t plan_id_array_idx_;
sql::ObPlanCache *plan_cache_;
const SessionInfoArray *sess_arr_;
int64_t sess_id_array_idx_;
ObEachSessionId oesid_;
uint64_t tenant_id_;
sql::ObSQLSessionMgr *session_mgr_;
common::ObString ipstr_;
uint32_t port_;
bool is_travs_sess_;
uint64_t plan_id_;
FillScanner fill_scanner_;
DISALLOW_COPY_AND_ASSIGN(ObVirtualOpenCursorTable);
}; // end ObVirtualOpenCursorTable
} // end observer

View File

@ -1984,8 +1984,6 @@ int ObVTIterCreator::create_vt_iter(ObVTableScanParam &params,
} else {
open_cursors->set_allocator(&allocator);
open_cursors->set_session_mgr(GCTX.session_mgr_);
open_cursors->set_plan_cache_manager(GCTX.sql_engine_->get_plan_cache_manager());
open_cursors->set_tenant_id(real_tenant_id);
OZ (open_cursors->set_addr(addr_));
OX (vt_iter = static_cast<ObVirtualOpenCursorTable*>(open_cursors));
}

View File

@ -1185,7 +1185,7 @@ int ObPLCodeGenerateVisitor::visit(const ObPLForAllStmt &s)
if (OB_SUCC(ret) && OB_NOT_NULL(generator_.get_current().get_v())) {
const ObPLForLoopStmt& for_loop = static_cast<const ObPLForLoopStmt&>(s);
if (OB_NOT_NULL(s.get_sql_stmt()) && !s.get_save_exception()) {
ObLLVMValue lower, upper, lower_obj, upper_obj, p_index_obj;
ObLLVMValue lower, upper, lower_obj, upper_obj, p_index_obj, count;
ObLLVMValue ret_err, is_need_rollback;
ObLLVMType ir_type;
ObLLVMBasicBlock illegal_block, after_block, rollback_block, not_rollback_block;
@ -1201,7 +1201,9 @@ int ObPLCodeGenerateVisitor::visit(const ObPLForAllStmt &s)
OZ (generator_.get_helper().create_alloca(var->get_name(), ir_type, p_index_obj));
OX (generator_.get_vars().at(s.get_ident() + generator_.USER_ARG_OFFSET) = p_index_obj);
OZ (generator_.generate_bound_and_check(s, true, lower, upper, lower_obj, upper_obj, illegal_block));
OZ (generator_.generate_sql(*(s.get_sql_stmt()), ret_err));
OZ (generator_.get_helper().create_sub(upper, lower, count));
OZ (generator_.get_helper().create_inc(count, count));
OZ (generator_.generate_sql(*(s.get_sql_stmt()), ret_err, count));
OZ (generator_.get_helper().create_icmp_eq(ret_err, OB_BATCHED_MULTI_STMT_ROLLBACK, is_need_rollback));
OZ (generator_.get_helper().create_cond_br(is_need_rollback, rollback_block, not_rollback_block));
OZ (generator_.set_current(not_rollback_block));
@ -1558,8 +1560,9 @@ int ObPLCodeGenerateVisitor::visit(const ObPLSqlStmt &s)
} else if (OB_FAIL(generator_.generate_goto_label(s))) {
LOG_WARN("failed to generate goto label", K(ret));
} else {
ObLLVMValue ret_err;
OZ (generator_.generate_sql(s, ret_err));
ObLLVMValue ret_err, count;
OZ (generator_.get_helper().get_int32(0, count));
OZ (generator_.generate_sql(s, ret_err, count));
OZ (generator_.generate_after_sql(s, ret_err));
}
return ret;
@ -2633,9 +2636,8 @@ int ObPLCodeGenerateVisitor::visit(const ObPLFetchStmt &s)
ret_err))) {
LOG_WARN("failed to generate fetch", K(ret));
} else if (lib::is_mysql_mode()) { //Mysql模式直接检查抛出异常
if (OB_FAIL(generator_.check_success(ret_err, s.get_stmt_id(), s.get_block()->in_notfound(), s.get_block()->in_warning()))) {
LOG_WARN("failed to check success", K(ret));
}
OZ (generator_.check_success(
ret_err, s.get_stmt_id(), s.get_block()->in_notfound(), s.get_block()->in_warning(), true));
} else { //Oracle模式如果是OB_READ_NOTHING错误,吞掉异常不抛出
ObLLVMValue is_not_found;
ObLLVMBasicBlock fetch_end;
@ -3357,6 +3359,8 @@ int ObPLCodeGenerator::init_spi_service()
LOG_WARN("push_back error", K(ret));
} else if (OB_FAIL(arg_types.push_back(bool_type))) {
LOG_WARN("push_back error", K(ret));
} else if (OB_FAIL(arg_types.push_back(int32_type))) {
LOG_WARN("push_back error", K(ret));
} else if (OB_FAIL(ObLLVMFunctionType::get(int32_type, arg_types, ft))) {
LOG_WARN("failed to get function type", K(ret));
} else if (OB_FAIL(helper_.create_function(ObString("spi_execute"), ft, spi_service_.spi_execute_))) {
@ -4937,7 +4941,7 @@ int ObPLCodeGenerator::generate_bound_and_check(const ObPLForLoopStmt &s,
return ret;
}
int ObPLCodeGenerator::generate_sql(const ObPLSqlStmt &s, ObLLVMValue &ret_err)
int ObPLCodeGenerator::generate_sql(const ObPLSqlStmt &s, ObLLVMValue &ret_err, ObLLVMValue &array_bind_count)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(get_current().get_v())) {
@ -5015,6 +5019,7 @@ int ObPLCodeGenerator::generate_sql(const ObPLSqlStmt &s, ObLLVMValue &ret_err)
ObLLVMValue is_forall;
OZ (get_helper().get_int8(static_cast<int64_t>(s.is_forall_sql()), is_forall));
OZ (args.push_back(is_forall));
OZ (args.push_back(array_bind_count));
OZ (get_helper().create_call(ObString("spi_execute"), get_spi_service().spi_execute_, args, ret_err));
}
}
@ -6612,7 +6617,7 @@ int ObPLCodeGenerator::raise_exception(ObLLVMValue &exception,
return ret;
}
int ObPLCodeGenerator::check_success(jit::ObLLVMValue &ret_err, int64_t stmt_id,
bool in_notfound, bool in_warning)
bool in_notfound, bool in_warning, bool signal)
{
int ret = OB_SUCCESS;
if (OB_FAIL(helper_.set_insert_point(get_current()))) {
@ -6694,7 +6699,7 @@ int ObPLCodeGenerator::check_success(jit::ObLLVMValue &ret_err, int64_t stmt_id,
LOG_WARN("failed to create_load", K(ret));
} else if (OB_FAIL(helper_.create_load(ObString("load_str_len"), str_len_ptr, str_len))) {
LOG_WARN("failed to create_load", K(ret));
} else if (OB_FAIL(generate_exception(type, ret_err, error_code, sql_state, str_len, stmt_id_value, success_branch, line_number_value, in_notfound, in_warning, false/*not signal*/))) {
} else if (OB_FAIL(generate_exception(type, ret_err, error_code, sql_state, str_len, stmt_id_value, success_branch, line_number_value, in_notfound, in_warning, signal))) {
LOG_WARN("failed to generate exception", K(ret));
} else if (OB_FAIL(set_current(success_branch))) {
LOG_WARN("failed to set_current", K(ret));

View File

@ -311,13 +311,14 @@ public:
jit::ObLLVMValue &upper_value,
jit::ObLLVMValue &is_true);
int generate_sql(const ObPLSqlStmt &s, jit::ObLLVMValue &ret_err);
int generate_sql(const ObPLSqlStmt &s, jit::ObLLVMValue &ret_err, jit::ObLLVMValue &array_bind_count);
int generate_after_sql(const ObPLSqlStmt &s, jit::ObLLVMValue &ret_err);
int generate_new_objparam(jit::ObLLVMValue &result, int64_t udt_id = OB_INVALID_ID);
int check_success(jit::ObLLVMValue &ret_err,
int64_t stmt_id = OB_INVALID_ID,
bool in_notfound = false,
bool in_warning = false);
bool in_warning = false,
bool signal = false);
int finish_current(const jit::ObLLVMBasicBlock &next);
jit::ObLLVMValue stack_save();
void stack_restore(jit::ObLLVMValue &stack);

View File

@ -3615,6 +3615,7 @@ int ObPLResolver::check_raw_expr_in_forall(ObRawExpr* expr, int64_t idx, bool &n
ret = OB_ERR_FORALL_ITER_NOT_ALLOWED;
LOG_WARN("PLS-00430: FORALL iteration variable INDX is not allowed in this context", K(ret));
}
//这里控制包含非数组类型变量的forall语句直接以forloop实现, 避免forall先回退, 再forloop执行
can_array_binding = false;
} else {
bool inner_modify = false;

View File

@ -805,16 +805,19 @@ int ObBackupCleanTaskMgr::delete_backup_set_inner_placeholder_()
int ret = OB_SUCCESS;
ObBackupPath path;
ObBackupSetDesc desc;
share::ObBackupDest backup_set_dest;
desc.backup_set_id_ = backup_set_info_.backup_set_id_;
desc.backup_type_ = backup_set_info_.backup_type_;
if (OB_FAIL(ObBackupPathUtil::construct_backup_set_dest(backup_dest_, desc, backup_set_dest))) {
LOG_WARN("fail to construct backup set dest", K(ret));
} else if (OB_FAIL(ObBackupPathUtil::get_backup_set_inner_placeholder(
backup_set_dest, desc, backup_set_info_.start_replay_scn_, backup_set_info_.min_restore_scn_, path))) {
LOG_WARN("failed to get backup set end placeholder path", K(ret));
} else if (OB_FAIL(share::ObBackupCleanUtil::delete_backup_file(path, backup_dest_.get_storage_info()))) {
LOG_WARN("failed to delete backup file", K(ret), K(task_attr_), K(path));
char placeholder_prefix[OB_MAX_BACKUP_CHECK_FILE_NAME_LENGTH] = { 0 };
ObBackupIoAdapter util;
ObBackupPrefixDeleteFileOp prefix_delete_op;
if (OB_FAIL(ObBackupPathUtil::get_backup_set_dir_path(backup_dest_, desc, path))) {
LOG_WARN("failed to get tenant data backup set dir", K(ret), K_(backup_dest));
} else if (OB_FAIL(ObBackupPathUtil::get_backup_set_inner_placeholder_prefix(desc, placeholder_prefix, sizeof(placeholder_prefix)))) {
LOG_WARN("failed to get backup set inner placeholder prefix", K(ret));
} else if (OB_FAIL(prefix_delete_op.init(placeholder_prefix, strlen(placeholder_prefix), path, backup_dest_.get_storage_info()))) {
LOG_WARN("failed to init prefix delete", K(ret), K(placeholder_prefix));
} else if (OB_FAIL(util.list_files(path.get_obstr(), backup_dest_.get_storage_info(), prefix_delete_op))) {
LOG_WARN("failed to list files", K(ret), K(path), K(placeholder_prefix));
}
return ret;
}

View File

@ -621,7 +621,8 @@ int ObBackupDataScheduler::start_tenant_backup_data_(const ObBackupJobAttr &job_
LOG_WARN("[DATA_BACKUP]failed to update backup type", K(ret), K(new_job_attr));
} else if (OB_FAIL(new_job_attr.executor_tenant_id_.push_back(new_job_attr.tenant_id_))) {
LOG_WARN("[DATA_BACKUP]failed to push back tenant id", K(ret));
} else if (OB_FALSE_IT(new_job_attr.initiator_job_id_ = new_job_attr.job_id_)) {
} else if (OB_FALSE_IT(new_job_attr.initiator_job_id_ = new_job_attr.tenant_id_ == new_job_attr.initiator_tenant_id_ ?
0/*no parent job*/ : new_job_attr.initiator_job_id_)) {
} else if (OB_FAIL(lease_service_->check_lease())) {
LOG_WARN("fail to check leader", K(ret));
} else if (OB_FAIL(ObBackupJobOperator::insert_job(trans, new_job_attr))) {

View File

@ -26,6 +26,7 @@
#include "share/backup/ob_backup_connectivity.h"
#include "share/ls/ob_ls_i_life_manager.h"
#include "logservice/palf/scn.h"
#include "share/ob_debug_sync.h"
using namespace oceanbase;
using namespace rootserver;
@ -586,14 +587,20 @@ int ObArchiveHandler::checkpoint_(ObTenantArchiveRoundAttr &round_info)
case ObArchiveRoundState::Status::INTERRUPTED:
break;
case ObArchiveRoundState::Status::PREPARE: {
DEBUG_SYNC(BEFROE_LOG_ARCHIVE_SCHEDULE_PREPARE);
if (OB_FAIL(start_archive_(round_info))) {
LOG_WARN("failed to prepare archive", K(ret), K(round_info));
}
}
break;
case ObArchiveRoundState::Status::BEGINNING:
case ObArchiveRoundState::Status::DOING:
case ObArchiveRoundState::Status::BEGINNING: {
DEBUG_SYNC(BEFROE_LOG_ARCHIVE_SCHEDULE_BEGINNING);
}
case ObArchiveRoundState::Status::DOING: {
DEBUG_SYNC(BEFROE_LOG_ARCHIVE_SCHEDULE_DOING);
}
case ObArchiveRoundState::Status::STOPPING: {
DEBUG_SYNC(BEFROE_LOG_ARCHIVE_SCHEDULE_STOPPING);
if (OB_FAIL(do_checkpoint_(round_info))) {
LOG_WARN("failed to checkpoint", K(ret), K(round_info));
}

View File

@ -120,7 +120,7 @@ int ObColumnRedefinitionTask::wait_data_complement(const ObDDLTaskStatus next_ta
DEBUG_SYNC(COLUMN_REDEFINITION_REPLICA_BUILD);
if (is_build_replica_end) {
ret = complete_sstable_job_ret_code_;
if (OB_SUCC(ret) && OB_FAIL(check_data_dest_tables_columns_checksum())) {
if (OB_SUCC(ret) && OB_FAIL(check_data_dest_tables_columns_checksum(1/*execution_id*/))) {
LOG_WARN("fail to check the columns checkum between data table and hidden one", K(ret));
}
if (OB_FAIL(switch_status(next_task_status, ret))) {
@ -139,6 +139,7 @@ int ObColumnRedefinitionTask::send_build_single_replica_request()
ret = OB_NOT_INIT;
LOG_WARN("ObColumnRedefinitionTask has not been inited", K(ret));
} else {
redefinition_execution_id_ = ObTimeUtility::fast_current_time();
ObDDLSingleReplicaExecutorParam param;
param.tenant_id_ = tenant_id_;
param.type_ = task_type_;
@ -148,6 +149,7 @@ int ObColumnRedefinitionTask::send_build_single_replica_request()
param.snapshot_version_ = snapshot_version_;
param.task_id_ = task_id_;
param.parallelism_ = alter_table_arg_.parallelism_;
param.execution_id_ = redefinition_execution_id_;
if (OB_FAIL(ObDDLUtil::get_tablets(tenant_id_, object_id_, param.source_tablet_ids_))) {
LOG_WARN("fail to get tablets", K(ret), K(tenant_id_), K(object_id_));
} else if (OB_FAIL(ObDDLUtil::get_tablets(tenant_id_, target_object_id_, param.dest_tablet_ids_))) {
@ -183,7 +185,10 @@ int ObColumnRedefinitionTask::check_build_single_replica(bool &is_end)
}
// update sstable complement status for all leaders
int ObColumnRedefinitionTask::update_complete_sstable_job_status(const common::ObTabletID &tablet_id, const int64_t snapshot_version, const int ret_code)
int ObColumnRedefinitionTask::update_complete_sstable_job_status(const common::ObTabletID &tablet_id,
const int64_t snapshot_version,
const int64_t execution_id,
const int ret_code)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!is_inited_)) {
@ -194,6 +199,8 @@ int ObColumnRedefinitionTask::update_complete_sstable_job_status(const common::O
} else if (snapshot_version != snapshot_version_) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("snapshot version not match", K(ret), K(snapshot_version), K(snapshot_version_));
} else if (execution_id != redefinition_execution_id_) {
LOG_INFO("receive a mismatch execution result, ignore", K(execution_id), K(redefinition_execution_id_));
} else if (OB_FAIL(replica_builder_.set_partition_task_status(tablet_id, ret_code))) {
LOG_WARN("fail to set partition task status", K(ret));
}

View File

@ -44,6 +44,7 @@ public:
virtual int update_complete_sstable_job_status(
const common::ObTabletID &tablet_id,
const int64_t snapshot_version,
const int64_t execution_id,
const int ret_code) override;
private:
int wait_data_complement(const share::ObDDLTaskStatus next_task_status);

View File

@ -44,33 +44,18 @@ ObCheckConstraintValidationTask::ObCheckConstraintValidationTask(
}
int ObCheckConstraintValidationTask::process()
{
int ret = OB_SUCCESS;
int tmp_ret = OB_SUCCESS;
ObRootService *root_service = GCTX.root_service_;
if (OB_ISNULL(root_service)) {
ret = OB_ERR_SYS;
LOG_WARN("error sys, root service must not be nullptr", K(ret));
} else {
ObTabletID unused_tablet_id;
ObDDLTaskKey task_key(target_object_id_, schema_version_);
ret = ObDDLUtil::retry_with_ddl_schema_hint([this]() -> int { return this->check_constraint_by_send_sql(); });
if (OB_SUCCESS != (tmp_ret = root_service->get_ddl_scheduler().on_sstable_complement_job_reply(unused_tablet_id, task_key, 1L/*unused snapshot version*/, ret))) {
LOG_WARN("fail to finish check constraint task", K(ret), K(tmp_ret));
}
}
return ret;
}
int ObCheckConstraintValidationTask::check_constraint_by_send_sql() const
{
int ret = OB_SUCCESS;
ObTraceIdGuard trace_id_guard(trace_id_);
ObRootService *root_service = GCTX.root_service_;
const ObConstraint *constraint = nullptr;
bool is_oracle_mode = false;
ObSchemaGetterGuard schema_guard;
const ObTableSchema *table_schema = nullptr;
const ObDatabaseSchema *database_schema = nullptr;
int tmp_ret = OB_SUCCESS;
ObTabletID unused_tablet_id;
ObDDLTaskKey task_key(target_object_id_, schema_version_);
if (OB_FAIL(ObMultiVersionSchemaService::get_instance().get_tenant_schema_guard(tenant_id_, schema_guard))) {
LOG_WARN("get tenant schema guard failed", K(ret), K(tenant_id_));
} else if (OB_FAIL(schema_guard.get_table_schema(tenant_id_, data_table_id_, table_schema))) {
@ -78,6 +63,9 @@ int ObCheckConstraintValidationTask::check_constraint_by_send_sql() const
} else if (OB_ISNULL(table_schema)) {
ret = OB_TABLE_NOT_EXIST;
LOG_WARN("table schema not exist", K(ret));
} else if (OB_ISNULL(root_service)) {
ret = OB_ERR_SYS;
LOG_WARN("error sys, root service must not be nullptr", K(ret));
} else if (!check_table_empty_ && OB_ISNULL(constraint = table_schema->get_constraint(constraint_id_))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("error unexpected, can not get constraint", K(ret));
@ -159,6 +147,9 @@ int ObCheckConstraintValidationTask::check_constraint_by_send_sql() const
}
}
}
if (OB_SUCCESS != (tmp_ret = root_service->get_ddl_scheduler().on_sstable_complement_job_reply(unused_tablet_id, task_key, 1L/*unused snapshot version*/, 1L/*unused execution id*/, ret))) {
LOG_WARN("fail to finish check constraint task", K(ret), K(tmp_ret));
}
return ret;
}
@ -199,8 +190,10 @@ int ObForeignKeyConstraintValidationTask::process()
ObTabletID unused_tablet_id;
ObDDLTaskKey task_key(foregin_key_id_, schema_version_);
int tmp_ret = OB_SUCCESS;
ret = ObDDLUtil::retry_with_ddl_schema_hint([this]() -> int { return this->check_fk_by_send_sql(); });
if (OB_SUCCESS != (tmp_ret = root_service->get_ddl_scheduler().on_sstable_complement_job_reply(unused_tablet_id, task_key, 1L/*unused snapshot version*/, ret))) {
if (OB_FAIL(check_fk_by_send_sql())) {
LOG_WARN("failed to check fk", K(ret));
}
if (OB_SUCCESS != (tmp_ret = root_service->get_ddl_scheduler().on_sstable_complement_job_reply(unused_tablet_id, task_key, 1L/*unused snapshot version*/, 1L/*unused execution id*/, ret))) {
LOG_WARN("fail to finish check constraint task", K(ret));
}
LOG_INFO("execute check foreign key task finish", K(ret), K(task_key), K(data_table_id_), K(foregin_key_id_));

View File

@ -37,9 +37,6 @@ public:
virtual int process() override;
virtual int64_t get_deep_copy_size() const override { return sizeof(*this); }
virtual ObAsyncTask *deep_copy(char *buf, const int64_t buf_size) const override;
private:
int check_constraint_by_send_sql() const;
int rollback_change();
private:
uint64_t tenant_id_;
int64_t data_table_id_;

View File

@ -39,6 +39,7 @@ ObDDLRedefinitionSSTableBuildTask::ObDDLRedefinitionSSTableBuildTask(
const int64_t dest_table_id,
const int64_t schema_version,
const int64_t snapshot_version,
const int64_t execution_id,
const ObSQLMode &sql_mode,
const common::ObCurTraceId::TraceId &trace_id,
const int64_t parallelism,
@ -46,7 +47,7 @@ ObDDLRedefinitionSSTableBuildTask::ObDDLRedefinitionSSTableBuildTask(
ObRootService *root_service)
: is_inited_(false), tenant_id_(tenant_id), task_id_(task_id), data_table_id_(data_table_id),
dest_table_id_(dest_table_id), schema_version_(schema_version), snapshot_version_(snapshot_version),
sql_mode_(sql_mode), trace_id_(trace_id), parallelism_(parallelism),
execution_id_(execution_id), sql_mode_(sql_mode), trace_id_(trace_id), parallelism_(parallelism),
use_heap_table_ddl_plan_(use_heap_table_ddl_plan), root_service_(root_service)
{
set_retry_times(0); // do not retry
@ -103,6 +104,8 @@ int ObDDLRedefinitionSSTableBuildTask::process()
dest_table_id_,
schema_version_,
snapshot_version_,
execution_id_,
task_id_,
parallelism_,
use_heap_table_ddl_plan_,
false/*use_schema_version_hint_for_src_table*/,
@ -141,7 +144,7 @@ int ObDDLRedefinitionSSTableBuildTask::process()
}
}
}
if (OB_SUCCESS != (tmp_ret = root_service_->get_ddl_scheduler().on_sstable_complement_job_reply(unused_tablet_id, task_key, snapshot_version_, ret))) {
if (OB_SUCCESS != (tmp_ret = root_service_->get_ddl_scheduler().on_sstable_complement_job_reply(unused_tablet_id, task_key, snapshot_version_, execution_id_, ret))) {
LOG_WARN("fail to finish sstable complement", K(ret));
}
return ret;
@ -165,6 +168,7 @@ ObAsyncTask *ObDDLRedefinitionSSTableBuildTask::deep_copy(char *buf, const int64
dest_table_id_,
schema_version_,
snapshot_version_,
execution_id_,
sql_mode_,
trace_id_,
parallelism_,
@ -551,7 +555,7 @@ int ObDDLRedefinitionTask::get_validate_checksum_columns_id(const ObTableSchema
return ret;
}
int ObDDLRedefinitionTask::check_data_dest_tables_columns_checksum()
int ObDDLRedefinitionTask::check_data_dest_tables_columns_checksum(const int64_t execution_id)
{
int ret = OB_SUCCESS;
ObSchemaGetterGuard schema_guard;
@ -583,16 +587,16 @@ int ObDDLRedefinitionTask::check_data_dest_tables_columns_checksum()
LOG_WARN("fail to create datatable column checksum map", K(ret));
} else if (OB_FAIL(dest_table_column_checksums.create(OB_MAX_COLUMN_NUMBER / 2, ObModIds::OB_CHECKSUM_CHECKER))) {
LOG_WARN("fail to create desttable column checksum map", K(ret));
} else if (OB_UNLIKELY(OB_INVALID_ID == schema_version_ || OB_INVALID_ID == object_id_ || !data_table_column_checksums.created())) {
} else if (OB_UNLIKELY(0 > execution_id || OB_INVALID_ID == object_id_ || !data_table_column_checksums.created())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), "data_table_execution_id", schema_version_, K(object_id_), K(data_table_column_checksums.created()));
LOG_WARN("invalid argument", K(ret), K(execution_id), K(object_id_), K(data_table_column_checksums.created()));
} else if (OB_UNLIKELY(OB_INVALID_ID == target_object_id_ || !dest_table_column_checksums.created())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), "dest_table_execution_id", schema_version_, "dest_table_id", target_object_id_, K(dest_table_column_checksums.created()));
} else if (OB_FAIL(ObDDLChecksumOperator::get_table_column_checksum(tenant_id_, schema_version_, object_id_, data_table_column_checksums, GCTX.root_service_->get_sql_proxy()))) {
LOG_WARN("fail to get table column checksum", K(ret), K(schema_version_), "table_id", object_id_, K(data_table_column_checksums.created()), KP(GCTX.root_service_));
} else if (OB_FAIL(ObDDLChecksumOperator::get_table_column_checksum(tenant_id_, schema_version_, target_object_id_, dest_table_column_checksums, GCTX.root_service_->get_sql_proxy()))) {
LOG_WARN("fail to get table column checksum", K(ret), "dest_table_execution_id", schema_version_, "table_id", target_object_id_, K(dest_table_column_checksums.created()), KP(GCTX.root_service_));
LOG_WARN("invalid argument", K(ret), "dest_table_id", target_object_id_, K(dest_table_column_checksums.created()));
} else if (OB_FAIL(ObDDLChecksumOperator::get_table_column_checksum(tenant_id_, execution_id, object_id_, task_id_, data_table_column_checksums, GCTX.root_service_->get_sql_proxy()))) {
LOG_WARN("fail to get table column checksum", K(ret), K(execution_id), "table_id", object_id_, K_(task_id), K(data_table_column_checksums.created()), KP(GCTX.root_service_));
} else if (OB_FAIL(ObDDLChecksumOperator::get_table_column_checksum(tenant_id_, execution_id, target_object_id_, task_id_, dest_table_column_checksums, GCTX.root_service_->get_sql_proxy()))) {
LOG_WARN("fail to get table column checksum", K(ret), K(execution_id), "table_id", target_object_id_, K_(task_id), K(dest_table_column_checksums.created()), KP(GCTX.root_service_));
} else {
uint64_t dest_column_id = 0;
for (hash::ObHashMap<int64_t, int64_t>::const_iterator iter = data_table_column_checksums.begin();

View File

@ -31,6 +31,7 @@ public:
const int64_t dest_table_id,
const int64_t schema_version,
const int64_t snapshot_version,
const int64_t execution_id,
const ObSQLMode &sql_mode,
const common::ObCurTraceId::TraceId &trace_id,
const int64_t parallelism,
@ -52,6 +53,7 @@ private:
int64_t dest_table_id_;
int64_t schema_version_;
int64_t snapshot_version_;
int64_t execution_id_;
ObSQLMode sql_mode_;
ObTimeZoneInfoWrap tz_info_wrap_;
share::ObColumnNameMap col_name_map_;
@ -112,6 +114,7 @@ public:
virtual int update_complete_sstable_job_status(
const common::ObTabletID &tablet_id,
const int64_t snapshot_version,
const int64_t execution_id,
const int ret_code) = 0;
int on_child_task_finish(
const ObDDLTaskKey &child_task_key,
@ -133,7 +136,7 @@ protected:
const share::schema::ObTableSchema &data_table_schema,
const share::schema::ObTableSchema &dest_table_schema,
common::hash::ObHashMap<uint64_t, uint64_t> &validate_checksum_column_ids);
int check_data_dest_tables_columns_checksum();
int check_data_dest_tables_columns_checksum(const int64_t execution_id);
int unlock_table();
int fail();
int success();
@ -214,6 +217,7 @@ protected:
int64_t update_autoinc_job_time_;
int64_t check_table_empty_job_ret_code_;
int64_t check_table_empty_job_time_;
int64_t redefinition_execution_id_;
};
} // end namespace rootserver

View File

@ -335,7 +335,7 @@ void ObDDLScheduler::run1()
} else {
ObCurTraceId::set(task->get_trace_id());
task->process();
if (task->need_retry()) {
if (task->need_retry() && !has_set_stop()) {
if (OB_FAIL(task_queue_.add_task_to_last(task))) {
STORAGE_LOG(ERROR, "fail to add task to last, which should not happen", K(ret), K(*task));
}
@ -1302,15 +1302,16 @@ int ObDDLScheduler::on_sstable_complement_job_reply(
const common::ObTabletID &tablet_id,
const ObDDLTaskKey &task_key,
const int64_t snapshot_version,
const int64_t execution_id,
const int ret_code)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret));
} else if (OB_UNLIKELY(!(task_key.is_valid() && snapshot_version > 0))) {
} else if (OB_UNLIKELY(!(task_key.is_valid() && snapshot_version > 0 && execution_id > 0))) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), K(task_key), K(snapshot_version), K(ret_code));
LOG_WARN("invalid argument", K(ret), K(task_key), K(snapshot_version), K(execution_id), K(ret_code));
} else {
ObDDLTask *ddl_task = nullptr;
if (OB_FAIL(task_queue_.get_task(task_key, ddl_task))) {
@ -1324,12 +1325,12 @@ int ObDDLScheduler::on_sstable_complement_job_reply(
const int64_t task_type = ddl_task->get_task_type();
switch (task_type) {
case ObDDLType::DDL_CREATE_INDEX:
if (OB_FAIL(static_cast<ObIndexBuildTask *>(ddl_task)->update_complete_sstable_job_status(tablet_id, snapshot_version, ret_code))) {
if (OB_FAIL(static_cast<ObIndexBuildTask *>(ddl_task)->update_complete_sstable_job_status(tablet_id, snapshot_version, execution_id, ret_code))) {
LOG_WARN("update complete sstable job status failed", K(ret));
}
break;
case ObDDLType::DDL_DROP_PRIMARY_KEY:
if (OB_FAIL(static_cast<ObDropPrimaryKeyTask *>(ddl_task)->update_complete_sstable_job_status(tablet_id, snapshot_version, ret_code))) {
if (OB_FAIL(static_cast<ObDropPrimaryKeyTask *>(ddl_task)->update_complete_sstable_job_status(tablet_id, snapshot_version, execution_id, ret_code))) {
LOG_WARN("update complete sstable job status", K(ret));
}
break;
@ -1339,7 +1340,7 @@ int ObDDLScheduler::on_sstable_complement_job_reply(
case ObDDLType::DDL_MODIFY_COLUMN:
case ObDDLType::DDL_CONVERT_TO_CHARACTER:
case ObDDLType::DDL_TABLE_REDEFINITION:
if (OB_FAIL(static_cast<ObTableRedefinitionTask *>(ddl_task)->update_complete_sstable_job_status(tablet_id, snapshot_version, ret_code))) {
if (OB_FAIL(static_cast<ObTableRedefinitionTask *>(ddl_task)->update_complete_sstable_job_status(tablet_id, snapshot_version, execution_id, ret_code))) {
LOG_WARN("update complete sstable job status", K(ret));
}
break;
@ -1353,7 +1354,7 @@ int ObDDLScheduler::on_sstable_complement_job_reply(
case ObDDLType::DDL_DROP_COLUMN:
case ObDDLType::DDL_ADD_COLUMN_OFFLINE:
case ObDDLType::DDL_COLUMN_REDEFINITION:
if (OB_FAIL(static_cast<ObColumnRedefinitionTask *>(ddl_task)->update_complete_sstable_job_status(tablet_id, snapshot_version, ret_code))) {
if (OB_FAIL(static_cast<ObColumnRedefinitionTask *>(ddl_task)->update_complete_sstable_job_status(tablet_id, snapshot_version, execution_id, ret_code))) {
LOG_WARN("update complete sstable job status", K(ret), K(tablet_id), K(snapshot_version), K(ret_code));
}
break;

View File

@ -113,6 +113,7 @@ public:
const common::ObTabletID &tablet_id,
const ObDDLTaskKey &task_key,
const int64_t snapshot_version,
const int64_t execution_id,
const int ret_code);
int on_ddl_task_finish(

View File

@ -42,6 +42,7 @@ int ObDDLSingleReplicaExecutor::build(const ObDDLSingleReplicaExecutorParam &par
schema_version_ = param.schema_version_;
snapshot_version_ = param.snapshot_version_;
task_id_ = param.task_id_;
execution_id_ = param.execution_id_;
parallelism_ = param.parallelism_;
common::ObIArray<ObPartitionBuildInfo> &build_infos = partition_build_stat_;
@ -113,6 +114,7 @@ int ObDDLSingleReplicaExecutor::schedule_task()
arg.ddl_type_ = type_;
arg.task_id_ = task_id_;
arg.parallelism_ = parallelism_;
arg.execution_id_ = execution_id_;
if (OB_FAIL(location_service->get(tenant_id_, arg.source_tablet_id_,
expire_renew_time, is_cache_hit, ls_id))) {
LOG_WARN("get ls failed", K(ret), K(arg.source_tablet_id_));

View File

@ -35,18 +35,19 @@ public:
schema_version_(0),
snapshot_version_(0),
task_id_(0),
parallelism_(0)
parallelism_(0),
execution_id_(0)
{}
~ObDDLSingleReplicaExecutorParam() = default;
bool is_valid() const {
return common::OB_INVALID_TENANT_ID != tenant_id_ && share::DDL_INVALID != type_
&& source_tablet_ids_.count() > 0 && dest_tablet_ids_.count() > 0
&& common::OB_INVALID_ID != source_table_id_ && common::OB_INVALID_ID != dest_table_id_
&& schema_version_ > 0 && snapshot_version_ > 0 && task_id_ > 0;
&& schema_version_ > 0 && snapshot_version_ > 0 && task_id_ > 0 && execution_id_ > 0;
}
TO_STRING_KV(K_(tenant_id), K_(type), K_(source_tablet_ids), K_(dest_tablet_ids),
K_(source_table_id), K_(dest_table_id), K_(schema_version),
K_(snapshot_version), K_(task_id), K_(parallelism));
K_(snapshot_version), K_(task_id), K_(parallelism), K_(execution_id));
public:
uint64_t tenant_id_;
share::ObDDLType type_;
@ -58,6 +59,7 @@ public:
int64_t snapshot_version_;
int64_t task_id_;
int64_t parallelism_;
int64_t execution_id_;
};
class ObDDLSingleReplicaExecutor
@ -100,6 +102,7 @@ private:
int64_t snapshot_version_;
int64_t task_id_;
int64_t parallelism_;
int64_t execution_id_;
common::ObArray<ObPartitionBuildInfo> partition_build_stat_;
common::ObSpinLock lock_;
};

View File

@ -28,21 +28,6 @@ using namespace oceanbase::share::schema;
using namespace oceanbase::sql;
int ObIndexSSTableBuildTask::process()
{
int ret = ObDDLUtil::retry_with_ddl_schema_hint([this]() -> int { return this->send_build_replica_sql(); });
ObTabletID unused_tablet_id;
LOG_INFO("build index sstable finish", K(ret), K(*this));
ObDDLTaskKey task_key(dest_table_id_, schema_version_);
int tmp_ret = root_service_->get_ddl_scheduler().on_sstable_complement_job_reply(
unused_tablet_id, task_key, snapshot_version_, ret);
if (OB_SUCCESS != tmp_ret) {
LOG_WARN("report build finish failed", K(ret), K(tmp_ret));
ret = OB_SUCCESS == ret ? tmp_ret : ret;
}
return ret;
}
int ObIndexSSTableBuildTask::send_build_replica_sql() const
{
int ret = OB_SUCCESS;
ObTraceIdGuard trace_id_guard(trace_id_);
@ -77,6 +62,8 @@ int ObIndexSSTableBuildTask::send_build_replica_sql() const
dest_table_id_,
table_schema->get_schema_version(),
snapshot_version_,
execution_id_,
task_id_,
parallelism_,
false/*use_heap_table_ddl*/,
!table_schema->is_user_hidden_table()/*use_schema_version_hint_for_src_table*/,
@ -117,6 +104,15 @@ int ObIndexSSTableBuildTask::send_build_replica_sql() const
LOG_WARN("fail to execute build replica sql", K(ret), K(tenant_id_));
}
}
LOG_INFO("build index sstable finish", K(ret), K(*this));
ObDDLTaskKey task_key(dest_table_id_, schema_version_);
int tmp_ret = root_service_->get_ddl_scheduler().on_sstable_complement_job_reply(
unused_tablet_id, task_key, snapshot_version_, execution_id_, ret);
if (OB_SUCCESS != tmp_ret) {
LOG_WARN("report build finish failed", K(ret), K(tmp_ret));
ret = OB_SUCCESS == ret ? tmp_ret : ret;
}
return ret;
}
@ -133,6 +129,7 @@ ObAsyncTask *ObIndexSSTableBuildTask::deep_copy(char *buf, const int64_t buf_siz
dest_table_id_,
schema_version_,
snapshot_version_,
execution_id_,
trace_id_,
parallelism_,
create_index_arg_,
@ -146,7 +143,8 @@ ObIndexBuildTask::ObIndexBuildTask()
: ObDDLTask(ObDDLType::DDL_CREATE_INDEX), index_table_id_(target_object_id_),
is_unique_index_(false), is_global_index_(false), root_service_(nullptr), snapshot_held_(false),
is_sstable_complete_task_submitted_(false), sstable_complete_request_time_(0), sstable_complete_ts_(0),
check_unique_snapshot_(0), complete_sstable_job_ret_code_(INT64_MAX), create_index_arg_()
check_unique_snapshot_(0), complete_sstable_job_ret_code_(INT64_MAX),
redefinition_execution_id_(0), create_index_arg_()
{
}
@ -578,6 +576,7 @@ int ObIndexBuildTask::send_build_single_replica_request()
target_object_id_,
schema_version_,
snapshot_version_,
redefinition_execution_id_,
trace_id_,
parallelism_,
&create_index_arg_,
@ -639,6 +638,7 @@ int ObIndexBuildTask::wait_data_complement()
// submit a job to complete sstable for the index table on snapshot_version
if (OB_SUCC(ret) && !state_finished && !is_sstable_complete_task_submitted_) {
redefinition_execution_id_ = ObTimeUtility::current_time();
if (OB_FAIL(send_build_single_replica_request())) {
LOG_WARN("fail to send build single replica request", K(ret));
}
@ -657,15 +657,13 @@ int ObIndexBuildTask::wait_data_complement()
if (OB_SUCC(ret) && state_finished) {
uint64_t execution_id = OB_INVALID_ID;
bool dummy_equal = false;
if (OB_FAIL(get_execution_id(execution_id))) {
LOG_WARN("fail to query execution id", K(ret), K(index_table_id_));
} else if (OB_FAIL(ObDDLChecksumOperator::check_column_checksum(
tenant_id_, execution_id, object_id_, index_table_id_, dummy_equal, root_service_->get_sql_proxy()))) {
if (OB_FAIL(ObDDLChecksumOperator::check_column_checksum(
tenant_id_, redefinition_execution_id_, object_id_, index_table_id_, task_id_, dummy_equal, root_service_->get_sql_proxy()))) {
if (OB_ITER_END != ret) {
LOG_ERROR("fail to check column checksum", K(ret), K(index_table_id_), K(object_id_));
LOG_WARN("fail to check column checksum", K(ret), K(index_table_id_), K(object_id_), K(task_id_));
state_finished = true;
} else if (REACH_TIME_INTERVAL(1000L * 1000L)) {
LOG_INFO("index checksum has not been reported", K(ret), K(index_table_id_), K(object_id_));
LOG_INFO("index checksum has not been reported", K(ret), K(index_table_id_), K(object_id_), K(task_id_));
}
}
}
@ -677,19 +675,6 @@ int ObIndexBuildTask::wait_data_complement()
return ret;
}
int ObIndexBuildTask::get_execution_id(uint64_t &execution_id)
{
int ret = OB_SUCCESS;
execution_id = OB_INVALID_ID;
if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT;
LOG_WARN("not init", K(ret));
} else {
execution_id = schema_version_;
}
return ret;
}
int ObIndexBuildTask::check_need_verify_checksum(bool &need_verify)
{
int ret = OB_SUCCESS;
@ -776,12 +761,8 @@ int ObIndexBuildTask::verify_checksum()
static int64_t checksum_wait_timeout = max(GCONF.global_index_build_single_replica_timeout / 50, 3600L * 1000L * 1000L);
bool is_column_checksum_ready = false;
bool dummy_equal = false;
uint64_t execution_id = OB_INVALID_ID;
int64_t pos = 0;
if (OB_FAIL(get_execution_id(execution_id))) {
LOG_WARN("get execution id failed", K(ret), K(index_table_id_));
} else if (!wait_column_checksum_ctx_.is_inited() && OB_FAIL(wait_column_checksum_ctx_.init(
task_id_, tenant_id_, object_id_, index_table_id_, schema_version_, check_unique_snapshot_, execution_id, checksum_wait_timeout))) {
if (!wait_column_checksum_ctx_.is_inited() && OB_FAIL(wait_column_checksum_ctx_.init(
task_id_, tenant_id_, object_id_, index_table_id_, schema_version_, check_unique_snapshot_, redefinition_execution_id_, checksum_wait_timeout))) {
LOG_WARN("init context of wait column checksum failed", K(ret), K(object_id_), K(index_table_id_));
} else {
if (OB_FAIL(wait_column_checksum_ctx_.try_wait(is_column_checksum_ready))) {
@ -794,7 +775,7 @@ int ObIndexBuildTask::verify_checksum()
// do nothing
} else {
if (OB_FAIL(ObDDLChecksumOperator::check_column_checksum(
tenant_id_, execution_id, object_id_, index_table_id_, dummy_equal, root_service_->get_sql_proxy()))) {
tenant_id_, redefinition_execution_id_, object_id_, index_table_id_, task_id_, dummy_equal, root_service_->get_sql_proxy()))) {
if (OB_CHECKSUM_ERROR == ret && is_unique_index_) {
ret = OB_ERR_DUPLICATED_UNIQUE_KEY;
}
@ -836,6 +817,7 @@ int ObIndexBuildTask::update_column_checksum_calc_status(
int ObIndexBuildTask::update_complete_sstable_job_status(
const common::ObTabletID &tablet_id,
const int64_t snapshot_version,
const int64_t execution_id,
const int ret_code)
{
int ret = OB_SUCCESS;
@ -851,6 +833,8 @@ int ObIndexBuildTask::update_complete_sstable_job_status(
} else if (snapshot_version != snapshot_version_) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("snapshot version not match", K(ret), K(snapshot_version), K(snapshot_version_));
} else if (execution_id != redefinition_execution_id_) {
LOG_INFO("receive a mismatch execution result, ignore", K(execution_id), K(redefinition_execution_id_));
} else {
complete_sstable_job_ret_code_ = ret_code;
sstable_complete_ts_ = ObTimeUtility::current_time();

View File

@ -30,13 +30,15 @@ public:
const int64_t dest_table_id,
const int64_t schema_version,
const int64_t snapshot_version,
const int64_t execution_id,
const common::ObCurTraceId::TraceId &trace_id,
const int64_t parallelism,
obrpc::ObCreateIndexArg *create_index_arg,
ObRootService *root_service)
: task_id_(task_id), tenant_id_(tenant_id), data_table_id_(data_table_id), dest_table_id_(dest_table_id),
schema_version_(schema_version), snapshot_version_(snapshot_version), trace_id_(trace_id),
parallelism_(parallelism), create_index_arg_(create_index_arg), root_service_(root_service)
schema_version_(schema_version), snapshot_version_(snapshot_version), execution_id_(execution_id),
trace_id_(trace_id), parallelism_(parallelism), create_index_arg_(create_index_arg),
root_service_(root_service)
{
set_retry_times(0);
}
@ -45,7 +47,8 @@ public:
virtual int process() override;
virtual int64_t get_deep_copy_size() const override { return sizeof(*this); }
virtual ObAsyncTask *deep_copy(char *buf, const int64_t buf_size) const override;
TO_STRING_KV(K_(data_table_id), K_(dest_table_id), K_(schema_version), K_(snapshot_version), K_(trace_id), K_(parallelism));
TO_STRING_KV(K_(data_table_id), K_(dest_table_id), K_(schema_version), K_(snapshot_version),
K_(execution_id), K_(trace_id), K_(parallelism));
private:
int64_t task_id_;
@ -54,6 +57,7 @@ private:
int64_t dest_table_id_;
int64_t schema_version_;
int64_t snapshot_version_;
int64_t execution_id_;
common::ObCurTraceId::TraceId trace_id_;
int64_t parallelism_;
obrpc::ObCreateIndexArg *create_index_arg_;
@ -85,6 +89,7 @@ public:
int update_complete_sstable_job_status(
const common::ObTabletID &tablet_id,
const int64_t snapshot_version,
const int64_t execution_id,
const int ret_code);
virtual int process() override;
virtual bool is_valid() const override;
@ -93,7 +98,7 @@ public:
virtual int64_t get_serialize_param_size() const override;
static int deep_copy_index_arg(common::ObIAllocator &allocator, const obrpc::ObCreateIndexArg &source_arg, obrpc::ObCreateIndexArg &dest_arg);
INHERIT_TO_STRING_KV("ObDDLTask", ObDDLTask, K(index_table_id_),K(snapshot_held_), K(is_sstable_complete_task_submitted_),
K(sstable_complete_ts_), K(check_unique_snapshot_), K(create_index_arg_));
K(sstable_complete_ts_), K(check_unique_snapshot_), K_(redefinition_execution_id), K(create_index_arg_));
private:
int prepare();
int wait_trans_end();
@ -108,7 +113,6 @@ private:
int update_index_status_in_schema(
const share::schema::ObTableSchema &index_schema,
const share::schema::ObIndexStatus new_status);
int get_execution_id(uint64_t &execution_id);
int check_health();
int send_build_single_replica_request();
int check_build_single_replica(bool &is_end);
@ -133,6 +137,7 @@ private:
int64_t check_unique_snapshot_;
ObDDLWaitColumnChecksumCtx wait_column_checksum_ctx_;
int64_t complete_sstable_job_ret_code_;
int64_t redefinition_execution_id_;
obrpc::ObCreateIndexArg create_index_arg_; // this is not a valid arg, only has nls formats for now
};

View File

@ -103,7 +103,10 @@ int ObTableRedefinitionTask::init(const ObDDLTaskRecord &task_record)
return ret;
}
int ObTableRedefinitionTask::update_complete_sstable_job_status(const common::ObTabletID &tablet_id, const int64_t snapshot_version, const int ret_code)
int ObTableRedefinitionTask::update_complete_sstable_job_status(const common::ObTabletID &tablet_id,
const int64_t snapshot_version,
const int64_t execution_id,
const int ret_code)
{
int ret = OB_SUCCESS;
TCWLockGuard guard(lock_);
@ -116,6 +119,8 @@ int ObTableRedefinitionTask::update_complete_sstable_job_status(const common::Ob
} else if (OB_UNLIKELY(snapshot_version_ != snapshot_version)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("error unexpected, snapshot version is not equal", K(ret), K(snapshot_version_), K(snapshot_version));
} else if (execution_id != redefinition_execution_id_) {
LOG_INFO("receive a mismatch execution result, ignore", K(execution_id), K(redefinition_execution_id_));
} else {
complete_sstable_job_ret_code_ = ret_code;
LOG_INFO("table redefinition task callback", K(complete_sstable_job_ret_code_));
@ -150,6 +155,7 @@ int ObTableRedefinitionTask::send_build_replica_request()
target_object_id_,
schema_version_,
snapshot_version_,
redefinition_execution_id_,
sql_mode,
trace_id_,
parallelism_,
@ -242,6 +248,7 @@ int ObTableRedefinitionTask::table_redefinition(const ObDDLTaskStatus next_task_
}
if (OB_SUCC(ret) && !is_build_replica_end && 0 == build_replica_request_time_) {
redefinition_execution_id_ = ObTimeUtility::current_time();
if (OB_FAIL(send_build_replica_request())) {
LOG_WARN("fail to send build replica request", K(ret));
} else {
@ -264,7 +271,7 @@ int ObTableRedefinitionTask::table_redefinition(const ObDDLTaskStatus next_task_
if (is_build_replica_end) {
ret = complete_sstable_job_ret_code_;
if (OB_SUCC(ret)) {
if (OB_FAIL(check_data_dest_tables_columns_checksum())) {
if (OB_FAIL(check_data_dest_tables_columns_checksum(redefinition_execution_id_))) {
LOG_WARN("fail to check the columns checksum of data table and destination table", K(ret));
}
}

View File

@ -43,6 +43,7 @@ public:
virtual int update_complete_sstable_job_status(
const common::ObTabletID &tablet_id,
const int64_t snapshot_version,
const int64_t execution_id,
const int ret_code) override;
protected:
int table_redefinition(const share::ObDDLTaskStatus next_task_status);

View File

@ -17,6 +17,7 @@
#include "share/ob_define.h"
#include "share/inner_table/ob_inner_table_schema_constants.h" // for OB_ALL_LS_REPLICA_TASK_TNAME
#include "rootserver/ob_disaster_recovery_task_mgr.h" // for ObDRTaskMgr
#include "share/schema/ob_multi_version_schema_service.h" // for GSCHEMASERVICE
namespace oceanbase
{
@ -259,6 +260,8 @@ int ObDRTaskTableUpdater::process_task_(
const uint64_t sql_tenant_id = gen_meta_tenant_id(task.get_tenant_id());
char task_id_to_set[OB_TRACE_STAT_BUFFER_SIZE] = "";
ObSqlString sql;
bool has_dropped = false;
if (OB_UNLIKELY(!inited_) || OB_ISNULL(sql_proxy_) || OB_ISNULL(task_mgr_)) {
ret = OB_NOT_INIT;
LOG_WARN("ObDRTaskTableUpdater is not inited", KR(ret));
@ -268,42 +271,51 @@ int ObDRTaskTableUpdater::process_task_(
} else if (false == task.get_task_id().to_string(task_id_to_set, sizeof(task_id_to_set))) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("convert task id to string failed", KR(ret), "task_id", task.get_task_id());
} else if (OB_FAIL(trans.start(sql_proxy_, sql_tenant_id))) {
LOG_WARN("start transaction failed", KR(ret), K(sql_tenant_id));
} else if (OB_UNLIKELY(!is_valid_tenant_id(task.get_tenant_id()))) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", KR(ret), "tenant_id", task.get_tenant_id());
} else if (OB_FAIL(GSCHEMASERVICE.check_if_tenant_has_been_dropped(task.get_tenant_id(), has_dropped))) {
LOG_WARN("fail to check if tenant has been dropped", KR(ret), "tenant_id", task.get_tenant_id());
} else {
if (OB_FAIL(sql.assign_fmt("DELETE FROM %s WHERE tenant_id = %lu AND ls_id = %lu "
"AND task_type = '%s' AND task_id = '%s'",
share::OB_ALL_LS_REPLICA_TASK_TNAME,
task.get_tenant_id(),
task.get_ls_id().id(),
ob_disaster_recovery_task_type_strs(task.get_task_type()),
task_id_to_set))) {
LOG_WARN("assign sql string failed", KR(ret), K(task));
} else if (OB_FAIL(sql_proxy_->write(sql_tenant_id, sql.ptr(), affected_rows))) {
LOG_WARN("execute sql failed", KR(ret), "sql", sql.ptr(), K(task), K(sql_tenant_id));
} else if (!is_single_row(affected_rows)) {
// ignore affected row check for task not exist
LOG_INFO("expected deleted single row",
K(affected_rows), K(sql), K(task), K(sql_tenant_id));
// tenant exist, have to delete task from table and memory
if (has_dropped) {
} else if (OB_FAIL(trans.start(sql_proxy_, sql_tenant_id))) {
LOG_WARN("start transaction failed", KR(ret), K(sql_tenant_id));
} else {
if (OB_FAIL(sql.assign_fmt("DELETE FROM %s WHERE tenant_id = %lu AND ls_id = %lu "
"AND task_type = '%s' AND task_id = '%s'",
share::OB_ALL_LS_REPLICA_TASK_TNAME,
task.get_tenant_id(),
task.get_ls_id().id(),
ob_disaster_recovery_task_type_strs(task.get_task_type()),
task_id_to_set))) {
LOG_WARN("assign sql string failed", KR(ret), K(task));
} else if (OB_FAIL(sql_proxy_->write(sql_tenant_id, sql.ptr(), affected_rows))) {
LOG_WARN("execute sql failed", KR(ret), "sql", sql.ptr(), K(task), K(sql_tenant_id));
} else if (!is_single_row(affected_rows)) {
// ignore affected row check for task not exist
LOG_INFO("expected deleted single row",
K(affected_rows), K(sql), K(task), K(sql_tenant_id));
}
}
if (FAILEDx(task_mgr_->do_cleaning(
task.get_task_id(),
task.get_task_key(),
task.get_ret_code(),
task.get_need_clear_server_data_in_limit(),
task.get_need_record_event(),
task.get_ret_comment()))) {
task.get_task_id(),
task.get_task_key(),
task.get_ret_code(),
task.get_need_clear_server_data_in_limit(),
task.get_need_record_event(),
task.get_ret_comment()))) {
LOG_WARN("fail to clean task info inside memory", KR(ret), K(task));
} else {
LOG_INFO("success to delete row from ls disaster task table and do cleaning",
K(affected_rows), K(sql), K(task), K(sql_tenant_id));
}
}
if (trans.is_started()) {
int trans_ret = trans.end(OB_SUCCESS == ret);
if (OB_SUCCESS != trans_ret) {
LOG_WARN("end transaction failed", KR(trans_ret));
ret = OB_SUCCESS == ret ? trans_ret : ret;
if (trans.is_started()) {
int trans_ret = trans.end(OB_SUCCESS == ret);
if (OB_SUCCESS != trans_ret) {
LOG_WARN("end transaction failed", KR(trans_ret));
ret = OB_SUCCESS == ret ? trans_ret : ret;
}
}
}
return ret;

View File

@ -9421,7 +9421,7 @@ int ObRootService::build_ddl_single_replica_response(const obrpc::ObDDLBuildSing
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguments", K(ret), K(arg));
} else if (OB_FAIL(ddl_scheduler_.on_sstable_complement_job_reply(
arg.tablet_id_/*source tablet id*/, ObDDLTaskKey(arg.dest_schema_id_, arg.schema_version_), arg.snapshot_version_, arg.ret_code_))) {
arg.tablet_id_/*source tablet id*/, ObDDLTaskKey(arg.dest_schema_id_, arg.schema_version_), arg.snapshot_version_, arg.execution_id_, arg.ret_code_))) {
LOG_WARN("handle column checksum calc response failed", K(ret), K(arg));
}
return ret;

View File

@ -50,6 +50,7 @@ int ObRestoreUtil::fill_physical_restore_job(
job.init_restore_key(OB_SYS_TENANT_ID, job_id);
job.set_status(PhysicalRestoreStatus::PHYSICAL_RESTORE_CREATE_TENANT);
job.set_tenant_name(arg.tenant_name_);
job.set_initiator_tenant_id(OB_SYS_TENANT_ID);
if (OB_FAIL(job.set_description(arg.description_))) {
LOG_WARN("fail to set description", K(ret));
}

View File

@ -80,15 +80,19 @@ public:
}
virtual void reset() override
{
if (pos_ > MAX_RESERVE_SIZE - 1) {
allocator_.reset();
}
pos_ = 0;
buf_[0] = '\0';
allocator_.reset();
}
virtual void reuse() override
{
if (pos_ > MAX_RESERVE_SIZE - 1) {
allocator_.reuse();
}
pos_ = 0;
buf_[0] = '\0';
allocator_.reuse();
}
virtual void set_attr(const ObMemAttr &attr) { UNUSED(attr); }

View File

@ -169,6 +169,8 @@ int ObDestRoundCheckpointer::gen_new_round_info_(const ObTenantArchiveRoundAttr
need_checkpoint = true;
if (OB_FAIL(new_round_info.deep_copy_from(old_round_info))) {
LOG_WARN("failed to deep copy round info", K(ret), K(old_round_info), K(counter));
} else if (counter.ls_count_ == counter.not_start_cnt_) {
// no log stream is archiving.
} else if (OB_FAIL(ObTenantArchiveMgr::decide_piece_id(old_round_info.start_scn_, old_round_info.base_piece_id_,
old_round_info.piece_switch_interval_, counter.max_scn_, new_round_info.used_piece_id_))) {
LOG_WARN("failed to calc MAX piece id", K(ret), K(old_round_info), K(counter));
@ -176,6 +178,9 @@ int ObDestRoundCheckpointer::gen_new_round_info_(const ObTenantArchiveRoundAttr
} else if (OB_FALSE_IT(next_checkpoint_scn = MIN(max_checkpoint_scn_, counter.checkpoint_scn_))) {
// Checkpoint can not over limit ts. However, if old round goes into STOPPING, then we will not
// move checkpoint_scn on.
}
if (OB_FAIL(ret)) {
} else if (old_round_info.state_.is_beginning()) {
if (counter.not_start_cnt_ > 0) {
need_checkpoint = false;
@ -254,40 +259,45 @@ int ObDestRoundCheckpointer::generate_pieces_(const ObTenantArchiveRoundAttr &ol
{
int ret = OB_SUCCESS;
int64_t active_input_bytes = 0;
int64_t active_output_bytes = 0;
int64_t frozen_input_bytes = 0;
int64_t frozen_output_bytes = 0;
if (result.new_round_info_.max_scn_ == old_round_info.start_scn_) {
// No log stream started archive before disable archive, then no piece generated in the round.
LOG_INFO("no piece generated.", K(old_round_info), K(result));
} else {
int64_t active_input_bytes = 0;
int64_t active_output_bytes = 0;
int64_t frozen_input_bytes = 0;
int64_t frozen_output_bytes = 0;
int64_t since_piece_id = 0;
if (OB_FAIL(ObTenantArchiveMgr::decide_piece_id(old_round_info.start_scn_, old_round_info.base_piece_id_, old_round_info.piece_switch_interval_, old_round_info.checkpoint_scn_, since_piece_id))) {
LOG_WARN("failed to calc since piece id", K(ret), K(old_round_info));
}
// generate pieces from last active and valid piece id to 'to_piece_id'
for (int64_t piece_id = since_piece_id; OB_SUCC(ret) && piece_id <= result.new_round_info_.used_piece_id_; piece_id++) {
GeneratedPiece piece;
if (OB_FAIL(generate_one_piece_(old_round_info, result.new_round_info_, summary, piece_id, piece))) {
LOG_WARN("failed to generate one piece", K(ret), K(old_round_info), K(result), K(summary), K(piece_id));
} else if (OB_FAIL(piece_generated_cb_(round_handler_->get_sql_proxy(), old_round_info, result, piece))) {
LOG_WARN("call piece_generated_cb_ failed", K(ret), K(old_round_info), K(piece));
} else if (OB_FAIL(result.piece_list_.push_back(piece))) {
LOG_WARN("failed to push back piece", K(ret), K(result), K(piece));
} else if (piece.piece_info_.status_.is_frozen()) {
frozen_input_bytes += piece.piece_info_.input_bytes_;
frozen_output_bytes += piece.piece_info_.output_bytes_;
} else {
// active piece
active_input_bytes += piece.piece_info_.input_bytes_;
active_output_bytes += piece.piece_info_.output_bytes_;
int64_t since_piece_id = 0;
if (OB_FAIL(ObTenantArchiveMgr::decide_piece_id(old_round_info.start_scn_, old_round_info.base_piece_id_, old_round_info.piece_switch_interval_, old_round_info.checkpoint_scn_, since_piece_id))) {
LOG_WARN("failed to calc since piece id", K(ret), K(old_round_info));
}
}
if (OB_SUCC(ret)) {
result.new_round_info_.frozen_input_bytes_ += frozen_input_bytes;
result.new_round_info_.frozen_output_bytes_ += frozen_output_bytes;
result.new_round_info_.active_input_bytes_ = active_input_bytes;
result.new_round_info_.active_output_bytes_ = active_output_bytes;
// generate pieces from last active and valid piece id to 'to_piece_id'
for (int64_t piece_id = since_piece_id; OB_SUCC(ret) && piece_id <= result.new_round_info_.used_piece_id_; piece_id++) {
GeneratedPiece piece;
if (OB_FAIL(generate_one_piece_(old_round_info, result.new_round_info_, summary, piece_id, piece))) {
LOG_WARN("failed to generate one piece", K(ret), K(old_round_info), K(result), K(summary), K(piece_id));
} else if (OB_FAIL(piece_generated_cb_(round_handler_->get_sql_proxy(), old_round_info, result, piece))) {
LOG_WARN("call piece_generated_cb_ failed", K(ret), K(old_round_info), K(piece));
} else if (OB_FAIL(result.piece_list_.push_back(piece))) {
LOG_WARN("failed to push back piece", K(ret), K(result), K(piece));
} else if (piece.piece_info_.status_.is_frozen()) {
frozen_input_bytes += piece.piece_info_.input_bytes_;
frozen_output_bytes += piece.piece_info_.output_bytes_;
} else {
// active piece
active_input_bytes += piece.piece_info_.input_bytes_;
active_output_bytes += piece.piece_info_.output_bytes_;
}
}
if (OB_SUCC(ret)) {
result.new_round_info_.frozen_input_bytes_ += frozen_input_bytes;
result.new_round_info_.frozen_output_bytes_ += frozen_output_bytes;
result.new_round_info_.active_input_bytes_ = active_input_bytes;
result.new_round_info_.active_output_bytes_ = active_output_bytes;
}
}
return ret;

Some files were not shown because too many files have changed in this diff Show More