[SCN] modify missing scenes

This commit is contained in:
obdev 2022-11-28 02:48:01 +00:00 committed by ob-robot
parent ac437d2f56
commit 68151eb87a
217 changed files with 2178 additions and 1196 deletions

View File

@ -286,7 +286,6 @@ struct ObVersionRange
OB_UNIS_VERSION(1);
public:
static const int64_t MIN_VERSION = 0;
static const int64_t MAX_VERSION = INT64_MAX;
ObVersionRange();
OB_INLINE void reset();
@ -310,7 +309,6 @@ struct ObNewVersionRange
OB_UNIS_VERSION(1);
public:
static const int64_t MIN_VERSION = 0;
static const int64_t MAX_VERSION = INT64_MAX;
ObNewVersionRange();
OB_INLINE void reset();

View File

@ -352,10 +352,11 @@ int label_stat(AChunk *chunk, ABlock *block, AObject *object,
} else {
hold = align_up2(chunk->alloc_bytes_ + ACHUNK_HEADER_SIZE, get_page_size());
}
void *label = &object->label_[0];
void *end = memchr(label, '\0', sizeof(object->label_));
int len = end ? (char*)end - (char*)label : sizeof(object->label_);
ObString str(len, (char*)label);
char label[AOBJECT_LABEL_SIZE + 1];
STRNCPY(label, object->label_, sizeof(label));
label[sizeof(label) - 1] = '\0';
int len = strlen(label);
ObString str(len, label);
LabelItem *litem = nullptr;
LabelInfoItem *linfoitem = lmap.get(str);
if (NULL != linfoitem) {

View File

@ -102,7 +102,7 @@ struct LabelInfoItem
void *block_;
};
typedef common::hash::ObHashMap<ObString, LabelInfoItem> LabelMap;
typedef common::hash::ObHashMap<ObString, LabelInfoItem, hash::NoPthreadDefendMode> LabelMap;
using lib::AChunk;
using lib::ABlock;

View File

@ -49,13 +49,16 @@ void sanity_set_whitelist(const char *str)
void memory_sanity_abort()
{
if ('\0' == whitelist[0]) {
abort();
}
void *addrs[128];
int n_addr = backtrace(addrs, sizeof(addrs)/sizeof(addrs[0]));
void *vip_addr = NULL;
for (int i = 0; NULL == vip_addr && i < n_addr; i++) {
for (int j = 0; NULL == vip_addr && j < 8; j++) {
for (int j = 0; NULL == vip_addr && j < sizeof(vips)/sizeof(vips[0]); j++) {
t_vip *vip = &vips[j];
if (0 == strlen(vip->func_)) {
if ('\0' == vip->func_[0]) {
break;
} else if (0 == vip->min_addr_ || 0 == vip->max_addr_) {
continue;
@ -81,9 +84,9 @@ void memory_sanity_abort()
if (real_len < buf_len - pos) {
pos += real_len;
}
for (int i = 0; i < 8; i++) {
for (int i = 0; i < sizeof(vips)/sizeof(vips[0]); i++) {
t_vip *vip = &vips[i];
if (0 == strlen(vip->func_)) {
if ('\0' == vip->func_[0]) {
break;
} else if (strstr(func_name, vip->func_) != NULL) {
strncpy(vip_func, func_name, sizeof(vip_func));

View File

@ -72,7 +72,7 @@ static constexpr int64_t sanity_max_canonical_addr = 0x4f210376cf1c;
static inline bool sanity_addr_in_range(const void *ptr)
{
return (int64_t)ptr >= sanity_min_canonical_addr && (int64_t)ptr < sanity_max_canonical_addr;
return (int64_t)ptr < sanity_max_canonical_addr && (int64_t)ptr >= sanity_min_canonical_addr;
}
static inline void* sanity_to_shadow(const void *ptr)
@ -139,12 +139,12 @@ static inline void sanity_check_range(const void *ptr, ssize_t len)
char *start_align = (char*)sanity_align_up((uint64_t)start, 8);
char *end_align = (char*)sanity_align_down((uint64_t)end, 8);
if (start_align > start &&
(*(uint8_t*)sanity_to_shadow(start_align - 8) != 0x0 &&
*(uint8_t*)sanity_to_shadow(start_align - 8) < (len + start - (start_align - 8)))) {
(*(int8_t*)sanity_to_shadow(start_align - 8) != 0x0 &&
*(int8_t*)sanity_to_shadow(start_align - 8) < (len + start - (start_align - 8)))) {
memory_sanity_abort();
}
if (end_align >= start_align + 8) {
if (*(uint8_t*)sanity_to_shadow(start_align) != 0x0) {
if (*(int8_t*)sanity_to_shadow(start_align) != 0x0) {
memory_sanity_abort();
}
if (end_align > start_align + 8) {
@ -157,8 +157,8 @@ static inline void sanity_check_range(const void *ptr, ssize_t len)
}
}
if (end_align < end &&
(*(uint8_t*)sanity_to_shadow(end_align) != 0x0 &&
*(uint8_t*)sanity_to_shadow(end_align) < (end - end_align))) {
(*(int8_t*)sanity_to_shadow(end_align) != 0x0 &&
*(int8_t*)sanity_to_shadow(end_align) < (end - end_align))) {
memory_sanity_abort();
}
}

View File

@ -131,9 +131,11 @@ public:
}
public:
uint32_t total() { return total_; }
int32_t stock() { return stock_; }
int32_t remain() { return stock_ > K ? stock_ - K : (stock_ < 0 ? stock_ + K : stock_); }
bool acquire() { return dec_if_gt(K, K) > K; }
bool release() { return faa(-K) > 0; }
bool recyle() {
bool recycle() {
int32_t total = total_;
return inc_if_lt(2 * K, -K + total) == -K + total;
}
@ -271,13 +273,37 @@ public:
LIB_LOG(INFO, "ObSliceAlloc init finished", K(bsize_), K(isize_), K(slice_limit_), KP(tmallocator_));
}
~ObSliceAlloc() {
tmallocator_ = NULL;
destroy();
}
int init(const int size, const int block_size, BlockAlloc& block_alloc, const ObMemAttr& attr) {
int ret = common::OB_SUCCESS;
new(this)ObSliceAlloc(size, attr, block_size, block_alloc, NULL);
return ret;
}
void destroy() {
for(int i = MAX_ARENA_NUM - 1; i >= 0; i--) {
Arena& arena = arena_[i];
Block* old_blk = arena.clear();
if (NULL != old_blk) {
blk_ref_[ObBlockSlicer::hash((uint64_t)old_blk) % MAX_REF_NUM].sync();
if (old_blk->release()) {
blk_list_.add(&old_blk->dlink_);
if (old_blk->recycle()) {
destroy_block(old_blk);
} else {
_LIB_LOG(ERROR, "there was memory leak, stock=%d, remain=%d", old_blk->stock(), old_blk->remain());
}
}
}
}
ObDLink* dlink = nullptr;
if (OB_NOT_NULL(dlink = blk_list_.top())) {
Block* blk = CONTAINER_OF(dlink, Block, dlink_);
_LIB_LOG(ERROR, "there was memory leak, stock=%d, remain=%d", blk->stock(), blk->remain());
}
tmallocator_ = NULL;
bsize_ = 0;
}
void set_nway(int nway) {
if (nway <= 0) {
nway = 1;
@ -351,6 +377,7 @@ public:
Block* blk = item->host_;
#ifndef NDEBUG
abort_unless(blk->get_slice_alloc() == this);
abort_unless(bsize_ != 0);
#else
if (this != blk->get_slice_alloc()) {
LIB_LOG(ERROR, "blk is freed or alloced by different slice_alloc", K(this), K(blk->get_slice_alloc()));
@ -391,7 +418,7 @@ private:
}
void add_to_blist(Block* blk) {
blk_list_.add(&blk->dlink_);
if (blk->recyle()) {
if (blk->recycle()) {
destroy_block(blk);
}
}

View File

@ -25,6 +25,7 @@ namespace common
extern ObBlockAllocMgr default_blk_alloc;
class ObBlockVSlicer
{
friend class ObVSliceAlloc;
public:
static const uint32_t ITEM_MAGIC_CODE = 0XCCEEDDF1;
static const uint32_t ITEM_MAGIC_CODE_MASK = 0XFFFFFFF0;
@ -72,6 +73,7 @@ private:
class ObVSliceAlloc : public common::ObIAllocator
{
friend class ObBlockVSlicer;
public:
enum { MAX_ARENA_NUM = 32, DEFAULT_BLOCK_SIZE = OB_MALLOC_NORMAL_BLOCK_SIZE };
typedef ObBlockAllocMgr BlockAlloc;
@ -91,12 +93,31 @@ public:
ObVSliceAlloc(): nway_(0), bsize_(0), blk_alloc_(default_blk_alloc) {}
ObVSliceAlloc(const ObMemAttr &attr, int block_size = DEFAULT_BLOCK_SIZE, BlockAlloc &blk_alloc = default_blk_alloc)
: nway_(1), bsize_(block_size), mattr_(attr), blk_alloc_(blk_alloc) {}
virtual ~ObVSliceAlloc() override {}
virtual ~ObVSliceAlloc() override { destroy(); }
int init(int block_size, BlockAlloc& block_alloc, const ObMemAttr& attr) {
int ret = OB_SUCCESS;
new(this)ObVSliceAlloc(attr, block_size, block_alloc);
return ret;
}
void destroy() {
for(int i = MAX_ARENA_NUM - 1; i >= 0; i--) {
Arena& arena = arena_[i];
Block* old_blk = arena.clear();
if (NULL != old_blk) {
int64_t old_pos = INT64_MAX;
if (old_blk->freeze(old_pos)) {
arena.sync();
if (old_blk->retire(old_pos)) {
destroy_block(old_blk);
} else {
// can not monitor all leak !!!
LIB_LOG(ERROR, "there was memory leak", K(old_blk->ref_));
}
}
}
}
bsize_ = 0;
}
void set_nway(int nway) {
if (nway <= 0) {
nway = 1;
@ -182,12 +203,13 @@ public:
#ifdef OB_USE_ASAN
::free(p);
#else
if (bsize_ > 0 && NULL != p) {
if (NULL != p) {
Block::Item* item = (Block::Item*)p - 1;
abort_unless(Block::ITEM_MAGIC_CODE == item->MAGIC_CODE_);
Block* blk = item->host_;
#ifndef NDEBUG
abort_unless(blk->get_vslice_alloc() == this);
abort_unless(bsize_ != 0);
#else
if (this != blk->get_vslice_alloc()) {
LIB_LOG(ERROR, "blk is freed or alloced by different vslice_alloc", K(this), K(blk->get_vslice_alloc()));

View File

@ -13,6 +13,8 @@
#include <stdlib.h>
#include "lib/checksum/ob_crc64.h"
#include "lib/ob_define.h"
#include "isa-l/crc64.h"
#include "isa-l/crc.h"
namespace oceanbase
{
@ -420,7 +422,7 @@ for RHEL4 support (GCC 3 doesn't support this instruction) */
#define crc32_sse42_byte crc = __crc32cb(crc, (uint8_t)*buf); len--, buf++
#endif /* defined(__GNUC__) && defined(__x86_64__) */
inline static uint64_t crc64_sse42(uint64_t uCRC64,
uint64_t crc64_sse42(uint64_t uCRC64,
const char *buf, int64_t len)
{
uint64_t crc = uCRC64;
@ -1102,6 +1104,14 @@ uint64_t fast_crc64_sse42_manually(uint64_t crc, const char *buf, int64_t len)
return crc;
}
//If the CPU is intel, ISA-L library for CRC can be used
uint64_t ob_crc64_isal(uint64_t uCRC64, const char* buf, int64_t cb)
{
if (buf == NULL || cb <= 0){
return uCRC64;
}
return crc32_iscsi((unsigned char*)(buf), cb, uCRC64);
}
uint64_t crc64_sse42_dispatch(uint64_t crc, const char *buf, int64_t len)
{
@ -1110,13 +1120,27 @@ uint64_t crc64_sse42_dispatch(uint64_t crc, const char *buf, int64_t len)
uint32_t b = 0;
uint32_t c = 0;
uint32_t d = 0;
asm("cpuid": "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(1));
if ((c & (1 << 20)) != 0) {
ob_crc64_sse42_func = &crc64_sse42;
_OB_LOG(INFO, "Use CPU crc32 instructs for crc64 calculate");
} else {
ob_crc64_sse42_func = &fast_crc64_sse42_manually;
_OB_LOG(INFO, "Use manual crc32 table lookup for crc64 calculate");
uint32_t vendor_info[4];
__asm__("mov $0x0, %eax\n\t");
__asm__("cpuid\n\t");
__asm__("mov %%ebx, %0\n\t":"=r" (vendor_info[0]));
__asm__("mov %%edx, %0\n\t":"=r" (vendor_info[1]));
__asm__("mov %%ecx, %0\n\t":"=r" (vendor_info[2]));
vendor_info[3]='\0';
if (strcmp((char*)vendor_info, "GenuineIntel") == 0) {
ob_crc64_sse42_func = &ob_crc64_isal;
_OB_LOG(WARN, "Use ISAL for crc64 calculate");
} else{
asm("cpuid" : "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(1));
if ((c & (1 << 20)) != 0) {
ob_crc64_sse42_func = &crc64_sse42;
_OB_LOG(WARN, "Use CPU crc32 instructs for crc64 calculate");
} else {
ob_crc64_sse42_func = &fast_crc64_sse42_manually;
_OB_LOG(WARN, "Use manual crc32 table lookup for crc64 calculate");
}
}
#elif defined(__aarch64__)
#if 1

View File

@ -68,6 +68,8 @@ inline uint64_t ob_crc64_sse42(const void *pv, int64_t cb)
return (*ob_crc64_sse42_func)(0, static_cast<const char *>(pv), cb);
}
uint64_t ob_crc64_isal(uint64_t uCRC64, const char* buf, int64_t cb);
uint64_t crc64_sse42(uint64_t uCRC64, const char* buf, int64_t len);
uint64_t crc64_sse42_manually(uint64_t crc, const char *buf, int64_t len);
uint64_t fast_crc64_sse42_manually(uint64_t crc, const char *buf, int64_t len);

View File

@ -182,10 +182,18 @@ struct ShareMemMgrTag { };
/* Don't use this mode unless you know what it means. */
struct UniqueMemMgrTag { };
// avoid allocator destructed before HashMap
template <typename Key, typename Value, typename MemMgrTag>
struct ConstructGuard
{
public:
ConstructGuard();
};
template <typename Key, typename Value, typename MemMgrTag = ShareMemMgrTag>
class ObLinearHashMap
class ObLinearHashMap : public ConstructGuard<Key, Value, MemMgrTag>
{
friend class ConstructGuard<Key, Value, MemMgrTag>;
private:
/* Entry. */
struct Node
@ -2372,6 +2380,12 @@ bool ObLinearHashMap<Key, Value, MemMgrTag>::DoRemoveIfOnBkt<Function>::operator
return true;
}
template <typename Key, typename Value, typename MemMgrTag>
ConstructGuard<Key, Value, MemMgrTag>::ConstructGuard()
{
auto& t = ObLinearHashMap<Key, Value, MemMgrTag>::HashMapMemMgrCore::get_instance();
}
}
}

View File

@ -1322,11 +1322,16 @@ int ObJsonBin::deserialize_json_object_v0(const char *data, uint64_t length, ObJ
} else {
// TODO if with key dict, read key from dict
// to consider, add option to controll need alloc or not
void *key_buf = allocator_->alloc(key_len);
if (key_buf == NULL) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to alloc memory for data buf", K(ret));
} else {
void *key_buf = nullptr;
if (key_len > 0) {
key_buf = allocator_->alloc(key_len);
if (key_buf == NULL) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to alloc memory for data buf", K(ret));
}
}
if (OB_SUCC(ret)) {
MEMCPY(key_buf, data + key_offset, key_len);
ObString key(key_len, reinterpret_cast<const char*>(key_buf));
const char *val = data + value_offset;

View File

@ -1049,7 +1049,7 @@ int ObJsonPath::parse_name_with_rapidjson(char*& str, uint64_t& len)
ObJsonString *val = static_cast<ObJsonString *>(dom);
len = val->value().length();
str = static_cast<char*> (allocator_->alloc(len));
if (OB_ISNULL(str)) {
if (len > 0 && OB_ISNULL(str)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to allocate memory for member_name.",
K(ret), K(len), K(val->value()));

View File

@ -628,9 +628,6 @@ int ObJsonObject::add(const common::ObString &key, ObJsonNode *value)
if (OB_ISNULL(value)) { // check param
ret = OB_INVALID_ARGUMENT;
LOG_WARN("param value is NULL", K(ret));
} else if (key.empty()) {
ret = OB_ERR_JSON_DOCUMENT_NULL_KEY;
LOG_WARN("key is NULL", K(ret));
} else {
value->set_parent(this);
ObJsonObjectPair pair(key, value);

View File

@ -68,7 +68,7 @@ private:
class ObBucketRLockGuard final
{
public:
ObBucketRLockGuard(ObBucketLock &lock, const uint64_t bucket_index)
[[nodiscard]] ObBucketRLockGuard(ObBucketLock &lock, const uint64_t bucket_index)
: lock_(lock),
index_(bucket_index),
ret_(OB_SUCCESS),
@ -109,7 +109,7 @@ private:
class ObBucketWLockGuard final
{
public:
ObBucketWLockGuard(ObBucketLock &lock, const uint64_t bucket_index)
[[nodiscard]] ObBucketWLockGuard(ObBucketLock &lock, const uint64_t bucket_index)
: lock_(lock),
index_(bucket_index),
ret_(OB_SUCCESS),
@ -150,7 +150,7 @@ private:
class ObBucketWLockAllGuard final
{
public:
ObBucketWLockAllGuard(ObBucketLock &lock)
[[nodiscard]] ObBucketWLockAllGuard(ObBucketLock &lock)
: lock_(lock),
ret_(OB_SUCCESS),
lock_start_ts_(0)
@ -189,7 +189,7 @@ private:
class ObBucketTryWLockAllGuard final
{
public:
ObBucketTryWLockAllGuard(ObBucketLock &lock)
[[nodiscard]] ObBucketTryWLockAllGuard(ObBucketLock &lock)
: lock_(lock),
ret_(OB_SUCCESS),
lock_start_ts_(0)
@ -234,7 +234,7 @@ private:
class ObBucketTryRLockAllGuard final
{
public:
ObBucketTryRLockAllGuard(ObBucketLock &lock)
[[nodiscard]] ObBucketTryRLockAllGuard(ObBucketLock &lock)
: lock_(lock),
ret_(OB_SUCCESS),
lock_start_ts_(0)
@ -279,7 +279,7 @@ private:
class ObMultiBucketLockGuard final
{
public:
ObMultiBucketLockGuard(ObBucketLock &lock, const bool is_write_lock);
[[nodiscard]] ObMultiBucketLockGuard(ObBucketLock &lock, const bool is_write_lock);
~ObMultiBucketLockGuard();
int lock_multi_buckets(ObIArray<uint64_t> &hash_array);
private:
@ -293,7 +293,7 @@ private:
class ObBucketHashRLockGuard final
{
public:
ObBucketHashRLockGuard(ObBucketLock &lock, const uint64_t hash_value)
[[nodiscard]] ObBucketHashRLockGuard(ObBucketLock &lock, const uint64_t hash_value)
: guard_(lock, lock.get_bucket_idx(hash_value))
{
}
@ -307,7 +307,7 @@ private:
class ObBucketHashWLockGuard final
{
public:
ObBucketHashWLockGuard(ObBucketLock &lock, const uint64_t hash_value)
[[nodiscard]] ObBucketHashWLockGuard(ObBucketLock &lock, const uint64_t hash_value)
: guard_(lock, lock.get_bucket_idx(hash_value))
{
}

View File

@ -34,7 +34,7 @@ public:
class RDLockGuard
{
public:
explicit RDLockGuard(DRWLock &rwlock): rwlock_(rwlock), ret_(OB_SUCCESS)
[[nodiscard]] explicit RDLockGuard(DRWLock &rwlock): rwlock_(rwlock), ret_(OB_SUCCESS)
{
if (OB_UNLIKELY(OB_SUCCESS != (ret_ = rwlock_.rdlock()))) {
COMMON_LOG(WARN, "Fail to read lock, ", K_(ret));
@ -58,7 +58,7 @@ public:
class WRLockGuard
{
public:
explicit WRLockGuard(DRWLock &rwlock): rwlock_(rwlock), ret_(OB_SUCCESS)
[[nodiscard]] explicit WRLockGuard(DRWLock &rwlock): rwlock_(rwlock), ret_(OB_SUCCESS)
{
if (OB_UNLIKELY(OB_SUCCESS != (ret_ = rwlock_.wrlock()))) {
COMMON_LOG(WARN, "Fail to write lock, ", K_(ret));

View File

@ -364,7 +364,7 @@ private:
class ObLatchMutexGuard
{
public:
ObLatchMutexGuard(ObLatchMutex &lock, const uint32_t latch_id)
[[nodiscard]] ObLatchMutexGuard(ObLatchMutex &lock, const uint32_t latch_id)
: lock_(lock), ret_(OB_SUCCESS)
{
if (OB_UNLIKELY(OB_SUCCESS != (ret_ = lock_.lock(latch_id)))) {
@ -390,7 +390,7 @@ private:
class ObLatchRGuard
{
public:
ObLatchRGuard(ObLatch &lock, const uint32_t latch_id)
[[nodiscard]] ObLatchRGuard(ObLatch &lock, const uint32_t latch_id)
: lock_(lock),
ret_(OB_SUCCESS)
{
@ -418,7 +418,7 @@ private:
class ObLatchWGuard
{
public:
ObLatchWGuard(ObLatch &lock, const uint32_t latch_id)
[[nodiscard]] ObLatchWGuard(ObLatch &lock, const uint32_t latch_id)
: lock_(lock),
ret_(OB_SUCCESS)
{

View File

@ -25,7 +25,7 @@ template <typename LockT>
class ObLockGuard
{
public:
explicit ObLockGuard(LockT &lock);
[[nodiscard]] explicit ObLockGuard(LockT &lock);
~ObLockGuard();
inline int get_ret() const { return ret_; }
private:

View File

@ -23,7 +23,7 @@ template <class T>
class ObLockGuardBase
{
public:
ObLockGuardBase(const T& lock, bool block = true) : lock_(lock)
[[nodiscard]] ObLockGuardBase(const T& lock, bool block = true) : lock_(lock)
{
acquired_ = !(block ? lock_.lock() : lock_.trylock());
}
@ -87,7 +87,7 @@ private:
class ObRLockGuard
{
public:
ObRLockGuard(const ObRWLock& rwlock, bool block = true) : guard_((*rwlock.rlock()), block) {}
[[nodiscard]] ObRLockGuard(const ObRWLock& rwlock, bool block = true) : guard_((*rwlock.rlock()), block) {}
~ObRLockGuard(){}
bool acquired() { return guard_.acquired(); }
private:
@ -97,7 +97,7 @@ private:
class ObWLockGuard
{
public:
ObWLockGuard(const ObRWLock& rwlock, bool block = true) : guard_((*rwlock.wlock()), block) {}
[[nodiscard]] ObWLockGuard(const ObRWLock& rwlock, bool block = true) : guard_((*rwlock.wlock()), block) {}
~ObWLockGuard(){}
bool acquired() { return guard_.acquired(); }
private:

View File

@ -54,13 +54,13 @@ public:
enum { WRITE_MASK = 1<<31 };
struct RLockGuard
{
explicit RLockGuard(TCRWLock& lock): lock_(lock) { lock_.rdlock(); }
[[nodiscard]] explicit RLockGuard(TCRWLock& lock): lock_(lock) { lock_.rdlock(); }
~RLockGuard() { lock_.rdunlock(); }
TCRWLock& lock_;
};
struct RLockGuardWithTimeout
{
explicit RLockGuardWithTimeout(TCRWLock &lock, const int64_t abs_timeout_us, int &ret): lock_(lock), need_unlock_(true)
[[nodiscard]] explicit RLockGuardWithTimeout(TCRWLock &lock, const int64_t abs_timeout_us, int &ret): lock_(lock), need_unlock_(true)
{
if (OB_FAIL(lock_.rdlock(abs_timeout_us))) {
need_unlock_ = false;
@ -80,13 +80,13 @@ public:
};
struct WLockGuard
{
explicit WLockGuard(TCRWLock& lock): lock_(lock) { lock_.wrlock(); }
[[nodiscard]] explicit WLockGuard(TCRWLock& lock): lock_(lock) { lock_.wrlock(); }
~WLockGuard() { lock_.wrunlock(); }
TCRWLock& lock_;
};
struct WLockGuardWithTimeout
{
explicit WLockGuardWithTimeout(TCRWLock &lock, const int64_t abs_timeout_us, int &ret): lock_(lock), need_unlock_(true)
[[nodiscard]] explicit WLockGuardWithTimeout(TCRWLock &lock, const int64_t abs_timeout_us, int &ret): lock_(lock), need_unlock_(true)
{
if (OB_FAIL(lock_.wrlock(abs_timeout_us))) {
need_unlock_ = false;
@ -106,7 +106,7 @@ public:
};
struct WLockGuardWithRetry
{
explicit WLockGuardWithRetry(TCRWLock &lock, const int64_t abs_timeout_us) : lock_(lock)
[[nodiscard]] explicit WLockGuardWithRetry(TCRWLock &lock, const int64_t abs_timeout_us) : lock_(lock)
{
lock_.wrlock_with_retry(abs_timeout_us);
}
@ -115,7 +115,7 @@ public:
};
struct WLockGuardWithRetryInterval
{
explicit WLockGuardWithRetryInterval(TCRWLock &lock,
[[nodiscard]] explicit WLockGuardWithRetryInterval(TCRWLock &lock,
const int64_t try_thresold_us,
const int64_t retry_interval_us)
: lock_(lock)
@ -287,7 +287,7 @@ private:
class TCWLockGuard
{
public:
explicit TCWLockGuard(const TCRWLock &lock)
[[nodiscard]] explicit TCWLockGuard(const TCRWLock &lock)
: lock_(const_cast<TCRWLock&>(lock)), ret_(OB_SUCCESS)
{
if (OB_UNLIKELY(OB_SUCCESS != (ret_ = lock_.wrlock()))) {
@ -313,7 +313,7 @@ private:
class TCRLockGuard
{
public:
explicit TCRLockGuard(const TCRWLock &lock)
[[nodiscard]] explicit TCRLockGuard(const TCRWLock &lock)
: lock_(const_cast<TCRWLock&>(lock)), ret_(OB_SUCCESS), slot_id_(0)
{
if (OB_UNLIKELY(OB_SUCCESS != (ret_ = lock_.rdlock(INT64_MAX, slot_id_)))) {
@ -342,7 +342,7 @@ typedef TCRWLock RWLock;
class RWLock
{
public:
struct RLockGuard
[[nodiscard]] struct RLockGuard
{
explicit RLockGuard(RWLock& lock): lock_(lock) { lock_.rdlock(); }
~RLockGuard() { lock_.rdunlock(); }
@ -350,7 +350,7 @@ public:
};
struct RLockGuardWithTimeout
{
explicit RLockGuardWithTimeout(RWLock &lock, const int64_t abs_timeout_us, int &ret): lock_(lock), need_unlock_(true)
[[nodiscard]] explicit RLockGuardWithTimeout(RWLock &lock, const int64_t abs_timeout_us, int &ret): lock_(lock), need_unlock_(true)
{
if (OB_FAIL(lock_.rdlock(abs_timeout_us))) {
need_unlock_ = false;
@ -371,13 +371,13 @@ public:
struct WLockGuard
{
explicit WLockGuard(RWLock& lock): lock_(lock) { lock_.wrlock(); }
[[nodiscard]] explicit WLockGuard(RWLock& lock): lock_(lock) { lock_.wrlock(); }
~WLockGuard() { lock_.wrunlock(); }
RWLock& lock_;
};
struct WLockGuardWithTimeout
{
explicit WLockGuardWithTimeout(RWLock &lock, const int64_t abs_timeout_us, int &ret): lock_(lock), need_unlock_(true)
[[nodiscard]] explicit WLockGuardWithTimeout(RWLock &lock, const int64_t abs_timeout_us, int &ret): lock_(lock), need_unlock_(true)
{
if (OB_FAIL(lock_.wrlock(abs_timeout_us))) {
need_unlock_ = false;
@ -397,7 +397,7 @@ public:
};
struct WLockGuardWithRetry
{
explicit WLockGuardWithRetry(RWLock &lock, const int64_t abs_timeout_us) : lock_(lock)
[[nodiscard]] explicit WLockGuardWithRetry(RWLock &lock, const int64_t abs_timeout_us) : lock_(lock)
{
lock_.wrlock_with_retry(abs_timeout_us);
}

View File

@ -52,7 +52,7 @@ protected:
class ThreadGuard
{
public:
ThreadGuard(ThreadMutex *mutex)
[[nodiscard]] ThreadGuard(ThreadMutex *mutex)
{
mutex_ = NULL;
if (mutex) {

View File

@ -114,6 +114,13 @@ STAT_EVENT_ADD_DEF(HA_GTS_HANDLE_GET_REQUEST_COUNT, "ha gts handle get request c
STAT_EVENT_ADD_DEF(HA_GTS_SEND_GET_RESPONSE_COUNT, "ha gts send get response count", ObStatClassIds::TRANS, "ha gts send get response count", 30070, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_HANDLE_PING_REQUEST_COUNT, "ha gts handle ping request count", ObStatClassIds::TRANS, "ha gts handle ping request count", 30071, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_HANDLE_PING_RESPONSE_COUNT, "ha gts handle ping response count", ObStatClassIds::TRANS, "ha gts handle ping response count", 30072, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_SOURCE_REQUEST_COUNT, "ha gts source request count", ObStatClassIds::TRANS, "ha gts source request count", 30073, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_SOURCE_REQUEST_COST_TIME, "ha gts source request cost time", ObStatClassIds::TRANS, "ha gts source request cost time", 30074, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_CACHE_HIT_COUNT, "ha gts cache hit count", ObStatClassIds::TRANS, "ha gts cache hit count", 30075, true, true)
STAT_EVENT_ADD_DEF(HA_GTS_CACHE_MISS_COUNT, "ha gts cache miss count", ObStatClassIds::TRANS, "ha gts cache miss count", 30076, true, true)
STAT_EVENT_ADD_DEF(TRANS_ELR_ENABLE_COUNT, "trans early lock release enable count", ObStatClassIds::TRANS, "trans early lock releaes enable count", 30077, true, true)
STAT_EVENT_ADD_DEF(TRANS_ELR_UNABLE_COUNT, "trans early lock release unable count", ObStatClassIds::TRANS, "trans early lock releaes unable count", 30078, true, true)
STAT_EVENT_ADD_DEF(READ_ELR_ROW_COUNT, "read elr row count", ObStatClassIds::TRANS, "read elr row count", 30079, true, true)
// SQL
//STAT_EVENT_ADD_DEF(PLAN_CACHE_HIT, "PLAN_CACHE_HIT", SQL, "PLAN_CACHE_HIT")

View File

@ -41,13 +41,16 @@ TEST(TestCrc64, common)
const int64_t STR_LEN = 10240;
char *tmp_str = new char[STR_LEN];
char *str = NULL;
uint64_t intermediate_hash = 0;
for (int64_t i = 1; i < (STR_LEN - 1); ++i) {
str = rand_str(tmp_str, i);
uint64_t manually_hash = crc64_sse42_manually(0, str, i);
uint64_t fast_manually_hash = fast_crc64_sse42_manually(0, str, i);
uint64_t sse42_hash = ob_crc64(0, str, i);
uint64_t manually_hash = crc64_sse42_manually(intermediate_hash, str, i);
uint64_t fast_manually_hash = fast_crc64_sse42_manually(intermediate_hash, str, i);
uint64_t sse42_hash = crc64_sse42(intermediate_hash, str, i);
uint64_t isal_hash = ob_crc64_isal(intermediate_hash, str, i);
ASSERT_EQ(manually_hash, fast_manually_hash);
ASSERT_EQ(manually_hash, sse42_hash);
ASSERT_EQ(manually_hash, isal_hash);
//cout << "st = "<< tmp_str << endl;
//cout << "crc64c = "<< manually_hash << endl;
}
@ -77,11 +80,19 @@ TEST(TestCrc64, test_speed)
start = get_current_time_us();
for (int64_t j = 0; j < COUNT; ++j) {
ob_crc64(0, tmp_str, i);
crc64_sse42(0, tmp_str, i);
}
end = get_current_time_us();
cout << " ob_crc64(sse42), execut_count = "<< COUNT << ", cost_us = " << end - start << " len = " << i << endl;
start = get_current_time_us();
for (int64_t j = 0; j < COUNT; ++j) {
ob_crc64_isal(0, tmp_str, i);
}
end = get_current_time_us();
cout << " ob_crc64(ob_crc64_isal), execut_count = " << COUNT << ", cost_us = " << end - start << " len = " << i
<< endl;
cout << endl;
cout << endl;
}

View File

@ -129,7 +129,8 @@ ObApplyServiceQueueTask::ObApplyServiceQueueTask()
: ObApplyServiceTask(),
total_submit_cb_cnt_(0),
last_check_submit_cb_cnt_(0),
total_apply_cb_cnt_(0)
total_apply_cb_cnt_(0),
idx_(-1)
{
type_ = ObApplyServiceTaskType::APPLY_LOG_TASK;
}
@ -149,21 +150,24 @@ void ObApplyServiceQueueTask::reset()
total_submit_cb_cnt_ = 0;
last_check_submit_cb_cnt_ = 0;
total_apply_cb_cnt_ = 0;
idx_ = -1;
}
int ObApplyServiceQueueTask::init(ObApplyStatus *apply_status)
int ObApplyServiceQueueTask::init(ObApplyStatus *apply_status,
const int64_t idx)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(apply_status)) {
if (OB_ISNULL(apply_status) || idx < 0) {
ret = OB_INVALID_ARGUMENT;
CLOG_LOG(WARN, "invalid argument", K(type_), K(apply_status), K(ret));
CLOG_LOG(WARN, "invalid argument", K(type_), K(apply_status), K(idx), K(ret));
} else {
apply_status_ = apply_status;
type_ = ObApplyServiceTaskType::APPLY_LOG_TASK;
total_submit_cb_cnt_ = 0;
last_check_submit_cb_cnt_ = 0;
total_apply_cb_cnt_ = 0;
CLOG_LOG(INFO, "ObApplyServiceQueueTask init success", K(type_), K(apply_status));
idx_ = idx;
CLOG_LOG(INFO, "ObApplyServiceQueueTask init success", K(type_), K(apply_status), K(idx_));
}
return ret;
}
@ -236,6 +240,11 @@ int ObApplyServiceQueueTask::is_apply_done(bool &is_done)
return ret;
}
int64_t ObApplyServiceQueueTask::idx() const
{
return idx_;
}
//---------------ObApplyStatus---------------//
ObApplyStatus::ObApplyStatus()
: is_inited_(false),
@ -285,7 +294,7 @@ int ObApplyStatus::init(const share::ObLSID &id,
CLOG_LOG(WARN, "failed to init submit_task", K(ret), K(id));
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < APPLY_TASK_QUEUE_SIZE; ++i) {
if (OB_FAIL(cb_queues_[i].init(this))) {
if (OB_FAIL(cb_queues_[i].init(this, i))) {
CLOG_LOG(WARN, "failed to init cb_queues", K(ret), K(id));
}
}
@ -451,6 +460,7 @@ int ObApplyStatus::try_handle_cb_queue(ObApplyServiceQueueTask *cb_queue,
int64_t append_finish_time = OB_INVALID_TIMESTAMP;
int64_t cb_first_handle_time = OB_INVALID_TIMESTAMP;
int64_t cb_start_time = OB_INVALID_TIMESTAMP;
int64_t idx = cb_queue->idx();
RLockGuard guard(lock_);
do {
ObLink *link = NULL;
@ -476,7 +486,7 @@ int ObApplyStatus::try_handle_cb_queue(ObApplyServiceQueueTask *cb_queue,
ret = OB_SUCCESS;
}
statistics_cb_cost_(lsn, scn, append_start_time, append_finish_time,
cb_first_handle_time, cb_start_time);
cb_first_handle_time, cb_start_time, idx);
cb_queue->inc_total_apply_cb_cnt();
}
} else if (FOLLOWER == role_) {
@ -492,7 +502,7 @@ int ObApplyStatus::try_handle_cb_queue(ObApplyServiceQueueTask *cb_queue,
ret = OB_SUCCESS;
}
statistics_cb_cost_(lsn, scn, append_start_time, append_finish_time,
cb_first_handle_time, cb_start_time);
cb_first_handle_time, cb_start_time, idx);
cb_queue->inc_total_apply_cb_cnt();
}
} else {
@ -814,6 +824,7 @@ int ObApplyStatus::handle_drop_cb_queue_(ObApplyServiceQueueTask &cb_queue)
int64_t append_finish_time = OB_INVALID_TIMESTAMP;
int64_t cb_first_handle_time = OB_INVALID_TIMESTAMP;
int64_t cb_start_time = OB_INVALID_TIMESTAMP;
int64_t idx = cb_queue.idx();
do {
ObLink *link = NULL;
AppendCb *cb = NULL;
@ -836,7 +847,7 @@ int ObApplyStatus::handle_drop_cb_queue_(ObApplyServiceQueueTask &cb_queue)
ret = OB_SUCCESS;
}
statistics_cb_cost_(lsn, scn, append_start_time, append_finish_time,
cb_first_handle_time, cb_start_time);
cb_first_handle_time, cb_start_time, idx);
cb_queue.inc_total_apply_cb_cnt();
}
} while (OB_SUCC(ret) && (!is_queue_empty));
@ -867,7 +878,8 @@ void ObApplyStatus::statistics_cb_cost_(const LSN &lsn,
const int64_t append_start_time,
const int64_t append_finish_time,
const int64_t cb_first_handle_time,
const int64_t cb_start_time)
const int64_t cb_start_time,
const int64_t idx)
{
// no need to print debug log when config [default value is true] is false;
if (GCONF.enable_record_trace_log) {
@ -882,7 +894,7 @@ void ObApplyStatus::statistics_cb_cost_(const LSN &lsn,
cb_wait_commit_stat_.stat(cb_wait_commit_time);
cb_execute_stat_.stat(cb_cost_time);
if (total_cost_time > 1000 * 1000) { //1s
CLOG_LOG(WARN, "cb cost too much time", K(lsn), K(scn), K(total_cost_time), K(append_cost_time),
CLOG_LOG(WARN, "cb cost too much time", K(lsn), K(scn), K(idx), K(total_cost_time), K(append_cost_time),
K(cb_wait_thread_time), K(cb_wait_commit_time), K(cb_cost_time), K(append_start_time), K(append_finish_time),
K(cb_first_handle_time), K(cb_first_handle_time), K(cb_finish_time));
}

View File

@ -107,7 +107,8 @@ public:
public:
ObApplyServiceQueueTask();
~ObApplyServiceQueueTask();
int init(ObApplyStatus *apply_status);
int init(ObApplyStatus *apply_status,
const int64_t idx);
void reset() override;
public:
Link *top();
@ -120,15 +121,18 @@ public:
void set_snapshot_check_submit_cb_cnt();
int is_snapshot_apply_done(bool &is_done);
int is_apply_done(bool &is_done);
int64_t idx() const;
INHERIT_TO_STRING_KV("ObApplyServiceQueueTask", ObApplyServiceTask,
K(total_submit_cb_cnt_),
K(last_check_submit_cb_cnt_),
K(total_apply_cb_cnt_));
K(total_apply_cb_cnt_),
K(idx_));
private:
int64_t total_submit_cb_cnt_;
int64_t last_check_submit_cb_cnt_;
int64_t total_apply_cb_cnt_;
common::ObSpLinkQueue queue_;
int64_t idx_;
};
class ObApplyStatus
@ -185,7 +189,8 @@ private:
const int64_t append_start_time,
const int64_t append_finish_time,
const int64_t cb_first_handle_time,
const int64_t cb_start_time);
const int64_t cb_start_time,
const int64_t idx);
private:
typedef common::RWLock RWLock;
typedef RWLock::RLockGuard RLockGuard;

View File

@ -13,20 +13,21 @@
#include "ob_log_request_handler.h"
#include "ob_log_rpc_req.h"
#include "logservice/ob_log_service.h"
#include "logservice/palf/log_define.h"
namespace oceanbase
{
namespace logservice
{
LogRequestHandler::LogRequestHandler(palf::PalfHandle *palf_handle) : palf_handle_(palf_handle)
LogRequestHandler::LogRequestHandler(palf::PalfHandle *palf_handle) : palf_handle_(palf_handle),
handle_request_print_time_(OB_INVALID_TIMESTAMP)
{
}
LogRequestHandler::~LogRequestHandler()
{
palf_handle_ = NULL;
handle_request_print_time_ = OB_INVALID_TIMESTAMP;
}
template <>
@ -43,6 +44,7 @@ int LogRequestHandler::handle_sync_request<LogConfigChangeCmd, LogConfigChangeCm
} else {
ConfigChangeCmdHandler cmd_handler(palf_handle_);
if (OB_FAIL(cmd_handler.handle_config_change_cmd(req))) {
if (palf::palf_reach_time_interval(100 * 1000, handle_request_print_time_))
PALF_LOG(WARN, "handle_config_change_cmd failed", K(ret), K(palf_id), K(server), K(req), KPC(palf_handle_));
} else {
PALF_LOG(INFO, "handle_config_change_cmd success", K(ret), K(palf_id), K(server), K(req), K(resp), KPC(palf_handle_));

View File

@ -34,6 +34,7 @@ public:
RespType &resp);
private:
palf::PalfHandle *palf_handle_;
int64_t handle_request_print_time_;
};
class ConfigChangeCmdHandler{

View File

@ -168,6 +168,9 @@ void ObLogHandler::destroy()
apply_status_ = NULL;
apply_service_ = NULL;
replay_service_ = NULL;
if (true == palf_handle_.is_valid()) {
palf_env_->close(palf_handle_);
}
lc_cb_ = NULL;
rpc_proxy_ = NULL;
palf_env_ = NULL;

View File

@ -311,7 +311,9 @@ int ObLogService::create_ls(const share::ObLSID &id,
return ret;
}
int ObLogService::remove_ls(const ObLSID &id)
int ObLogService::remove_ls(const ObLSID &id,
ObLogHandler &log_handler,
ObLogRestoreHandler &restore_handler)
{
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {
@ -322,10 +324,14 @@ int ObLogService::remove_ls(const ObLSID &id)
} else if (OB_FAIL(replay_service_.remove_ls(id))) {
CLOG_LOG(WARN, "failed to remove from replay_service", K(ret), K(id));
// NB: remove palf_handle lastly.
} else if (OB_FAIL(palf_env_->remove(id.id()))) {
CLOG_LOG(WARN, "failed to remove from palf_env_", K(ret), K(id));
} else {
FLOG_INFO("ObLogService remove_ls success", K(ret), K(id));
log_handler.destroy();
restore_handler.destroy();
if (OB_FAIL(palf_env_->remove(id.id()))) {
CLOG_LOG(WARN, "failed to remove from palf_env_", K(ret), K(id));
} else {
FLOG_INFO("ObLogService remove_ls success", K(ret), K(id));
}
}
return ret;

View File

@ -124,7 +124,9 @@ public:
ObLogRestoreHandler &restore_handler);
//删除日志流接口:外层调用create_ls()之后,后续流程失败,需要调用remove_ls()
int remove_ls(const share::ObLSID &id);
int remove_ls(const share::ObLSID &id,
ObLogHandler &log_handler,
ObLogRestoreHandler &restore_handler);
int check_palf_exist(const share::ObLSID &id, bool &exist) const;
//宕机重启恢复日志流接口,包括生成并初始化对应的ObReplayStatus结构

View File

@ -398,16 +398,16 @@ int ElectionImpl::send_(const ElectionChangeLeaderMsg &msg) const
#undef PRINT_WRAPPER
}
int ElectionImpl::revoke()
int ElectionImpl::revoke(const RoleChangeReason &reason)
{
ELECT_TIME_GUARD(500_ms);
int ret = OB_SUCCESS;
LockGuard lock_guard(lock_);
CHECK_ELECTION_INIT();
ret = proposer_.revoke();
ret = proposer_.revoke(reason);
return ret;
}
}
}
}
}

View File

@ -64,7 +64,7 @@ public:
const int64_t restart_counter,
const ObFunction<int(const int64_t, const ObAddr &)> &prepare_change_leader_cb,
const ObFunction<void(ElectionImpl *, common::ObRole, common::ObRole, RoleChangeReason)> &role_change_cb = DefaultRoleChangeCallBack());
int revoke();
int revoke(const RoleChangeReason &reason) override;
virtual void stop() override final;
virtual int set_memberlist(const MemberList &new_memberlist) override final;
virtual int change_leader_to(const common::ObAddr &dest_addr) override final;

View File

@ -688,7 +688,7 @@ int64_t ElectionProposer::to_string(char *buf, const int64_t buf_len) const
return pos;
}
int ElectionProposer::revoke()
int ElectionProposer::revoke(const RoleChangeReason &reason)
{
ELECT_TIME_GUARD(500_ms);
#define PRINT_WRAPPER K(*this)
@ -698,7 +698,7 @@ int ElectionProposer::revoke()
LOG_NONE(WARN, "i am not leader, but someone ask me to revoke", K(lbt()));
}
leader_lease_and_epoch_.reset();
if (!leader_revoke_if_lease_expired_(RoleChangeReason::AskToRevoke)) {
if (!leader_revoke_if_lease_expired_(reason)) {
LOG_NONE(WARN, "somethig wrong when revoke", K(lbt()));
}
return ret;

View File

@ -81,7 +81,7 @@ public:
}
return ret;
}
int revoke();
int revoke(const RoleChangeReason &reason);
public:
// 发prepare请求
void prepare(const common::ObRole role);

View File

@ -42,6 +42,7 @@ enum class RoleChangeReason
ChangeLeaderToRevoke = 4, // 切主流程旧主从Leader变为Follower
StopToRevoke = 5,// 选举leader调用stop接口后leader卸任
AskToRevoke = 6,// 有人要求选举卸任(???)
PalfDisableVoteToRevoke = 7,// palf disable vote触发卸任
};
class ElectionProposer;
@ -72,6 +73,7 @@ public:
int64_t &cur_leader_epoch) const = 0;
// 供role change service使用
virtual int change_leader_to(const common::ObAddr &dest_addr) = 0;
virtual int revoke(const RoleChangeReason &reason) = 0;
// 拿本机地址
virtual const common::ObAddr &get_self_addr() const = 0;
// 打印日志

View File

@ -48,6 +48,7 @@ LogConfigMgr::LogConfigMgr()
persistent_config_version_(),
barrier_print_log_time_(OB_INVALID_TIMESTAMP),
last_check_state_ts_us_(OB_INVALID_TIMESTAMP),
check_config_print_time_(OB_INVALID_TIMESTAMP),
parent_lock_(),
register_time_us_(OB_INVALID_TIMESTAMP),
parent_(),
@ -771,8 +772,10 @@ int LogConfigMgr::check_config_change_args_(const LogConfigChangeArgs &args, boo
if (args.type_ == ADD_MEMBER_AND_NUM || new_replica_num == paxos_replica_num_) {
// config change has finished successfully, do not need change again
is_already_finished = true;
PALF_LOG(INFO, "member already exists, don't need add_member/replace_member", KR(ret), K_(palf_id), K_(self),
K_(log_ms_meta), K(member), K(new_replica_num), K_(paxos_replica_num));
if (palf_reach_time_interval(100 * 1000, check_config_print_time_)) {
PALF_LOG(INFO, "member already exists, don't need add_member/replace_member", KR(ret), K_(palf_id), K_(self),
K_(log_ms_meta), K(member), K(new_replica_num), K_(paxos_replica_num));
}
} else {
ret = OB_INVALID_ARGUMENT;
PALF_LOG(INFO, "member already exists, but new_replica_num not equal to curr val", KR(ret), K_(palf_id), K_(self),

View File

@ -422,6 +422,7 @@ private:
LogConfigVersion persistent_config_version_;
mutable int64_t barrier_print_log_time_;
mutable int64_t last_check_state_ts_us_;
mutable int64_t check_config_print_time_;
// ================= Config Change =================
// ==================== Child ========================
mutable common::ObSpinLock parent_lock_;

View File

@ -937,6 +937,31 @@ int LogEngine::submit_learner_keepalive_resp(const common::ObAddr &server,
return ret;
}
int LogEngine::submit_committed_info_req(
const common::ObAddr &server,
const int64_t &msg_proposal_id,
const int64_t prev_log_id,
const int64_t &prev_log_proposal_id,
const LSN &committed_end_lsn)
{
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
PALF_LOG(ERROR, "LogEngine not init", K(ret), KPC(this));
} else if (OB_FAIL(log_net_service_.submit_committed_info_req(
server, msg_proposal_id,
prev_log_id, prev_log_proposal_id, committed_end_lsn))) {
PALF_LOG(ERROR, "LogNetService submit_committed_info_req failed", K(ret),
KPC(this), K(server),
K(prev_log_id), K(prev_log_proposal_id), K(committed_end_lsn));
} else {
PALF_LOG(TRACE, "submit_committed_info_req success", K(ret), KPC(this),
K(server), K(msg_proposal_id), K(prev_log_id),
K(prev_log_proposal_id), K(committed_end_lsn));
}
return ret;
}
LogMeta LogEngine::get_log_meta() const
{
ObSpinLockGuard guard(log_meta_lock_);

View File

@ -320,7 +320,12 @@ public:
int submit_notify_rebuild_req(const ObAddr &server,
const LSN &base_lsn,
const LogInfo &base_prev_log_info);
int submit_committed_info_req(
const ObAddr &server,
const int64_t &msg_proposal_id,
const int64_t prev_log_id,
const int64_t &prev_log_proposal_id,
const LSN &committed_end_lsn);
// @brief: this function used to send committed_info to child replica
// @param[in] member_list: current paxos member list
// @param[in] msg_proposal_id: the current proposal_id

View File

@ -94,6 +94,25 @@ int LogNetService::submit_push_log_req(
return ret;
}
int LogNetService::submit_committed_info_req(
const common::ObAddr &server,
const int64_t &msg_proposal_id,
const int64_t prev_log_id,
const int64_t &prev_log_proposal_id,
const LSN &committed_end_lsn)
{
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
PALF_LOG(ERROR, "LogNetService has not inited!!!", K(ret));
} else {
CommittedInfo committed_info_req(msg_proposal_id, prev_log_id,
prev_log_proposal_id, committed_end_lsn);
ret = post_request_to_server_(server, committed_info_req);
}
return ret;
}
int LogNetService::submit_push_log_resp(
const ObAddr &server,
const int64_t &msg_proposal_id,

View File

@ -188,7 +188,11 @@ public:
int submit_retire_child_req(const common::ObAddr &server, const LogLearner &parent_itself);
int submit_learner_keepalive_req(const common::ObAddr &server, const LogLearner &sender_itself);
int submit_learner_keepalive_resp(const common::ObAddr &server, const LogLearner &sender_itself);
int submit_committed_info_req(const common::ObAddr &server,
const int64_t &msg_proposal_id,
const int64_t prev_log_id,
const int64_t &prev_log_proposal_id,
const LSN &committed_end_lsn);
template<class List>
int submit_committed_info_req(
const List &member_list,

View File

@ -69,6 +69,7 @@ LogSlidingWindow::LogSlidingWindow()
cannot_fetch_log_warn_time_(OB_INVALID_TIMESTAMP),
cannot_freeze_log_warn_time_(OB_INVALID_TIMESTAMP),
larger_log_warn_time_(OB_INVALID_TIMESTAMP),
log_life_long_warn_time_(OB_INVALID_TIMESTAMP),
lc_cb_get_warn_time_(OB_INVALID_TIMESTAMP),
fetch_dst_invalid_warn_time_(OB_INVALID_TIMESTAMP),
commit_log_handling_lease_(),
@ -1769,8 +1770,10 @@ int LogSlidingWindow::sliding_cb(const int64_t sn, const FixedSlidingWindowSlot
log_submit_to_slide_cost_stat_.stat(fs_cb_begin_ts - log_submit_ts);
if (log_life_time > 100 * 1000) {
PALF_LOG(WARN, "log_task life cost too much time", K_(palf_id), K_(self), K(log_id), KPC(log_task),
K(fs_cb_begin_ts), K(log_life_time));
if (palf_reach_time_interval(10 * 1000, log_life_long_warn_time_)) {
PALF_LOG(WARN, "log_task life cost too much time", K_(palf_id), K_(self), K(log_id), KPC(log_task),
K(fs_cb_begin_ts), K(log_life_time));
}
}
if (OB_FAIL(checksum_.verify_accum_checksum(log_task_header.data_checksum_,
@ -2470,7 +2473,9 @@ int LogSlidingWindow::receive_log(const common::ObAddr &src_server,
"start_id", get_start_id());
} else if (OB_FAIL(guard.get_log_task(log_id, log_task))) {
if (OB_ERR_OUT_OF_LOWER_BOUND == ret) {
PALF_LOG(WARN, "this log has slide out, no need receive", K(ret), K(log_id), K_(palf_id), K_(self));
if (REACH_TIME_INTERVAL(100 * 1000)) {
PALF_LOG(WARN, "this log has slide out, no need receive", K(ret), K(log_id), K_(palf_id), K_(self));
}
} else {
PALF_LOG(ERROR, "get_log_task failed", K(ret), K(log_id), K_(palf_id), K_(self), K(group_entry_header));
}
@ -3273,7 +3278,60 @@ int LogSlidingWindow::try_update_match_lsn_map_(const common::ObAddr &server, co
return ret;
}
int LogSlidingWindow::leader_broadcast_committed_info_(const LSN &committed_end_lsn)
int LogSlidingWindow::try_send_committed_info(const common::ObAddr &server,
const LSN &log_lsn,
const LSN &log_end_lsn,
const int64_t &log_proposal_id)
{
int ret = OB_SUCCESS;
LSN committed_end_lsn;
get_committed_end_lsn_(committed_end_lsn);
const int64_t curr_proposal_id = state_mgr_->get_proposal_id();
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
} else if (!log_lsn.is_valid() || !log_end_lsn.is_valid() || INVALID_PROPOSAL_ID == log_proposal_id) {
ret = OB_INVALID_ARGUMENT;
} else if (state_mgr_->is_leader_active()) {
// Leader
int64_t last_log_id = OB_INVALID_LOG_ID;
int64_t last_log_proposal_id = INVALID_PROPOSAL_ID;
if (OB_FAIL(leader_get_committed_log_info_(committed_end_lsn, last_log_id, last_log_proposal_id))
|| OB_INVALID_LOG_ID == last_log_id) {
// no need send committed_info
} else if (OB_FAIL(log_engine_->submit_committed_info_req(server, curr_proposal_id,
last_log_id, log_proposal_id, committed_end_lsn))) {
PALF_LOG(WARN, "submit_committed_info_req failed", K(ret), K_(palf_id), K_(self), K(server));
}
} else {
// Follower
int64_t last_slide_log_id = OB_INVALID_LOG_ID;
SCN last_slide_scn;
LSN last_slide_lsn;
LSN last_slide_end_lsn;
int64_t last_slide_log_pid = INVALID_PROPOSAL_ID;
int64_t last_slide_accum_checksum = -1;
get_last_slide_log_info_(last_slide_log_id, last_slide_scn, last_slide_lsn, \
last_slide_end_lsn, last_slide_log_pid, last_slide_accum_checksum);
if (log_lsn == last_slide_lsn
&& log_proposal_id == last_slide_log_pid
&& committed_end_lsn == log_end_lsn) {
// If arg log does match with last slide log, follower can send committed_info to server.
OB_ASSERT(log_end_lsn == last_slide_end_lsn);
if (OB_FAIL(log_engine_->submit_committed_info_req(server, curr_proposal_id,
last_slide_log_id, log_proposal_id, committed_end_lsn))) {
PALF_LOG(WARN, "submit_committed_info_req failed", K(ret), K_(palf_id), K_(self), K(server));
} else {
PALF_LOG(TRACE, "follower try_send_committed_info success", K(ret), K_(palf_id), K_(self),
K(last_slide_log_id), K(log_proposal_id), K(committed_end_lsn));
}
}
}
return ret;
}
int LogSlidingWindow::leader_get_committed_log_info_(const LSN &committed_end_lsn,
int64_t &log_id,
int64_t &log_proposal_id)
{
int ret = OB_SUCCESS;
const int64_t max_log_id = get_max_log_id();
@ -3289,25 +3347,38 @@ int LogSlidingWindow::leader_broadcast_committed_info_(const LSN &committed_end_
// log_task is invalid or not freezed, that means there is maybe new log after committed_end_lsn.
// No need broadcast commonitted_info.
} else {
int64_t log_proposal_id = INVALID_PROPOSAL_ID;
LSN log_end_lsn;
log_task->lock();
log_proposal_id = log_task->get_proposal_id();
log_end_lsn = log_task->get_begin_lsn() + LogGroupEntryHeader::HEADER_SER_SIZE + log_task->get_data_len();
log_task->unlock();
if (log_end_lsn == committed_end_lsn) {
ObMemberList dst_member_list;
const int64_t curr_proposal_id = state_mgr_->get_proposal_id();
if (OB_FAIL(mm_->get_curr_member_list(dst_member_list))) {
PALF_LOG(WARN, "get_curr_member_list failed", K(ret), K_(palf_id), K_(self));
} else if (OB_FAIL(dst_member_list.remove_server(self_))) {
PALF_LOG(WARN, "dst_member_list remove_server failed", K(ret), K_(palf_id), K_(self));
} else if (dst_member_list.is_valid()
&& OB_FAIL(log_engine_->submit_committed_info_req(dst_member_list, curr_proposal_id,
max_log_id, log_proposal_id, committed_end_lsn))) {
} else {}
log_id = max_log_id;
}
PALF_LOG(TRACE, "leader_broadcast_committed_info_", K(ret), K_(palf_id), K_(self), K(max_log_id));
}
return ret;
}
int LogSlidingWindow::leader_broadcast_committed_info_(const LSN &committed_end_lsn)
{
int ret = OB_SUCCESS;
const int64_t curr_proposal_id = state_mgr_->get_proposal_id();
int64_t log_id = OB_INVALID_LOG_ID;
int64_t log_proposal_id = INVALID_PROPOSAL_ID;
ObMemberList dst_member_list;
if (OB_FAIL(leader_get_committed_log_info_(committed_end_lsn, log_id, log_proposal_id))
|| OB_INVALID_LOG_ID == log_id) {
// no need send committed_info
} else if (OB_FAIL(mm_->get_curr_member_list(dst_member_list))) {
PALF_LOG(WARN, "get_curr_member_list failed", K(ret), K_(palf_id), K_(self));
} else if (OB_FAIL(dst_member_list.remove_server(self_))) {
PALF_LOG(WARN, "dst_member_list remove_server failed", K(ret), K_(palf_id), K_(self));
} else if (dst_member_list.is_valid()
&& OB_FAIL(log_engine_->submit_committed_info_req(dst_member_list, curr_proposal_id,
log_id, log_proposal_id, committed_end_lsn))) {
PALF_LOG(WARN, "submit_committed_info_req failed", K(ret), K_(palf_id), K_(self), K(log_id));
} else {
PALF_LOG(TRACE, "leader_broadcast_committed_info_", K(ret), K_(palf_id), K_(self), K(log_id));
}
return ret;
}

View File

@ -191,6 +191,10 @@ public:
virtual int set_location_cache_cb(PalfLocationCacheCb *lc_cb);
virtual int reset_location_cache_cb();
virtual int advance_reuse_lsn(const LSN &flush_log_end_lsn);
virtual int try_send_committed_info(const common::ObAddr &server,
const LSN &log_lsn,
const LSN &log_end_lsn,
const int64_t &log_proposal_id);
TO_STRING_KV(K_(palf_id), K_(self), K_(lsn_allocator), K_(group_buffer), \
K_(last_submit_lsn), K_(last_submit_end_lsn), K_(last_submit_log_id), K_(last_submit_log_pid), \
K_(max_flushed_lsn), K_(max_flushed_end_lsn), K_(max_flushed_log_pid), K_(committed_end_lsn), \
@ -304,6 +308,9 @@ private:
const char *buf,
const int64_t buf_len,
SCN &min_scn);
int leader_get_committed_log_info_(const LSN &committed_end_lsn,
int64_t &log_id,
int64_t &log_proposal_id);
int leader_broadcast_committed_info_(const LSN &committed_end_lsn);
int submit_push_log_resp_(const common::ObAddr &server, const int64_t &msg_proposal_id, const LSN &lsn);
inline int try_push_log_to_paxos_follower_(const int64_t curr_proposal_id,
@ -412,6 +419,7 @@ private:
mutable int64_t cannot_fetch_log_warn_time_;
mutable int64_t cannot_freeze_log_warn_time_;
mutable int64_t larger_log_warn_time_;
mutable int64_t log_life_long_warn_time_;
mutable int64_t lc_cb_get_warn_time_;
mutable int64_t fetch_dst_invalid_warn_time_;
common::ObThreadLease commit_log_handling_lease_; // thread lease for handling committed logs

View File

@ -217,9 +217,9 @@ bool LogStateMgr::is_state_changed()
state_changed = follower_need_update_role_(new_leader, new_leader_epoch);
}
} else if (is_leader_reconfirm_()) {
state_changed = leader_reconfirm_need_switch_();
state_changed = (leader_reconfirm_need_switch_() || false == is_allow_vote());
} else if (is_leader_active_()) {
state_changed = leader_active_need_switch_(is_error);
state_changed = (leader_active_need_switch_(is_error) || false == is_allow_vote());
} else {}
return state_changed;
}
@ -292,6 +292,10 @@ int LogStateMgr::switch_state()
need_next_loop = true; // 1) drive reconfirm or 2) fetch log from leader
}
} else if (is_leader_reconfirm_()) {
if (false == is_allow_vote()
&& OB_FAIL(election_->revoke(election::RoleChangeReason::PalfDisableVoteToRevoke))) {
PALF_LOG(WARN, "election revoke failed", K(ret), K_(palf_id));
}
if (is_reconfirm_need_start_()) {
ret = reconfirm_->reconfirm();
if (OB_EAGAIN == ret) {
@ -313,12 +317,12 @@ int LogStateMgr::switch_state()
// do nothing
}
} else if (is_leader_active_()) {
if (false == is_allow_vote()
&& OB_FAIL(election_->revoke(election::RoleChangeReason::PalfDisableVoteToRevoke))) {
PALF_LOG(WARN, "election revoke failed", K(ret), K_(palf_id));
}
bool is_error = false;
if (leader_active_need_switch_(is_error)) {
if (is_error) {
// const uint32_t revoke_type = RevokeType::CLOG_SW_TIMEOUT;
// revoke_leader_(revoke_type);
}
ret = leader_active_to_follower_pending_();
need_next_loop = true;
}
@ -578,7 +582,8 @@ int LogStateMgr::follower_pending_to_reconfirm_(const int64_t new_leader_epoch)
int LogStateMgr::reconfirm_to_follower_pending_()
{
PALF_EVENT("reconfirm_to_follower_pending", palf_id_, K_(self), K_(leader), K(lbt()));
PALF_EVENT("reconfirm_to_follower_pending", palf_id_, K_(self), K_(leader), "is_allow_vote",
is_allow_vote(), K(lbt()));
int ret = OB_SUCCESS;
if (OB_FAIL(to_follower_pending_())) {
PALF_LOG(WARN, "to_follower_pending_ failed, try again", K(ret), K_(palf_id));
@ -739,9 +744,7 @@ bool LogStateMgr::follower_active_need_switch_()
bool state_changed = false;
common::ObAddr new_leader;
if (need_update_leader_(new_leader)) {
if (new_leader.is_valid() || !leader_.is_valid() || leader_epoch_ == OB_INVALID_TIMESTAMP) {
state_changed = true;
}
state_changed = true;
} else if (new_leader.is_valid()
&& self_ == new_leader) {
state_changed = true;
@ -902,7 +905,8 @@ bool LogStateMgr::follower_need_update_role_(common::ObAddr &new_leader,
new_leader_epoch = OB_INVALID_TIMESTAMP;
} else {
bool_ret = (self_ == new_leader);
PALF_LOG(TRACE, "follower_need_update_role_", K(new_leader), K(new_leader_epoch));
PALF_LOG(TRACE, "follower_need_update_role_", K(bool_ret), K(new_leader), K(new_leader_epoch),
"is_allow_vote", is_allow_vote());
}
return bool_ret;
}
@ -914,14 +918,6 @@ void LogStateMgr::set_leader_and_epoch_(const common::ObAddr &new_leader, const
PALF_LOG(INFO, "set_leader_and_epoch_", K_(palf_id), K_(self), K(leader_), K(leader_epoch_), K(new_leader));
}
int LogStateMgr::revoke_leader_(const uint32_t revoke_type)
{
int ret = OB_SUCCESS;
UNUSED(revoke_type);
// election_->leader_revoke(revoke_type);
return ret;
}
int LogStateMgr::get_elect_leader_(common::ObAddr &leader,
int64_t &leader_epoch) const
{
@ -1020,6 +1016,7 @@ int LogStateMgr::check_and_try_fetch_log_()
} else {
last_check_start_id_ = start_id;
last_check_start_id_time_us_ = now_us;
PALF_LOG(TRACE, "sw try_fetch_log success", K(ret), K_(palf_id), K(start_id));
}
} else if (last_check_start_id_ != start_id) {
last_check_start_id_ = start_id;

View File

@ -97,7 +97,7 @@ public:
TO_STRING_KV(KP(this), K_(self), K_(palf_id), "role", role_to_string(role_), \
"state", replica_state_to_string(state_), K_(prepare_meta), K_(leader), K_(leader_epoch), \
K_(is_sync_enabled), K_(pending_end_lsn), K_(scan_disk_log_finished), K_(last_check_start_id), \
K_(reconfirm_start_time_us), KP_(palf_role_change_cb));
K_(reconfirm_start_time_us), KP_(palf_role_change_cb), K_(allow_vote));
private:
bool check_role_and_state_(const common::ObRole &role, const ObReplicaState &state) const;
void update_role_and_state_(const common::ObRole &new_role, const ObReplicaState &new_state);
@ -139,7 +139,6 @@ private:
bool need_update_leader_(common::ObAddr &new_leader);
bool follower_need_update_role_(common::ObAddr &new_leader, int64_t &new_leader_epoch);
void set_leader_and_epoch_(const common::ObAddr &new_leader, const int64_t new_leader_epoch);
int revoke_leader_(const uint32_t revoke_type);
int get_elect_leader_(common::ObAddr &leader, int64_t &leader_epoch) const;
bool check_leader_log_sync_state_();
bool need_fetch_log_() const;

View File

@ -57,6 +57,8 @@ PalfHandleImpl::PalfHandleImpl()
last_check_parent_child_ts_us_(OB_INVALID_TIMESTAMP),
wait_slide_print_time_us_(OB_INVALID_TIMESTAMP),
append_size_stat_time_us_(OB_INVALID_TIMESTAMP),
replace_member_print_time_us_(OB_INVALID_TIMESTAMP),
config_change_print_time_us_(OB_INVALID_TIMESTAMP),
last_rebuild_lsn_(),
last_record_append_lsn_(PALF_INITIAL_LSN_VAL),
has_set_deleted_(false),
@ -612,7 +614,9 @@ int PalfHandleImpl::replace_member(
} else if (FALSE_IT(args.server_ = removed_member)) {
} else if (FALSE_IT(args.type_ = REMOVE_MEMBER_AND_NUM)) {
} else if (OB_FAIL(one_stage_config_change_(args, timeout_us + begin_time_us - common::ObTimeUtility::current_time()))) {
PALF_LOG(WARN, "remove_member in replace_member failed", KR(ret), K(args), KPC(this));
if (palf_reach_time_interval(100 * 1000, replace_member_print_time_us_)) {
PALF_LOG(WARN, "remove_member in replace_member failed", KR(ret), K(args), KPC(this));
}
} else if (OB_FAIL(config_mgr_.get_curr_member_list(curr_member_list))) {
PALF_LOG(WARN, "get_curr_member_list failed", KR(ret), KPC(this));
} else {
@ -1077,12 +1081,16 @@ int PalfHandleImpl::one_stage_config_change_(const LogConfigChangeArgs &args,
ret = OB_INVALID_ARGUMENT;
PALF_LOG(WARN, "invalid argument", KR(ret), KPC(this), K(args));
} else if (OB_FAIL(can_change_config_(args, curr_proposal_id))) {
PALF_LOG(WARN, "not active leader, can't change member", KR(ret), KPC(this),
"role", state_mgr_.get_role(), "state", state_mgr_.get_state());
if (palf_reach_time_interval(100 * 1000, config_change_print_time_us_)) {
PALF_LOG(WARN, "not active leader, can't change member", KR(ret), KPC(this),
"role", state_mgr_.get_role(), "state", state_mgr_.get_state());
}
} else if (OB_FAIL(check_args_and_generate_config_(args, is_already_finished, new_log_sync_memberlist, new_log_sync_replica_num))) {
PALF_LOG(WARN, "check_args_and_generate_config failed", KR(ret), KPC(this), K(args));
} else if (is_already_finished) {
PALF_LOG(INFO, "one_stage_config_change has already finished", K(ret), KPC(this), K(args));
if (palf_reach_time_interval(100 * 1000, config_change_print_time_us_)) {
PALF_LOG(INFO, "one_stage_config_change has already finished", K(ret), KPC(this), K(args));
}
} else {
PALF_LOG(INFO, "one_stage_config_change start", KPC(this), K(curr_proposal_id), K(args), K(timeout_us));
TimeoutChecker not_timeout(timeout_us);
@ -1350,7 +1358,11 @@ int PalfHandleImpl::set_allow_vote_flag_(const bool allow_vote)
flush_meta_cb_ctx.allow_vote_ = allow_vote;
LogReplicaPropertyMeta replica_property_meta = log_engine_.get_log_meta().get_log_replica_property_meta();
replica_property_meta.allow_vote_ = allow_vote;
if (OB_FAIL(log_engine_.submit_flush_replica_property_meta_task(flush_meta_cb_ctx, replica_property_meta))) {
if (false == allow_vote
&& LEADER == state_mgr_.get_role()
&& OB_FAIL(election_.revoke(RoleChangeReason::PalfDisableVoteToRevoke))) {
PALF_LOG(WARN, "election revoke failed", K(ret), K_(palf_id));
} else if (OB_FAIL(log_engine_.submit_flush_replica_property_meta_task(flush_meta_cb_ctx, replica_property_meta))) {
PALF_LOG(WARN, "submit_flush_replica_property_meta_task failed", K(ret), K(flush_meta_cb_ctx), K(replica_property_meta));
}
}
@ -1945,6 +1957,7 @@ int PalfHandleImpl::set_location_cache_cb(PalfLocationCacheCb *lc_cb)
int ret = OB_SUCCESS;
if (IS_NOT_INIT) {
ret = OB_NOT_INIT;
PALF_LOG(WARN, "not initted", KR(ret), KPC(this));
} else if (OB_ISNULL(lc_cb)) {
ret = OB_INVALID_ARGUMENT;
PALF_LOG(WARN, "lc_cb is NULL, can't register", KR(ret), KPC(this));
@ -2207,31 +2220,26 @@ int PalfHandleImpl::ack_mode_meta(const common::ObAddr &server,
int PalfHandleImpl::handle_election_message(const election::ElectionPrepareRequestMsg &msg)
{
RLockGuard guard(lock_);
return election_.handle_message(msg);
}
int PalfHandleImpl::handle_election_message(const election::ElectionPrepareResponseMsg &msg)
{
RLockGuard guard(lock_);
return election_.handle_message(msg);
}
int PalfHandleImpl::handle_election_message(const election::ElectionAcceptRequestMsg &msg)
{
RLockGuard guard(lock_);
return election_.handle_message(msg);
}
int PalfHandleImpl::handle_election_message(const election::ElectionAcceptResponseMsg &msg)
{
RLockGuard guard(lock_);
return election_.handle_message(msg);
}
int PalfHandleImpl::handle_election_message(const election::ElectionChangeLeaderMsg &msg)
{
RLockGuard guard(lock_);
return election_.handle_message(msg);
}
@ -2285,7 +2293,7 @@ int PalfHandleImpl::do_init_mem_(
has_set_deleted_ = false;
palf_env_impl_ = palf_env_impl;
is_inited_ = true;
PALF_LOG(INFO, "PalfHandleImpl do_init_ success", K(ret), K(palf_id), K(log_dir), K(palf_base_info),
PALF_LOG(INFO, "PalfHandleImpl do_init_ success", K(ret), K(palf_id), K(self), K(log_dir), K(palf_base_info),
K(log_meta), K(fetch_log_engine), K(alloc_mgr), K(log_rpc), K(log_io_worker));
}
if (OB_FAIL(ret)) {
@ -2441,7 +2449,9 @@ int PalfHandleImpl::receive_log(const common::ObAddr &server,
// rewrite -4023 to 0
ret = OB_SUCCESS;
} else {
PALF_LOG(WARN, "sw_ receive_log failed", K(ret), KPC(this), K(server), K(msg_proposal_id), K(lsn));
if (REACH_TIME_INTERVAL(100 * 1000)) {
PALF_LOG(WARN, "sw_ receive_log failed", K(ret), KPC(this), K(server), K(msg_proposal_id), K(lsn));
}
}
} else {
PALF_LOG(TRACE, "receive_log success", K(ret), KPC(this), K(server), K(msg_proposal_id), K(lsn), K(buf_len));
@ -2482,7 +2492,9 @@ int PalfHandleImpl::receive_log(const common::ObAddr &server,
if (OB_FAIL(ret)) {
} else if (OB_FAIL(sw_.receive_log(server, push_log_type, prev_lsn, prev_log_proposal_id, lsn, buf,
buf_len, false, truncate_log_info))) {
PALF_LOG(WARN, "sw_ receive_log failed", K(ret), KPC(this), K(server), K(msg_proposal_id), K(lsn));
if (REACH_TIME_INTERVAL(100 * 1000)) {
PALF_LOG(WARN, "sw_ receive_log failed", K(ret), KPC(this), K(server), K(msg_proposal_id), K(lsn));
}
} else {
PALF_LOG(INFO, "receive_log success", K(ret), KPC(this), K(server), K_(self), K(msg_proposal_id), K(prev_lsn),
K(prev_log_proposal_id), K(lsn), K(truncate_log_info));
@ -2756,13 +2768,36 @@ int PalfHandleImpl::fetch_log_from_storage(const common::ObAddr &server,
return ret;
}
int PalfHandleImpl::try_send_committed_info_(const ObAddr &server,
const LSN &log_lsn,
const LSN &log_end_lsn,
const int64_t &log_proposal_id)
{
int ret = OB_SUCCESS;
AccessMode access_mode;
if (!log_lsn.is_valid() || !log_end_lsn.is_valid() || INVALID_PROPOSAL_ID == log_proposal_id) {
ret = OB_INVALID_ARGUMENT;
} else if (OB_FAIL(mode_mgr_.get_access_mode(access_mode))) {
PALF_LOG(WARN, "get_access_mode failed", K(ret), KPC(this));
} else if (AccessMode::APPEND == access_mode) {
// No need send committed_info in APPEND mode, because leader will genenrate keeapAlive log periodically.
} else if (OB_FAIL(sw_.try_send_committed_info(server, log_lsn, log_end_lsn, log_proposal_id))) {
PALF_LOG(TRACE, "try_send_committed_info failed", K(ret), K_(palf_id), K_(self),
K(server), K(log_lsn), K(log_end_lsn), K(log_proposal_id));
} else {
PALF_LOG(TRACE, "try_send_committed_info_ success", K(ret), K_(palf_id), K_(self), K(server),
K(log_lsn), K(log_end_lsn), K(log_proposal_id));
}
return ret;
}
int PalfHandleImpl::fetch_log_from_storage_(const common::ObAddr &server,
const FetchLogType fetch_type,
const int64_t &msg_proposal_id,
const LSN &prev_lsn,
const LSN &fetch_start_lsn,
const int64_t fetch_log_size,
const int64_t fetch_log_count)
const FetchLogType fetch_type,
const int64_t &msg_proposal_id,
const LSN &prev_lsn,
const LSN &fetch_start_lsn,
const int64_t fetch_log_size,
const int64_t fetch_log_count)
{
int ret = OB_SUCCESS;
PalfGroupBufferIterator iterator;
@ -2818,6 +2853,7 @@ int PalfHandleImpl::fetch_log_from_storage_(const common::ObAddr &server,
bool is_reach_end = false;
int64_t fetched_count = 0;
LSN curr_log_end_lsn = curr_lsn + curr_group_entry.get_group_entry_size();
LSN prev_log_end_lsn;
int64_t prev_log_proposal_id = prev_log_info.log_proposal_id_;
while (OB_SUCC(ret) && !is_reach_size_limit && !is_reach_count_limit && !is_reach_end
&& OB_SUCC(iterator.next())) {
@ -2849,12 +2885,18 @@ int PalfHandleImpl::fetch_log_from_storage_(const common::ObAddr &server,
K(prev_log_proposal_id), K(fetch_end_lsn), K(curr_log_end_lsn), K(is_reach_size_limit),
K(fetch_log_size), K(fetched_count), K(is_reach_count_limit));
each_round_prev_lsn = curr_lsn;
prev_log_end_lsn = curr_log_end_lsn;
prev_log_proposal_id = curr_group_entry.get_header().get_log_proposal_id();
}
}
if (OB_ITER_END == ret) {
ret = OB_SUCCESS;
}
// try send committed_info to server
if (OB_SUCC(ret)) {
RLockGuard guard(lock_);
(void) try_send_committed_info_(server, each_round_prev_lsn, prev_log_end_lsn, prev_log_proposal_id);
}
}
if (OB_FAIL(ret) && OB_ERR_OUT_OF_LOWER_BOUND == ret) {
@ -3408,7 +3450,7 @@ int PalfHandleImpl::revoke_leader(const int64_t proposal_id)
} else if (false == state_mgr_.can_revoke(proposal_id)) {
ret = OB_NOT_MASTER;
PALF_LOG(WARN, "revoke_leader failed, not master", K(ret), K_(palf_id), K(proposal_id));
} else if (OB_FAIL(election_.revoke())) {
} else if (OB_FAIL(election_.revoke(RoleChangeReason::AskToRevoke))) {
PALF_LOG(WARN, "PalfHandleImpl revoke leader failed", K(ret), K_(palf_id));
} else {
PALF_LOG(INFO, "PalfHandleImpl revoke leader success", K(ret), K_(palf_id));

View File

@ -868,6 +868,10 @@ private:
int construct_palf_base_info_(const LSN &max_committed_lsn,
PalfBaseInfo &palf_base_info);
int append_disk_log_to_sw_(const LSN &start_lsn);
int try_send_committed_info_(const common::ObAddr &server,
const LSN &log_lsn,
const LSN &log_end_lsn,
const int64_t &log_proposal_id);
int fetch_log_from_storage_(const common::ObAddr &server,
const FetchLogType fetch_type,
const int64_t &msg_proposal_id,
@ -998,6 +1002,8 @@ private:
int64_t last_check_parent_child_ts_us_;
int64_t wait_slide_print_time_us_;
int64_t append_size_stat_time_us_;
int64_t replace_member_print_time_us_;
int64_t config_change_print_time_us_;
mutable SpinLock last_rebuild_lsn_lock_;
LSN last_rebuild_lsn_;
LSN last_record_append_lsn_;

View File

@ -317,7 +317,7 @@ int SCN::convert_for_sql(uint64_t value)
void SCN::transform_max()
{
if (share::ObScnRange::OLD_MAX_TS == val_) {
if (INT64_MAX == val_) {
this->set_max();
}
}

View File

@ -80,7 +80,7 @@ public:
// @param[in] convert for tx: INT64_MAX may convert to MAX_SCN
int convert_for_tx(int64_t commit_trans_version);
// change val_ from ObScnRange::OLD_MAX_TS to OB_MAX_SCN_TS_NS for compitibility in
// change val_ from INT64_MAX to OB_MAX_SCN_TS_NS for compitibility in
// deserialization
void transform_max();

View File

@ -211,6 +211,7 @@ public:
DELEGATE_WITH_RET(palf_handle_, switch_learner_to_acceptor, int);
DELEGATE_WITH_RET(palf_handle_, switch_acceptor_to_learner, int);
DELEGATE_WITH_RET(palf_handle_, set_region, int);
DELEGATE_WITH_RET(palf_handle_, set_location_cache_cb, int);
DELEGATE_WITH_RET(palf_handle_, change_access_mode, int);
DELEGATE_WITH_RET(palf_handle_, get_access_mode, int);
private:

View File

@ -551,7 +551,8 @@ ObReplayStatus::ObReplayStatus():
palf_handle_(),
fs_cb_(),
get_log_info_debug_time_(OB_INVALID_TIMESTAMP),
try_wrlock_debug_time_(OB_INVALID_TIMESTAMP)
try_wrlock_debug_time_(OB_INVALID_TIMESTAMP),
check_enable_debug_time_(OB_INVALID_TIMESTAMP)
{
}
@ -580,6 +581,7 @@ int ObReplayStatus::init(const share::ObLSID &id,
ls_id_ = id;
get_log_info_debug_time_ = OB_INVALID_TIMESTAMP;
try_wrlock_debug_time_ = OB_INVALID_TIMESTAMP;
check_enable_debug_time_ = OB_INVALID_TIMESTAMP;
palf_env_ = palf_env;
rp_sv_ = rp_sv;
fs_cb_ = ObReplayFsCb(this);
@ -628,6 +630,7 @@ void ObReplayStatus::destroy()
fs_cb_.destroy();
get_log_info_debug_time_ = OB_INVALID_TIMESTAMP;
try_wrlock_debug_time_ = OB_INVALID_TIMESTAMP;
check_enable_debug_time_ = OB_INVALID_TIMESTAMP;
palf_env_ = NULL;
rp_sv_ = NULL;
}
@ -864,7 +867,9 @@ int ObReplayStatus::update_end_offset(const LSN &lsn)
ret = OB_NOT_INIT;
CLOG_LOG(ERROR, "replay status is not init", K(ls_id_), K(lsn), K(ret));
} else if (!is_enabled_) {
CLOG_LOG(INFO, "replay status is not enabled", K(this), K(ret), K(lsn));
if (palf_reach_time_interval(100 * 1000, check_enable_debug_time_)) {
CLOG_LOG(INFO, "replay status is not enabled", K(this), K(ret), K(lsn));
}
} else if (OB_UNLIKELY(!lsn.is_valid())) {
ret = OB_INVALID_ARGUMENT;
CLOG_LOG(ERROR, "invalid arguments", K(ls_id_), K(lsn), K(ret));

View File

@ -597,6 +597,7 @@ private:
ObReplayFsCb fs_cb_;
mutable int64_t get_log_info_debug_time_;
mutable int64_t try_wrlock_debug_time_;
mutable int64_t check_enable_debug_time_;
DISALLOW_COPY_AND_ASSIGN(ObReplayStatus);
};

View File

@ -2083,6 +2083,13 @@ typedef enum ObItemType
T_OB_DDL_SCHEMA_VERSION,
T_TG_ORDER,
T_ODBC_ESCAPE_SEQUENCES,
// column group
T_COLUMN_GROUP,
T_ALL_COLUMN_GROUP,
T_SINGLE_COLUMN_GROUP,
T_NORMAL_COLUMN_GROUP,
T_MAX //Attention: add a new type before T_MAX
} ObItemType;

View File

@ -68,7 +68,7 @@ int ObAsyncCmdDriver::response_result(ObMySQLResultSet &result)
LOG_WARN("close result set fail", K(close_ret));
}
if (!result.is_async_end_trans_submitted()) {
retry_ctrl_.test_and_save_retry_state(gctx_, ctx_, result, ret, cli_ret);
retry_ctrl_.test_and_save_retry_state(gctx_, ctx_, result, ret, cli_ret, is_prexecute_);
LOG_WARN("result set open failed, check if need retry",
K(ret), K(cli_ret), K(retry_ctrl_.need_retry()));
ret = cli_ret;

View File

@ -79,7 +79,7 @@ int ObAsyncPlanDriver::response_result(ObMySQLResultSet &result)
// 如果try_again为true,说明这条SQL需要重做。考虑到重做之前我们需要回滚整个事务,会调用EndTransCb
// 所以这里设置一个标记,告诉EndTransCb这种情况下不要给客户端回包。
int cli_ret = OB_SUCCESS;
retry_ctrl_.test_and_save_retry_state(gctx_, ctx_, result, ret, cli_ret);
retry_ctrl_.test_and_save_retry_state(gctx_, ctx_, result, ret, cli_ret, is_prexecute_);
if (retry_ctrl_.need_retry()) {
result.set_end_trans_async(false);
}

View File

@ -114,7 +114,7 @@ int ObSyncCmdDriver::response_result(ObMySQLResultSet &result)
}
// open失败,决定是否需要重试
retry_ctrl_.test_and_save_retry_state(gctx_, ctx_, result, ret, cli_ret);
retry_ctrl_.test_and_save_retry_state(gctx_, ctx_, result, ret, cli_ret, is_prexecute_);
LOG_WARN("result set open failed, check if need retry",
K(ret), K(cli_ret), K(retry_ctrl_.need_retry()));
ret = cli_ret;

View File

@ -72,7 +72,8 @@ int ObSyncPlanDriver::response_result(ObMySQLResultSet &result)
ctx_,
result,
ret,
cli_ret);
cli_ret,
is_prexecute_);
if (OB_TRANSACTION_SET_VIOLATION != ret && OB_REPLICA_NOT_READABLE != ret) {
if (OB_TRY_LOCK_ROW_CONFLICT == ret && retry_ctrl_.need_retry()) {
//锁冲突重试不打印日志,避免刷屏
@ -107,7 +108,8 @@ int ObSyncPlanDriver::response_result(ObMySQLResultSet &result)
ctx_,
result,
ret,
cli_ret);
cli_ret,
is_prexecute_);
LOG_WARN("result response failed, check if need retry",
K(ret), K(cli_ret), K(retry_ctrl_.need_retry()));
ret = cli_ret;

View File

@ -2284,19 +2284,36 @@ int ObPLCodeGenerateVisitor::visit(const ObPLSignalStmt &s)
ObLLVMValue unwindException = generator_.get_saved_exception();
ObLLVMValue ob_error_code = generator_.get_saved_ob_error();
ObLLVMType unwind_exception_type, unwind_exception_pointer_type;
ObLLVMValue unwind_exception_header;
ObLLVMType condition_type;
ObLLVMType condition_pointer_type;
ObLLVMValue condition;
ObLLVMValue sql_state;
ObLLVMValue error_code;
CK (OB_NOT_NULL(generator_.get_saved_exception().get_v()));
CK (OB_NOT_NULL(generator_.get_saved_ob_error().get_v()));
OZ (generator_.extract_status_from_context(generator_.get_vars().at(generator_.CTX_IDX), status));
OZ (generator_.get_helper().create_store(ob_error_code, status));
OZ (generator_.get_adt_service().get_unwind_exception(unwind_exception_type));
OZ (unwind_exception_type.get_pointer_to(unwind_exception_pointer_type));
OZ (generator_.get_helper().create_const_gep1_64(ObString("extract_unwind_exception_header"),
unwindException,
generator_.get_eh_service().pl_exception_base_offset_,
unwind_exception_header));
OZ (generator_.get_adt_service().get_pl_condition_value(condition_type));
OZ (condition_type.get_pointer_to(condition_pointer_type));
OZ (generator_.get_helper().create_pointer_cast(ObString("cast_header"),
unwind_exception_header,
condition_pointer_type,
condition));
OZ (generator_.extract_name_from_condition_value(condition, sql_state));
OZ (generator_.extract_code_from_condition_value(condition, error_code));
OZ (generator_.get_helper().create_pointer_cast(
ObString("cast_unwind_exception"), unwindException,
unwind_exception_pointer_type, unwindException));
OZ (generator_.get_helper().create_block(ObString("normal"), generator_.get_func(), normal));
OZ (generator_.raise_exception(unwindException, null_sql_state, normal,
s.get_block()->in_notfound(), s.get_block()->in_warning(),
true/*is signal*/));
OZ (generator_.raise_exception(unwindException, error_code, sql_state, normal,
s.get_block()->in_notfound(), s.get_block()->in_warning(), true));
OZ (generator_.set_current(normal));
} else {
ObLLVMValue type, ob_err_code, err_code, sql_state, str_len, is_signal, stmt_id, loc;
@ -6509,7 +6526,7 @@ int ObPLCodeGenerator::generate_exception(ObLLVMValue &type,
if (OB_FAIL(helper_.create_call(ObString("create_exception"), get_eh_service().eh_create_exception_, args, exception))) {
LOG_WARN("failed to create_call", K(ret));
} else {
OZ (raise_exception(exception, sql_state, normal, in_notfound, in_warning, signal));
OZ (raise_exception(exception, error_code, sql_state, normal, in_notfound, in_warning, signal));
}
}
}
@ -6518,6 +6535,7 @@ int ObPLCodeGenerator::generate_exception(ObLLVMValue &type,
}
int ObPLCodeGenerator::raise_exception(ObLLVMValue &exception,
ObLLVMValue &error_code,
ObLLVMValue &sql_state,
ObLLVMBasicBlock &normal,
bool in_notfound,
@ -6587,26 +6605,33 @@ int ObPLCodeGenerator::raise_exception(ObLLVMValue &exception,
}
}
if (OB_SUCC(ret)) {
ObLLVMValue exception_class;
ObLLVMSwitch switch_inst;
ObLLVMValue int_value;
OZ (set_current(current));
if (OB_SUCC(ret) && lib::is_oracle_mode()) {
if (OB_FAIL(ret)) {
} else if (lib::is_oracle_mode()) {
OZ (helper_.create_br(raise_exception));
}
if (OB_SUCC(ret) && lib::is_mysql_mode()) {
if (signal && OB_ISNULL(sql_state.get_v())) {
// resignal
// TODO: SQL_WARNING错误的resignal需要特别处理
OZ (helper_.create_br(raise_exception));
} else {
OZ (helper_.create_call(ObString("get_exception_class"), get_eh_service().eh_classify_exception, sql_state, exception_class));
OZ (helper_.create_switch(exception_class, raise_exception, switch_inst));
OZ (helper_.get_int64(SQL_WARNING, int_value));
OZ (switch_inst.add_case(int_value, in_warning ? raise_exception : normal));
OZ (helper_.get_int64(NOT_FOUND, int_value));
OZ (switch_inst.add_case(int_value, signal || in_notfound ? raise_exception : normal));
}
} else if (lib::is_mysql_mode()) {
ObLLVMBasicBlock normal_raise_block;
ObLLVMValue exception_class;
ObLLVMSwitch switch_inst1;
ObLLVMSwitch switch_inst2;
ObLLVMValue int_value;
OZ (helper_.create_block(ObString("normal_raise_block"), get_func(), normal_raise_block));
OZ (helper_.create_switch(error_code, normal_raise_block, switch_inst1));
OZ (helper_.get_int64(ER_WARN_TOO_MANY_RECORDS, int_value));
OZ (switch_inst1.add_case(int_value, raise_exception));
OZ (helper_.get_int64(WARN_DATA_TRUNCATED, int_value));
OZ (switch_inst1.add_case(int_value, raise_exception));
OZ (helper_.get_int64(ER_SIGNAL_WARN, int_value));
OZ (switch_inst1.add_case(int_value, raise_exception));
OZ (set_current(normal_raise_block));
OZ (helper_.create_call(ObString("get_exception_class"), get_eh_service().eh_classify_exception, sql_state, exception_class));
OZ (helper_.create_switch(exception_class, raise_exception, switch_inst2));
OZ (helper_.get_int64(SQL_WARNING, int_value));
OZ (switch_inst2.add_case(int_value, in_warning ? raise_exception : normal));
OZ (helper_.get_int64(NOT_FOUND, int_value));
OZ (switch_inst2.add_case(int_value, signal || in_notfound ? raise_exception : normal));
}
}
return ret;

View File

@ -243,6 +243,7 @@ public:
bool in_warning,
bool signal);
int raise_exception(jit::ObLLVMValue &exception,
jit::ObLLVMValue &error_code,
jit::ObLLVMValue &sql_staten,
jit::ObLLVMBasicBlock &normal,
bool in_notfound,

View File

@ -421,7 +421,12 @@ int ObPLResolver::resolve(const ObStmtNodeTree *parse_tree, ObPLFunctionAST &fun
LOG_WARN("fail to check decalre order", K(ret));
} else if (OB_FAIL(resolve_declare_handler(parse_tree, static_cast<ObPLDeclareHandlerStmt*>(NULL == stmt ? current_block_->get_eh() : stmt), func))) {
LOG_WARN("failed to resolve declare handler stmt", K(parse_tree), K(stmt), K(ret));
} else {
} else if (stmt != NULL && static_cast<ObPLDeclareHandlerStmt*>(stmt)->get_handlers().count() <= 0) {
// continue handler will record into handler_analyzer_,
// so here handlers may null, do not add null handler to current block.
stmt = NULL;
}
if (OB_SUCC(ret)) {
func.set_is_all_sql_stmt(false);
}
}
@ -645,7 +650,7 @@ int ObPLResolver::resolve(const ObStmtNodeTree *parse_tree, ObPLFunctionAST &fun
}
if (OB_SUCC(ret) && handler_analyzer_.in_continue() && NULL != stmt && !NO_EXCEPTION_STMT(stmt->get_type())) {
//如果自己在continue里,那么把栈里的handler都加到block里
// for continue handler, should add handler to every stmt, here, make a new block, consturct new block with handler and stmt.
ObPLStmtBlock *block = NULL;
if (OB_FAIL(make_block(func, current_block_, block))) {
LOG_WARN("failed to make block", K(current_block_), K(ret));
@ -990,10 +995,22 @@ int ObPLResolver::check_declare_order(ObPLStmtType type)
CK(PL_VAR == type || PL_COND == type || PL_HANDLER == type || PL_CURSOR == type);
if (is_oracle_mode()) {
// oracle compatible, do nothing ...
} else if (OB_NOT_NULL(current_block_) && current_block_->get_stmts().count() != 0) {
ObPLStmtType pre_type =
current_block_->get_stmts().at(current_block_->get_stmts().count() - 1)->get_type();
if ((PL_VAR == type || PL_COND == type)
} else {
ObPLStmtType pre_type = INVALID_PL_STMT;
if (OB_NOT_NULL(current_block_) && (current_block_->get_stmts().count() != 0)) {
pre_type =
current_block_->get_stmts().at(current_block_->get_stmts().count() - 1)->get_type();
}
if (handler_analyzer_.get_stack_depth() > 0) {
ObPLDeclareHandlerStmt::DeclareHandler info;
if (OB_FAIL(handler_analyzer_.get_handler(handler_analyzer_.get_stack_depth() - 1, info))) {
LOG_WARN("failed to get last handler", K(ret));
} else if (info.get_level() == current_level_) {
pre_type = PL_HANDLER;
}
}
if (OB_FAIL(ret)) {
} else if ((PL_VAR == type || PL_COND == type)
&& (PL_HANDLER == pre_type || PL_CURSOR == pre_type)) {
ret = OB_ER_SP_VARCOND_AFTER_CURSHNDLR;
LOG_USER_ERROR(OB_ER_SP_VARCOND_AFTER_CURSHNDLR);
@ -5202,15 +5219,16 @@ int ObPLResolver::resolve_declare_handler(const ObStmtNodeTree *parse_tree, ObPL
ret = OB_ERR_NO_CHOICES;
LOG_WARN("no choices may appear with choice OTHERS in an exception handler",
K(ret));
} else if (OB_FAIL(desc->add_condition(value))) {
LOG_WARN("failed to add condition for delcare handler desc", K(ret), K(value));
} else {
desc->add_condition(value);
if (NOT_FOUND == actual_type && !handler_analyzer_.in_notfound()) {
handler_analyzer_.set_notfound(current_level_);
current_block_->set_notfound();
} else if (SQL_WARNING == actual_type && !handler_analyzer_.in_warning()) {
handler_analyzer_.set_warning(current_level_);
current_block_->set_warning();
} else { /*do nothing*/ }
}
}
}
}
@ -5235,17 +5253,19 @@ int ObPLResolver::resolve_declare_handler(const ObStmtNodeTree *parse_tree, ObPL
}
}
if (OB_SUCC(ret)) {
if (OB_SUCC(ret) && !desc->is_continue()) {
ObPLDeclareHandlerStmt::DeclareHandler handler;
handler.set_desc(desc);
OZ (stmt->add_handler(handler));
if (OB_FAIL(stmt->add_handler(handler))) {
LOG_WARN("failed to add handler", K(ret));
}
}
if (OB_SUCC(ret)) {
if (OB_ISNULL(current_block_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("Symbol table is NULL", K(current_block_), K(ret));
} else {
} else if (stmt->get_handlers().count() > 0) {
current_block_->set_eh(stmt);
}
}
@ -5744,7 +5764,7 @@ int ObPLResolver::resolve_cparam_with_assign(ObRawExpr* expr,
ret = OB_ERR_SP_UNDECLARED_VAR;
LOG_WARN("can not find param in param list", K(ret), K(position), K(name));
}
OZ (resolve_cparam_without_assign(call_expr, position, func, params, expr_idx));
OZ (resolve_cparam_without_assign(call_expr->get_expr(), position, func, params, expr_idx));
}
return ret;
}
@ -10497,6 +10517,13 @@ int ObPLResolver::resolve_sf_clause(
}
OX (routine_info->set_pipelined());
}
} else if (T_COMMENT == child->type_) {
if (lib::is_mysql_mode()) {
ObString routine_comment;
CK (OB_NOT_NULL(dynamic_cast<ObRoutineInfo*>(routine_info)));
OX (routine_comment = ObString(child->str_len_, child->str_value_));
OZ (dynamic_cast<ObRoutineInfo*>(routine_info)->set_comment(routine_comment));
}
}
}
}
@ -12187,7 +12214,7 @@ int ObPLResolver::check_duplicate_condition(const ObPLDeclareHandlerStmt &stmt,
{
int ret = OB_SUCCESS;
dup = false;
for (int64_t i = 0; !dup && i < stmt.get_handlers().count(); ++i) {
for (int64_t i = 0; OB_SUCC(ret) && !dup && i < stmt.get_handlers().count(); ++i) {
ObPLDeclareHandlerStmt::DeclareHandler::HandlerDesc *desc = stmt.get_handler(i).get_desc();
if (OB_ISNULL(desc)) {
ret = OB_ERR_UNEXPECTED;
@ -12203,6 +12230,29 @@ int ObPLResolver::check_duplicate_condition(const ObPLDeclareHandlerStmt &stmt,
}
}
}
for (int64_t i = handler_analyzer_.get_stack_depth() - 1; OB_SUCC(ret) && !dup && i >= 0; --i) {
ObPLDeclareHandlerStmt::DeclareHandler handler;
if (OB_FAIL(handler_analyzer_.get_handler(i, handler))) {
LOG_WARN("failed to get handler from handler analyzer", K(ret), K(i));
} else if (handler.get_level() == current_level_) {
ObPLDeclareHandlerStmt::DeclareHandler::HandlerDesc *desc = handler.get_desc();
if (OB_ISNULL(desc)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("Handler desc is NULL", K(ret), K(i), K(handler));
} else if (desc->is_continue()) {
for (int64_t j = 0; !dup && j < desc->get_conditions().count(); ++j) {
if (value.type_ == desc->get_condition(j).type_ &&
value.error_code_ == desc->get_condition(j).error_code_ &&
value.str_len_ == desc->get_condition(j).str_len_ &&
0 == STRNCMP(value.sql_state_, desc->get_condition(j).sql_state_, value.str_len_)) {
dup = true;
}
}
}
} else {
break;
}
}
return ret;
}
@ -12424,7 +12474,12 @@ int ObPLResolver::HandlerAnalyzer::reset_handlers(int64_t level)
int ret = OB_SUCCESS;
for (int64_t i = handler_stack_.count() - 1; OB_SUCC(ret) && i >= 0; --i) {
if (handler_stack_.at(i).get_level() == level) {
handler_stack_.pop_back();
if (i != handler_stack_.count() -1) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("failed to reset handlers with level", K(ret), K(level), K(i), K(handler_stack_.at(i)));
} else {
handler_stack_.pop_back();
}
}
}
if (OB_SUCC(ret) && handler_stack_.count() - 1 < top_continue_) {

View File

@ -1200,6 +1200,10 @@ int ObPLBlockNS::check_dup_symbol(const ObString &name, const ObPLDataType &type
is_dup = true;
ObPLVar *pl_var = const_cast<ObPLVar *>(symbol_table_->get_symbol(symbols_.at(i)));
pl_var->set_dup_declare(is_dup);
if (pl_var->is_referenced()) {
ret = OB_ERR_DECL_MORE_THAN_ONCE;
LOG_USER_ERROR(OB_ERR_DECL_MORE_THAN_ONCE, name.length(), name.ptr());
}
}
} else { /*do nothing*/ }
}
@ -2371,11 +2375,13 @@ int ObPLBlockNS::resolve_symbol(const ObString &var_name,
&& OB_INVALID_INDEX == var_idx
&& OB_INVALID_INDEX == parent_id
&& i < get_symbols().count(); ++i) {
const ObPLVar *pl_var = symbol_table_->get_symbol(get_symbols().at(i));
ObPLVar *pl_var = const_cast<ObPLVar *>(symbol_table_->get_symbol(get_symbols().at(i)));
if (OB_ISNULL(pl_var)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("PL var ns is null", K(i), K(get_symbols().at(i)), K(ret));
} else if (ObCharset::case_compat_mode_equal(var_name, pl_var->get_name())) {
bool is_referenced = true;
pl_var->set_is_referenced(is_referenced);
if (pl_var->is_dup_declare()) {
ret = OB_ERR_DECL_MORE_THAN_ONCE;
LOG_USER_ERROR(OB_ERR_DECL_MORE_THAN_ONCE, var_name.length(), var_name.ptr());

View File

@ -121,7 +121,8 @@ public:
is_readonly_(false),
is_not_null_(false),
is_default_construct_(false),
is_formal_param_(false) {}
is_formal_param_(false),
is_referenced_(false) {}
virtual ~ObPLVar() {}
inline const common::ObString &get_name() const { return name_; }
@ -146,6 +147,8 @@ public:
int deep_copy(const ObPLVar &var, common::ObIAllocator &allocator);
inline void set_dup_declare(bool dup_declare) { is_dup_declare_ = dup_declare; }
inline bool is_dup_declare() const { return is_dup_declare_; }
inline void set_is_referenced(bool is_referenced) { is_referenced_ = is_referenced; }
inline bool is_referenced() const { return is_referenced_; }
TO_STRING_KV(K_(name),
K_(type),
@ -164,6 +167,7 @@ private:
bool is_default_construct_; //默认值是否是该变量的构造函数
bool is_formal_param_; // this is formal param of a routine
bool is_dup_declare_;
bool is_referenced_;
};
class ObPLSymbolTable

View File

@ -1137,7 +1137,12 @@ sp_create_chistic:
;
sp_chistic:
COMMENT STRING { }
COMMENT STRING
{
malloc_terminal_node($$, parse_ctx->mem_pool_, T_COMMENT);
$$->str_value_ = $2->str_value_;
$$->str_len_ = $2->str_len_;
}
| LANGUAGE SQL { /* Just parse it, we only have one language for now. */ $$ = NULL; }
| NO SQL {}
| CONTAINS SQL {}

View File

@ -1847,7 +1847,9 @@ int ObSyncTabletAutoincSeqCtx::sync()
LOG_WARN("failed to call and process", K(ret));
}
}
is_synced_ = true;
if (OB_SUCC(ret)) {
is_synced_ = true;
}
}
}
return ret;

View File

@ -315,6 +315,8 @@ void ObDDLScheduler::run1()
ObDDLTask *first_retry_task = nullptr;
(void)prctl(PR_SET_NAME, "DDLTaskExecutor", 0, 0, 0);
while (!has_set_stop()) {
THIS_WORKER.set_worker_level(1);
THIS_WORKER.set_curr_request_level(1);
while (!has_set_stop()) {
if (OB_FAIL(task_queue_.get_next_task(task))) {
if (common::OB_ENTRY_NOT_EXIST == ret) {

View File

@ -13607,12 +13607,22 @@ int ObDDLService::add_new_index_schema(obrpc::ObAlterTableArg &alter_table_arg,
} else if (OB_FAIL(generate_tablet_id(index_schema))) {
LOG_WARN("fail to generate tablet id for hidden table", K(ret), K(index_schema));
} else {
bool is_exist = false;
index_schema.set_table_id(new_idx_tid);
index_schema.set_data_table_id(new_table_schema.get_table_id());
index_schema.set_index_status(INDEX_STATUS_UNAVAILABLE);
// set the hidden attributes of the table
index_schema.set_table_state_flag(ObTableStateFlag::TABLE_STATE_HIDDEN_OFFLINE_DDL);
if (OB_FAIL(ret)) {
} else if (OB_FAIL(schema_guard.check_table_exist(index_schema.get_tenant_id(),
index_schema.get_database_id(),
index_schema.get_table_name_str(),
true/*is_index*/,
ObSchemaGetterGuard::USER_HIDDEN_TABLE_TYPE/*check_type*/,
is_exist))) {
LOG_WARN("failed to check table exist", K(ret));
} else if (is_exist) {
LOG_INFO("index already rebuilt, skip", K(index_schema.get_table_id()), K(index_schema.get_table_name_str()));
} else if (OB_FAIL(new_table_schemas.push_back(index_schema))) {
LOG_WARN("failed to add table schema!", K(ret));
} else if (OB_FAIL(index_ids.push_back(index_schema.get_table_id()))) {
@ -13809,6 +13819,7 @@ int ObDDLService::reconstruct_index_schema(const ObTableSchema &orig_table_schem
new_index_schema.set_table_name(new_index_table_name);
// set the hidden attributes of the table
new_index_schema.set_table_state_flag(ObTableStateFlag::TABLE_STATE_HIDDEN_OFFLINE_DDL);
bool is_exist = false;
if (OB_FAIL(ret)) {
} else if (OB_FAIL(new_table_schemas.push_back(new_index_schema))) {
LOG_WARN("failed to add table schema!", K(ret));

View File

@ -409,7 +409,10 @@ int ObTenantRoleTransitionService::get_ls_access_mode_(ObIArray<LSAccessModeInfo
*rpc_proxy_, &obrpc::ObSrvRpcProxy::get_ls_access_mode);
obrpc::ObGetLSAccessModeInfoArg arg;
int64_t rpc_count = 0;
ObArray<int> return_code_array;
int tmp_ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < status_info_array.count(); ++i) {
return_code_array.reset();
const ObLSStatusInfo &info = status_info_array.at(i);
const int64_t timeout = ctx.get_timeout();
if (info.ls_is_create_abort()) {
@ -426,7 +429,6 @@ int ObTenantRoleTransitionService::get_ls_access_mode_(ObIArray<LSAccessModeInfo
rpc_count++;
}
if (OB_FAIL(ret)) {
int tmp_ret = OB_SUCCESS;
const obrpc::ObGetLSAccessModeInfoArg &arg = proxy.get_args().at(i);
if (OB_SUCCESS !=(tmp_ret = GCTX.location_service_->nonblock_renew(
GCONF.cluster_id, tenant_id_, info.ls_id_))) {
@ -435,9 +437,12 @@ int ObTenantRoleTransitionService::get_ls_access_mode_(ObIArray<LSAccessModeInfo
}
}//end for
//get result
ObArray<int> return_code_array;
if (FAILEDx(proxy.wait_all(return_code_array))) {
LOG_WARN("wait all batch result failed", KR(ret));
//need to wait all result whether success or fail
if (OB_SUCCESS != (tmp_ret = proxy.wait_all(return_code_array))) {
LOG_WARN("wait all batch result failed", KR(ret), KR(tmp_ret));
ret = OB_SUCC(ret) ? tmp_ret : ret;
} else if (OB_FAIL(ret)) {
//no need to process return code
} else if (rpc_count != return_code_array.count() ||
rpc_count != proxy.get_args().count() ||
rpc_count != proxy.get_results().count()) {

View File

@ -232,6 +232,12 @@ int ObKVGlobalCache::init(
map_once_clean_num_ = min(MAX_MAP_ONCE_CLEAN_NUM, bucket_num / MAP_ONCE_CLEAN_RATIO);
map_once_replace_num_ = min(MAX_MAP_ONCE_REPLACE_NUM, bucket_num / MAP_ONCE_REPLACE_RATIO);
inited_ = true;
#ifdef ENABLE_DEBUG_LOG
int tmp_ret = OB_SUCCESS;
if (OB_TMP_FAIL(set_checker_cache_name(GCONF.leak_mod_to_check.str()))) {
COMMON_LOG(WARN, "[CACHE-HANDLE-CHECKER] Fail to set check cache name", K(tmp_ret));
}
#endif
}
if (OB_UNLIKELY(!inited_)) {
@ -853,10 +859,10 @@ int ObKVGlobalCache::set_checker_cache_name(const char *cache_name)
int64_t cache_id = INVALID_CACHE_ID;
if (OB_UNLIKELY(!inited_)) {
ret = OB_NOT_INIT;
COMMON_LOG(WARN, "The ObKVGlobalCache has not been inited", K(ret));
COMMON_LOG(WARN, "[CACHE-HANDLE-CHECKER] The ObKVGlobalCache has not been inited", K(ret));
} else if (nullptr == cache_name) {
ret = OB_INVALID_ARGUMENT;
COMMON_LOG(WARN, "Invalid argument", K(ret), KP(cache_name));
COMMON_LOG(WARN, "[CACHE-HANDLE-CHECKER] Invalid argument", K(ret), KP(cache_name));
} else {
if (0 == STRNCMP(cache_name, ObKVCacheHandleRefChecker::ALL_CACHE_NAME, MAX_CACHE_NAME_LENGTH)) {
cache_id = MAX_CACHE_NUM;

View File

@ -583,6 +583,10 @@ int ObKVCache<Key, Value>::put_and_fetch(
if (OB_ENTRY_EXIST != ret) {
COMMON_LOG(WARN, "Fail to put kv to ObKVGlobalCache, ", K_(cache_id), K(ret));
}
} else {
#ifdef ENABLE_DEBUG_LOG
ObKVCacheHandleRefChecker::get_instance().handle_ref_inc(handle);
#endif
}
return ret;
}

View File

@ -12,21 +12,27 @@
#include "share/cache/ob_kvcache_handle_ref_checker.h"
#include "share/cache/ob_kv_storecache.h"
namespace oceanbase
{
namespace common
{
/*
* ---------------------------------------------- ObKVCacheHandleRefChecker::Key ----------------------------------------------
*/
ObKVCacheHandleRefChecker::Key::Key()
: handle_(nullptr)
{
}
ObKVCacheHandleRefChecker::Key::Key(const ObKVCacheHandle &cache_handle)
: handle_(&cache_handle)
{
}
uint64_t ObKVCacheHandleRefChecker::Key::hash() const
{
uint64_t hash = 0;
@ -35,13 +41,16 @@ uint64_t ObKVCacheHandleRefChecker::Key::hash() const
}
return hash;
}
bool ObKVCacheHandleRefChecker::Key::operator== (const Key &other) const
{
return handle_ == other.handle_;
}
/*
* ---------------------------------------------- ObKVCacheHandleRefChecker::Value ----------------------------------------------
*/
ObKVCacheHandleRefChecker::Value::Value()
: tenant_id_(OB_INVALID_TENANT_ID),
cache_id_(INVALID_CACHE_ID),
@ -49,20 +58,24 @@ ObKVCacheHandleRefChecker::Value::Value()
{
MEMSET(bt_, 0, sizeof(bt_));
}
ObKVCacheHandleRefChecker::Value::Value(const Value &other)
{
*this = other;
}
uint64_t ObKVCacheHandleRefChecker::Value::hash() const
{
uint64_t hash = 0;
hash = murmurhash(bt_, sizeof(bt_), hash);
return hash;
}
bool ObKVCacheHandleRefChecker::Value::operator== (const Value &other) const
{
return (tenant_id_ == other.tenant_id_) && (cache_id_ == other.cache_id_) && (0 == STRNCMP(bt_, other.bt_, sizeof(bt_)));
}
ObKVCacheHandleRefChecker::Value & ObKVCacheHandleRefChecker::Value::operator= (const Value &other)
{
if (this != &other) {
@ -72,10 +85,13 @@ ObKVCacheHandleRefChecker::Value & ObKVCacheHandleRefChecker::Value::operator= (
}
return *this;
}
/*
* ---------------------------------------------- ObKVCacheHandleRefChecker ----------------------------------------------
*/
const char ObKVCacheHandleRefChecker::ALL_CACHE_NAME[MAX_CACHE_NAME_LENGTH] = "all_cache";
ObKVCacheHandleRefChecker::ObKVCacheHandleRefChecker()
: cache_id_(INVALID_CACHE_ID),
handle_ref_bt_info_(),
@ -88,21 +104,25 @@ ObKVCacheHandleRefChecker::ObKVCacheHandleRefChecker()
is_inited_ = true;
}
}
ObKVCacheHandleRefChecker::~ObKVCacheHandleRefChecker()
{
reset();
}
ObKVCacheHandleRefChecker &ObKVCacheHandleRefChecker::get_instance()
{
static ObKVCacheHandleRefChecker cache_handle_ref_checker_;
return cache_handle_ref_checker_;
}
void ObKVCacheHandleRefChecker::reset()
{
cache_id_ = INVALID_CACHE_ID;
handle_ref_bt_info_.reuse();
is_inited_ = false;
}
void ObKVCacheHandleRefChecker::handle_ref_inc(const ObKVCacheHandle &cache_handle)
{
INIT_SUCC(ret);
@ -122,6 +142,7 @@ void ObKVCacheHandleRefChecker::handle_ref_inc(const ObKVCacheHandle &cache_hand
}
}
}
void ObKVCacheHandleRefChecker::handle_ref_de(const ObKVCacheHandle &cache_handle)
{
INIT_SUCC(ret);
@ -138,6 +159,7 @@ void ObKVCacheHandleRefChecker::handle_ref_de(const ObKVCacheHandle &cache_handl
}
}
}
int ObKVCacheHandleRefChecker::set_cache_id(const int64_t cache_id)
{
INIT_SUCC(ret);
@ -153,6 +175,7 @@ int ObKVCacheHandleRefChecker::set_cache_id(const int64_t cache_id)
}
return ret;
}
int ObKVCacheHandleRefChecker::get_aggregate_bt_info(hash::ObHashMap<Value, int64_t> &bt_info)
{
INIT_SUCC(ret);
@ -186,5 +209,7 @@ int ObKVCacheHandleRefChecker::get_aggregate_bt_info(hash::ObHashMap<Value, int6
}
return ret;
}
} // common
} // oceanbase

View File

@ -95,7 +95,26 @@ int64_t ObServerConfig::get_server_memory_avail()
int64_t ObServerConfig::get_reserved_server_memory()
{
return system_memory;
int64_t system_memory_b = system_memory;
if (0 == system_memory_b) {
int64_t memory_limit_g = get_server_memory_limit() >> 30;
if (memory_limit_g < 4) {
OB_LOG(ERROR, "memory_limit with unexpected value", K(memory_limit_g));
} else if (memory_limit_g <= 8) {
system_memory_b = 2LL << 30;
} else if (memory_limit_g <= 16) {
system_memory_b = 3LL << 30;
} else if (memory_limit_g <= 32) {
system_memory_b = 5LL << 30;
} else if (memory_limit_g <= 48) {
system_memory_b = 7LL << 30;
} else if (memory_limit_g <= 64) {
system_memory_b = 10LL << 30;
} else {
system_memory_b = int64_t(15 + 3 * (sqrt(memory_limit_g) - 8)) << 30;
}
}
return system_memory_b;
}
int ObServerConfig::read_config()

View File

@ -5111,6 +5111,8 @@ def_table_schema(
# 427 : __all_ls_balance_job
# 428 : __all_ls_balance_job_history
# 429 : __all_arbitration_service
# 430 : __all_arbitration_service_replica_task
################################################################################
# Virtual Table (10000, 20000]
# Normally, virtual table's index_using_type should be USING_HASH.

View File

@ -82,6 +82,11 @@ void ObLSLocationMap::destroy()
ls_buckets_ = NULL;
}
if (OB_NOT_NULL(buckets_lock_)) {
for (int64_t i = 0; i < BUCKETS_CNT; ++i) {
if (OB_NOT_NULL(buckets_lock_ + i)) {
(buckets_lock_ + i)->~ObQSyncLock();
}
}
ob_free(buckets_lock_);
buckets_lock_ = nullptr;
}

View File

@ -789,7 +789,7 @@ int ObLSLocationService::renew_location(
// get from cache just for printing cache changes log
if (OB_FAIL(ret)) {
} else if (OB_SUCCESS != (tmp_ret = get_from_cache(cluster_id, tenant_id, ls_id, old_location))) {
if (OB_ENTRY_NOT_EXIST == tmp_ret) {
if (OB_CACHE_NOT_HIT == tmp_ret) {
tmp_ret = OB_SUCCESS;
} else {
LOG_WARN("fail to get from cache", KR(tmp_ret), K(cluster_id), K(tenant_id), K(ls_id));
@ -813,7 +813,7 @@ int ObLSLocationService::renew_location(
LOG_WARN("get empty location from meta table", KR(ret), K(location));
}
// print cache changes
if (OB_SUCC(ret) && OB_SUCC(tmp_ret) && !location.is_same_with(old_location)) {
if (OB_SUCC(ret) && (OB_SUCCESS == tmp_ret) && !location.is_same_with(old_location)) {
FLOG_INFO("[LOCATION_CACHE]ls location cache has changed", KR(ret), K(old_location), "new_location", location);
}
return ret;

View File

@ -417,6 +417,9 @@ class ObString;
ACT(BEFORE_BACKUP_TASK_FINISH,)\
ACT(BEFORE_UPDATE_LS_META_TABLE,)\
ACT(BEFORE_LOAD_ARCHIVE_ROUND,)\
ACT(BEFORE_MIG_DDL_TABLE_MERGE_TASK,)\
ACT(BEFORE_COPY_DDL_SSTABLE,)\
ACT(BEFORE_DDL_WRITE_PREPARE_LOG,)\
ACT(MAX_DEBUG_SYNC_POINT,)
DECLARE_ENUM(ObDebugSyncPoint, debug_sync_point, OB_DEBUG_SYNC_POINT_DEF);

View File

@ -10725,6 +10725,18 @@ static const _error _error_OB_DDL_SCHEMA_VERSION_NOT_MATCH = {
.oracle_str_error = "ORA-00600: internal error code, arguments: -5403, ddl schema version not match",
.oracle_str_user_error = "ORA-00600: internal error code, arguments: -5403, ddl schema version not match"
};
static const _error _error_OB_ERR_COLUMN_GROUP_DUPLICATE = {
.error_name = "OB_ERR_COLUMN_GROUP_DUPLICATE",
.error_cause = "Internal Error",
.error_solution = "Contact OceanBase Support",
.mysql_errno = ER_DUP_FIELDNAME,
.sqlstate = "42S21",
.str_error = "Duplicate column group name",
.str_user_error = "Duplicate column group name '%.*s'",
.oracle_errno = 600,
.oracle_str_error = "ORA-00600: internal error code, arguments: -5404, Duplicate column group name",
.oracle_str_user_error = "ORA-00600: internal error code, arguments: -5404, Duplicate column group name '%.*s'"
};
static const _error _error_OB_ERR_INVALID_JSON_TEXT = {
.error_name = "OB_ERR_INVALID_JSON_TEXT",
.error_cause = "Internal Error",
@ -22856,6 +22868,7 @@ struct ObStrErrorInit
_errors[-OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED] = &_error_OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED;
_errors[-OB_ERR_GET_STACKED_DIAGNOSTICS] = &_error_OB_ERR_GET_STACKED_DIAGNOSTICS;
_errors[-OB_DDL_SCHEMA_VERSION_NOT_MATCH] = &_error_OB_DDL_SCHEMA_VERSION_NOT_MATCH;
_errors[-OB_ERR_COLUMN_GROUP_DUPLICATE] = &_error_OB_ERR_COLUMN_GROUP_DUPLICATE;
_errors[-OB_ERR_INVALID_JSON_TEXT] = &_error_OB_ERR_INVALID_JSON_TEXT;
_errors[-OB_ERR_INVALID_JSON_TEXT_IN_PARAM] = &_error_OB_ERR_INVALID_JSON_TEXT_IN_PARAM;
_errors[-OB_ERR_INVALID_JSON_BINARY_DATA] = &_error_OB_ERR_INVALID_JSON_BINARY_DATA;

View File

@ -624,6 +624,8 @@ DEFINE_ERROR(OB_FREEZE_SERVICE_EPOCH_MISMATCH, -4743, -1, "HY000", "freeze servi
DEFINE_ERROR_EXT_DEP(OB_FROZEN_INFO_ALREADY_EXIST, -4744, -1, "HY000", "already exist larger frozen_scn in __all_freeze_info", "%s");
DEFINE_ERROR_EXT(OB_DELETE_SERVER_NOT_ALLOWED, -4745, -1, "HY000", "delete server not allowed", "%s");
DEFINE_ERROR(OB_PACKET_STATUS_UNKNOWN, -4746, -1, "HY000", "Network error and packet status unknown. Abort auto retry.");
//4747: OB_ARBITRATION_SERVICE_NOT_EXIST
//4748: OB_ARBITRATION_SERVICE_ALREADY_EXIST
////////////////////////////////////////////////////////////////
// SQL & Schema specific error code, -5000 ~ -6000
@ -995,6 +997,7 @@ DEFINE_ORACLE_ERROR_EXT(OB_ERR_OBJECT_STRING_DOES_NOT_EXIST, -5400, -1, "HY000",
DEFINE_ORACLE_ERROR(OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED, -5401, -1, "HY000", "resultant data type of virtual column is not supported", 54004, "resultant data type of virtual column is not supported");
DEFINE_ERROR(OB_ERR_GET_STACKED_DIAGNOSTICS, -5402, ER_GET_STACKED_DIAGNOSTICS_INACTIVE, "0Z002", "GET STACKED DIAGNOSTICS when handler not active");
DEFINE_ERROR(OB_DDL_SCHEMA_VERSION_NOT_MATCH, -5403, -1, "HY000", "ddl schema version not match");
DEFINE_ERROR_EXT(OB_ERR_COLUMN_GROUP_DUPLICATE, -5404, ER_DUP_FIELDNAME, "42S21", "Duplicate column group name", "Duplicate column group name '%.*s'");
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//error code for json -5410 ---- -5433, as for json only support mysql mode, error code for oracle use special values

View File

@ -763,6 +763,7 @@ constexpr int OB_ERR_OBJECT_STRING_DOES_NOT_EXIST = -5400;
constexpr int OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED = -5401;
constexpr int OB_ERR_GET_STACKED_DIAGNOSTICS = -5402;
constexpr int OB_DDL_SCHEMA_VERSION_NOT_MATCH = -5403;
constexpr int OB_ERR_COLUMN_GROUP_DUPLICATE = -5404;
constexpr int OB_SQL_RETRY_SPM = -5434;
constexpr int OB_OUTLINE_NOT_REPRODUCIBLE = -5435;
constexpr int OB_ERR_SP_ALREADY_EXISTS = -5541;
@ -2491,6 +2492,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED__USER_ERROR_MSG "resultant data type of virtual column is not supported"
#define OB_ERR_GET_STACKED_DIAGNOSTICS__USER_ERROR_MSG "GET STACKED DIAGNOSTICS when handler not active"
#define OB_DDL_SCHEMA_VERSION_NOT_MATCH__USER_ERROR_MSG "ddl schema version not match"
#define OB_ERR_COLUMN_GROUP_DUPLICATE__USER_ERROR_MSG "Duplicate column group name '%.*s'"
#define OB_ERR_INVALID_JSON_TEXT__USER_ERROR_MSG "Invalid JSON text."
#define OB_ERR_INVALID_JSON_TEXT_IN_PARAM__USER_ERROR_MSG "Invalid JSON text in argument."
#define OB_ERR_INVALID_JSON_BINARY_DATA__USER_ERROR_MSG "The JSON binary value contains invalid data."
@ -4322,6 +4324,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
#define OB_ERR_RESULTANT_DATA_TYPE_OF_VIRTUAL_COLUMN_IS_NOT_SUPPORTED__ORA_USER_ERROR_MSG "ORA-54004: resultant data type of virtual column is not supported"
#define OB_ERR_GET_STACKED_DIAGNOSTICS__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5402, GET STACKED DIAGNOSTICS when handler not active"
#define OB_DDL_SCHEMA_VERSION_NOT_MATCH__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5403, ddl schema version not match"
#define OB_ERR_COLUMN_GROUP_DUPLICATE__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5404, Duplicate column group name '%.*s'"
#define OB_ERR_INVALID_JSON_TEXT__ORA_USER_ERROR_MSG "ORA-00600: Invalid JSON text."
#define OB_ERR_INVALID_JSON_TEXT_IN_PARAM__ORA_USER_ERROR_MSG "ORA-00600: Invalid JSON text in argument."
#define OB_ERR_INVALID_JSON_BINARY_DATA__ORA_USER_ERROR_MSG "ORA-00600: The JSON binary value contains invalid data."

View File

@ -3715,8 +3715,9 @@ bool ObPhysicalRestoreTenantArg::is_valid() const
&& uri_.length() < share::OB_MAX_RESTORE_DEST_LENGTH
&& !restore_option_.empty()
&& restore_option_.length() < common::OB_INNER_TABLE_DEFAULT_VALUE_LENTH
&& restore_scn_.is_valid();
&& (!with_restore_scn_ || restore_scn_.is_valid());
}
OB_SERIALIZE_MEMBER((ObPhysicalRestoreTenantArg, ObCmdArg),
tenant_name_,
uri_,

View File

@ -194,6 +194,7 @@ int ObSnapshotTableProxy::batch_add_snapshot(
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguments", K(ret), K(tenant_id), K(schema_version), K(snapshot_scn), K(tablet_id_array));
} else {
palf::SCN snapshot_gc_scn = palf::SCN::min_scn();
int64_t report_idx = 0;
const int64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id);
ObSnapshotInfo info;
@ -203,6 +204,9 @@ int ObSnapshotTableProxy::batch_add_snapshot(
info.snapshot_scn_ = snapshot_scn;
info.schema_version_ = schema_version;
info.comment_ = comment;
if (OB_FAIL(ObGlobalStatProxy::select_snapshot_gc_scn_for_update(trans, tenant_id, snapshot_gc_scn))) {
LOG_WARN("fail to select gc timstamp for update", KR(ret), K(info), K(tenant_id));
}
while (OB_SUCC(ret) && report_idx < tablet_id_array.count()) {
sql.reuse();
columns.reuse();
@ -211,7 +215,7 @@ int ObSnapshotTableProxy::batch_add_snapshot(
for (int64_t i = 0; OB_SUCC(ret) && i < cur_batch_cnt; ++i) {
info.tablet_id_ = tablet_id_array.at(report_idx + i).id();
dml.reuse();
if (OB_FAIL(check_snapshot_valid(trans, info.tenant_id_, info, is_valid))) {
if (OB_FAIL(check_snapshot_valid(snapshot_gc_scn, info, is_valid))) {
LOG_WARN("fail to check snapshot valid", KR(ret), K(info), K(tenant_id));
} else if (!is_valid) {
ret = OB_SNAPSHOT_DISCARDED;
@ -428,19 +432,15 @@ int ObSnapshotTableProxy::get_all_snapshots(
}
int ObSnapshotTableProxy::check_snapshot_valid(
ObISQLClient &client,
const uint64_t tenant_id,
const palf::SCN &snapshot_gc_scn,
const ObSnapshotInfo &info,
bool &is_valid)
bool &is_valid) const
{
int ret = OB_SUCCESS;
palf::SCN snapshot_gc_scn;
is_valid = false;
if (!info.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", KR(ret), K(info));
} else if (OB_FAIL(ObGlobalStatProxy::select_snapshot_gc_scn_for_update(client, tenant_id, snapshot_gc_scn))) {
LOG_WARN("fail to select gc timstamp for update", KR(ret), K(info), K(tenant_id));
} else if (info.snapshot_scn_ <= snapshot_gc_scn) {
is_valid = false;
LOG_WARN("invalid snapshot info", KR(ret), K(info), K(snapshot_gc_scn));

View File

@ -148,10 +148,9 @@ public:
int64_t &count);
private:
int gen_event_ts(int64_t &event_ts);
int check_snapshot_valid(common::ObISQLClient &client,
const uint64_t tenant_id,
int check_snapshot_valid(const palf::SCN &snapshot_gc_scn,
const ObSnapshotInfo &info,
bool &is_valid);
bool &is_valid) const;
int fill_snapshot_item(const ObSnapshotInfo &info,
share::ObDMLSqlSplicer &dml);

View File

@ -16,10 +16,6 @@ namespace share
const palf::SCN ObScnRange::MIN_SCN = palf::SCN::min_scn();
const palf::SCN ObScnRange::MAX_SCN = palf::SCN::max_scn();
const int64_t ObScnRange::MIN_TS = palf::OB_MIN_SCN_TS_NS;
const int64_t ObScnRange::MAX_TS = palf::OB_MAX_SCN_TS_NS;
const int64_t ObScnRange::OLD_MAX_TS = INT64_MAX;
ObScnRange::ObScnRange()
: start_scn_(MIN_SCN),
end_scn_(MIN_SCN)

View File

@ -25,9 +25,6 @@ struct ObScnRange
public:
static const palf::SCN MIN_SCN;
static const palf::SCN MAX_SCN;
static const int64_t MIN_TS;
static const int64_t MAX_TS;
static const int64_t OLD_MAX_TS;
ObScnRange();
int64_t hash() const;

View File

@ -508,5 +508,37 @@ int ObTabletAutoincSeqRpcHandler::batch_set_tablet_autoinc_seq(
return ret;
}
int ObTabletAutoincSeqRpcHandler::replay_update_tablet_autoinc_seq(
const ObLS *ls,
const ObTabletID &tablet_id,
const uint64_t autoinc_seq,
const palf::SCN &replay_scn)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(ls == nullptr || !tablet_id.is_valid() || autoinc_seq == 0 || !replay_scn.is_valid_and_not_min())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret), K(tablet_id), K(autoinc_seq), K(replay_scn));
} else {
ObTabletHandle tablet_handle;
ObBucketHashWLockGuard guard(bucket_lock_, tablet_id.hash());
if (OB_FAIL(ls->replay_get_tablet(tablet_id,
replay_scn,
tablet_handle))) {
if (OB_TABLET_NOT_EXIST == ret) {
LOG_INFO("tablet may be deleted, skip this log", K(ret), K(tablet_id), K(replay_scn));
ret = OB_SUCCESS;
} else if (OB_EAGAIN == ret) {
// retry replay again
} else {
LOG_WARN("fail to replay get tablet, retry again", K(ret), K(tablet_id), K(replay_scn));
ret = OB_EAGAIN;
}
} else if (OB_FAIL(tablet_handle.get_obj()->update_tablet_autoinc_seq(autoinc_seq, replay_scn))) {
LOG_WARN("failed to update tablet auto inc seq", K(ret), K(autoinc_seq), K(replay_scn));
}
}
return ret;
}
}
}

View File

@ -131,11 +131,16 @@ public:
int batch_set_tablet_autoinc_seq(
const obrpc::ObBatchSetTabletAutoincSeqArg &arg,
obrpc::ObBatchSetTabletAutoincSeqRes &res);
int replay_update_tablet_autoinc_seq(
const ObLS *ls,
const ObTabletID &tablet_id,
const uint64_t autoinc_seq,
const palf::SCN &replay_scn);
private:
ObTabletAutoincSeqRpcHandler();
~ObTabletAutoincSeqRpcHandler();
private:
static const int64_t BUCKET_LOCK_BUCKET_CNT = 100;
static const int64_t BUCKET_LOCK_BUCKET_CNT = 10243L;
bool is_inited_;
common::ObBucketLock bucket_lock_;
};

View File

@ -80,7 +80,7 @@ DEF_CAP_WITH_CHECKER(memory_limit, OB_CLUSTER_PARAMETER, "0",
DEF_CAP(rootservice_memory_limit, OB_CLUSTER_PARAMETER, "2G", "[2G,)",
"max memory size which can be used by rs tenant The default value is 2G. Range: [2G,)",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_CAP(system_memory, OB_CLUSTER_PARAMETER, "30G", "[0M,)",
DEF_CAP(system_memory, OB_CLUSTER_PARAMETER, "0M", "[0M,)",
"the memory reserved for internal use which cannot be allocated to any outer-tenant, "
"and should be determined to guarantee every server functions normally. Range: [0M,)",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
@ -1291,6 +1291,21 @@ DEF_STR_LIST(sanity_whitelist, OB_CLUSTER_PARAMETER, "", "vip who wouldn't leadi
DEF_TIME(_advance_checkpoint_timeout, OB_CLUSTER_PARAMETER, "30m", "[10s,180m]",
"the timeout for backup/migrate advance checkpoint Range: [10s,180m]",
ObParameterAttr(Section::ROOT_SERVICE, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
ERRSIM_DEF_INT(errsim_migration_tablet_id, OB_CLUSTER_PARAMETER, "0", "[0,)",
"the tablet id that migration want to insert error"
"Range: [0,) in integer",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
ERRSIM_DEF_INT(errsim_max_ddl_sstable_count, OB_CLUSTER_PARAMETER, "0", "[0,)",
"max ddl sstable count in errsim mode"
"Range: [0,) in integer",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
ERRSIM_DEF_INT(errsim_max_ddl_block_count, OB_CLUSTER_PARAMETER, "0", "[0,)",
"max ddl block count in errsim mode"
"Range: [0,) in integer",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
ERRSIM_DEF_STR(errsim_migration_src_server_addr, OB_CLUSTER_PARAMETER, "",
"the server dest ls choose as src when in errsim mode",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_BOOL(enable_cgroup, OB_CLUSTER_PARAMETER, "True",
"when set to false, cgroup will not init; when set to true but cgroup root dir is not ready, print ERROR",

View File

@ -3332,8 +3332,131 @@ int ObSchemaGetterGuard::check_priv(const ObSessionPrivInfo &session_priv,
return ret;
}
int ObSchemaGetterGuard::check_priv_db_or_(const ObSessionPrivInfo &session_priv,
const ObNeedPriv &need_priv,
const ObPrivMgr &priv_mgr,
const uint64_t tenant_id,
const uint64_t user_id,
bool& pass) {
int ret = OB_SUCCESS;
int64_t total_db_priv_set_role = 0;
ObString db = need_priv.db_;
ObPrivSet db_priv_set = 0;
if (session_priv.db_.length() != 0 && (session_priv.db_ == db || 0 == db.length())) {
db_priv_set = session_priv.db_priv_set_;
} else {
ObOriginalDBKey db_priv_key(tenant_id, user_id, db);
if (OB_FAIL(priv_mgr.get_db_priv_set(db_priv_key, db_priv_set))) {
LOG_WARN("get db priv set failed", K(db_priv_key), KR(ret));
}
}
/* load role db privs */
if (OB_SUCC(ret)) {
const ObUserInfo *user_info = NULL;
//bool is_grant_role = false;
if (OB_FAIL(get_user_info(tenant_id, user_id, user_info))) {
LOG_WARN("failed to get user info", KR(ret), K(tenant_id), K(user_id));
} else if (OB_ISNULL(user_info)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("user info is null", KR(ret), K(tenant_id), K(user_id));
} else {
const ObIArray<uint64_t> &role_id_array = user_info->get_role_id_array();
for (int64_t i = 0; OB_SUCC(ret) && i < role_id_array.count(); ++i) {
const ObUserInfo *role_info = NULL;
if (OB_FAIL(get_user_info(tenant_id, role_id_array.at(i), role_info))) {
LOG_WARN("failed to get role ids", KR(ret), K(tenant_id), K(role_id_array.at(i)));
} else if (OB_ISNULL(role_info)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("role info is null", KR(ret), K(role_id_array.at(i)));
} else {
ObPrivSet db_priv_set_role = OB_PRIV_SET_EMPTY;
ObOriginalDBKey db_priv_key_role(tenant_id, role_info->get_user_id(), db);
if (OB_FAIL(priv_mgr.get_db_priv_set(db_priv_key_role, db_priv_set_role))) {
LOG_WARN("get db priv set failed", KR(ret), K(db_priv_key_role));
} else {
db_priv_set |= db_priv_set_role;
}
}
}
}
}
if (OB_SUCC(ret)) {
pass = OB_PRIV_HAS_ANY(db_priv_set, need_priv.priv_set_);
}
return ret;
}
int ObSchemaGetterGuard::check_priv_table_or_(const ObNeedPriv &need_priv,
const ObPrivMgr &priv_mgr,
const uint64_t tenant_id,
const uint64_t user_id,
bool& pass) {
int ret = OB_SUCCESS;
//1. fetch table priv
const ObTablePriv *table_priv = NULL;
ObPrivSet table_priv_set = 0;
ObTablePrivSortKey table_priv_key(tenant_id,
user_id,
need_priv.db_,
need_priv.table_);
if (OB_FAIL(priv_mgr.get_table_priv(table_priv_key, table_priv))) {
LOG_WARN("get table priv failed", KR(ret), K(table_priv_key));
} else if (OB_ISNULL(table_priv)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("table priv is null", KR(ret), K(table_priv_key));
} else {
table_priv_set = table_priv->get_priv_set();
}
if (OB_SUCC(ret)) {
//2. fetch roles privs
const ObUserInfo *user_info = NULL;
if (OB_FAIL(get_user_info(tenant_id, user_id, user_info))) {
LOG_WARN("failed to get user info", KR(ret), K(tenant_id), K(user_id));
} else if (OB_ISNULL(user_info)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("user info is null", KR(ret), K(tenant_id), K(user_id));
} else {
const ObIArray<uint64_t> &role_id_array = user_info->get_role_id_array();
for (int64_t i = 0; OB_SUCC(ret) && i < role_id_array.count(); ++i) {
const ObUserInfo *role_info = NULL;
const ObTablePriv *role_table_priv = NULL;
if (OB_FAIL(get_user_info(tenant_id, role_id_array.at(i), role_info))) {
LOG_WARN("failed to get role ids", KR(ret), K(tenant_id), K(role_id_array.at(i)));
} else if (OB_ISNULL(role_info)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("role info is null", KR(ret), K(role_id_array.at(i)));
} else {
ObTablePrivSortKey role_table_priv_key(tenant_id,
role_info->get_user_id(),
need_priv.db_,
need_priv.table_);
if (OB_FAIL(priv_mgr.get_table_priv(role_table_priv_key, role_table_priv))) {
LOG_WARN("get table priv failed", KR(ret), K(role_table_priv_key) );
} else if (OB_ISNULL(role_table_priv)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("role table priv is null", KR(ret), K(role_table_priv_key));
} else {
table_priv_set |= role_table_priv->get_priv_set();
}
}
}
}
}
//3. check privs
if (OB_SUCC(ret)) {
pass = OB_PRIV_HAS_ANY(table_priv_set, need_priv.priv_set_);
}
return ret;
}
int ObSchemaGetterGuard::check_priv_or(const ObSessionPrivInfo &session_priv,
const ObStmtNeedPrivs &stmt_need_privs)
const ObStmtNeedPrivs &stmt_need_privs)
{
int ret = OB_SUCCESS;
@ -3341,13 +3464,18 @@ int ObSchemaGetterGuard::check_priv_or(const ObSessionPrivInfo &session_priv,
bool pass = false;
ObPrivLevel max_priv_level = OB_PRIV_INVALID_LEVEL;
uint64_t tenant_id = session_priv.tenant_id_;
uint64_t user_id = session_priv.user_id_;
const ObSchemaMgr *mgr = NULL;
if (OB_FAIL(check_tenant_schema_guard(tenant_id))) {
LOG_WARN("fail to check tenant schema guard", KR(ret), K(tenant_id), K_(tenant_id));
} else if (OB_FAIL(check_lazy_guard(tenant_id, mgr))) {
LOG_WARN("fail to check lazy guard", KR(ret), K(tenant_id));
} else if (OB_ISNULL(mgr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("mgr is NULL", KR(ret), K(tenant_id));
} else if (session_priv.is_valid()) {
for (int64_t i = 0; !pass && OB_SUCCESS == ret && i < need_privs.count(); ++i) {
const ObPrivMgr &priv_mgr = mgr->priv_mgr_;
for (int64_t i = 0; !pass && OB_SUCC(ret) && i < need_privs.count(); ++i) {
const ObNeedPriv &need_priv = need_privs.at(i);
if (need_priv.priv_level_ > max_priv_level) {
max_priv_level = need_priv.priv_level_;
@ -3358,20 +3486,14 @@ int ObSchemaGetterGuard::check_priv_or(const ObSessionPrivInfo &session_priv,
break;
}
case OB_PRIV_DB_LEVEL: {
pass = OB_PRIV_HAS_ANY(session_priv.db_priv_set_, need_priv.priv_set_);
if (OB_FAIL(check_priv_db_or_(session_priv, need_priv, priv_mgr, tenant_id, user_id, pass))) {
LOG_WARN("fail to check priv db only", KR(ret), K(tenant_id), K(user_id), K(need_priv.db_));
}
break;
}
case OB_PRIV_TABLE_LEVEL: {
const ObPrivMgr &priv_mgr = mgr->priv_mgr_;
const ObTablePriv *table_priv = NULL;
ObTablePrivSortKey table_priv_key(session_priv.tenant_id_,
session_priv.user_id_,
need_priv.db_,
need_priv.table_);
if (OB_FAIL(priv_mgr.get_table_priv(table_priv_key, table_priv))) {
LOG_WARN("get table priv failed", KR(ret), K(table_priv_key));
} else if (NULL != table_priv) {
pass = OB_PRIV_HAS_ANY(table_priv->get_priv_set(), need_priv.priv_set_);
if (OB_FAIL(check_priv_table_or_(need_priv, priv_mgr, tenant_id, user_id, pass))) {
LOG_WARN("fail to check priv table only", KR(ret), K(tenant_id), K(user_id), K(need_priv.db_), K(need_priv.table_));
}
break;
}

View File

@ -48,6 +48,7 @@ class ObColumnSchemaV2;
class ObDBPriv;
class ObDatabaseSchema;
class ObMultiVersionSchemaService;
class ObPrivMgr;
class ObSimpleDatabaseSchema;
class ObSimplePackageSchema;
class ObSimpleRoutineSchema;
@ -72,6 +73,7 @@ struct ObSessionPrivInfo;
struct ObStmtNeedPrivs;
struct ObUserLoginInfo;
class ObSchemaMgrInfo
{
public:
@ -1087,6 +1089,17 @@ private:
const ObIArray<uint64_t> &role_id_array);
bool ignore_tenant_not_exist_error(const uint64_t tenant_id);
int check_priv_db_or_(const ObSessionPrivInfo &session_priv,
const ObNeedPriv &need_priv,
const ObPrivMgr &priv_mgr,
const uint64_t tenant_id,
const uint64_t user_id,
bool& pass);
int check_priv_table_or_(const ObNeedPriv &need_priv,
const ObPrivMgr &priv_mgr,
const uint64_t tenant_id,
const uint64_t user_id,
bool& pass);
private:
common::ObArenaAllocator local_allocator_;
ObMultiVersionSchemaService *schema_service_;

View File

@ -3840,6 +3840,16 @@ int ObSchemaPrinter::print_routine_definition(const ObRoutineInfo *routine_info,
OX (routine_param = static_cast<const ObRoutineParam*>(routine_info->get_ret_info()));
OZ (print_routine_param_type(routine_param, return_type, buf, buf_len, pos, tz_info));
}
if (OB_SUCC(ret) && lib::is_mysql_mode()) {
OZ (databuff_printf(buf, buf_len, pos, "%s",
routine_info->is_deterministic() ? "\nDETERMINISTIC\n" : ""));
if (OB_SUCC(ret) && OB_NOT_NULL(routine_info->get_comment())) {
OZ (databuff_printf(buf, buf_len, pos, "%s%.*s%s\n","COMMENT `",
routine_info->get_comment().length(),
routine_info->get_comment().ptr(),
"`"));
}
}
OZ (databuff_printf(buf, buf_len, pos, lib::is_oracle_mode() ? " IS\n%.*s" : " %.*s", body.length(), body.ptr()));
return ret;
}

View File

@ -30,6 +30,14 @@ ObDASGroupScanOp::ObDASGroupScanOp(ObIAllocator &op_alloc)
{
}
ObDASGroupScanOp::~ObDASGroupScanOp()
{
if (result_iter_ != nullptr && result_iter_->get_type() == ObNewRowIterator::ObTableScanIterator) {
LOG_ERROR("table group scan iter is not released, maybe some bug occured",
KPC(scan_ctdef_), K(scan_param_), KPC(scan_rtdef_));
}
}
int ObDASGroupScanOp::rescan()
{
int &ret = errcode_;
@ -223,6 +231,21 @@ int ObDASGroupScanOp::decode_task_result(ObIDASTaskResult *task_result)
}
return ret;
}
ObGroupLookupOp::~ObGroupLookupOp()
{
const ObNewRowIterator *lookup_iter = get_lookup_storage_iter();
if (lookup_iter != nullptr && lookup_iter->get_type() == ObNewRowIterator::ObTableScanIterator) {
LOG_ERROR("lookup_iter iter is not released, maybe some bug occured",
KPC(lookup_ctdef_), K(scan_param_), KPC(index_ctdef_),
K(lookup_rowkey_cnt_), K(lookup_row_cnt_));
}
const ObNewRowIterator *rowkey_iter = static_cast<ObGroupScanIter *>(get_rowkey_iter())->get_iter();
if (rowkey_iter != nullptr && rowkey_iter->get_type() == ObNewRowIterator::ObTableScanIterator) {
LOG_ERROR("rowkey_iter iter is not released, maybe some bug occured",
KPC(lookup_ctdef_), K(scan_param_), KPC(index_ctdef_),
K(lookup_rowkey_cnt_), K(lookup_row_cnt_));
}
}
int ObGroupLookupOp::init_group_range(int64_t cur_group_idx, int64_t group_size)
{

View File

@ -25,6 +25,7 @@ public:
index_group_cnt_(1),
lookup_group_cnt_(1)
{}
virtual ~ObGroupLookupOp();
virtual void reset() override
{
ObLocalIndexLookupOp::reset();
@ -57,6 +58,7 @@ class ObDASGroupScanOp : public ObDASScanOp
OB_UNIS_VERSION(1);
public:
ObDASGroupScanOp(common::ObIAllocator &op_alloc);
virtual ~ObDASGroupScanOp();
int open_op() override;
int release_op() override;
virtual int rescan() override;

View File

@ -168,7 +168,14 @@ int ObDASSyncFetchP::process()
} else if (OB_FAIL(das->get_task_res_mgr().iterator_task_result(task_id,
datum_store,
has_more))) {
LOG_WARN("get task result failed", KR(ret), K(res));
if (OB_UNLIKELY(OB_ENTRY_NOT_EXIST == ret)) {
// After server reboot, the hash map containing task results was gone.
// We need to retry for such cases.
LOG_WARN("task result was gone due to server reboot, will retry", KR(ret), K(res));
ret = OB_RPC_SEND_ERROR;
} else {
LOG_WARN("get task result failed", KR(ret), K(res));
}
} else {
res.set_has_more(has_more);
}

View File

@ -361,7 +361,11 @@ int ObDASTaskResultMgr::iterator_task_result(int64_t task_id,
ret = OB_ERR_UNEXPECTED;
LOG_WARN("das tcb is null", KR(ret), K(task_id));
} else if (tcb->is_exiting_) {
ret = OB_INVALID_ARGUMENT;
// The background GC thread is already cleaning up this tcb,
// and it will be removed from the hash map shortly.
// This happens when the task result has expired meaning the
// SQL has timed out.
ret = OB_TIMEOUT;
LOG_WARN("das tcb is exiting", KR(ret), K(task_id));
} else if (tcb->is_reading_) {
ret = OB_EAGAIN;

View File

@ -414,26 +414,18 @@ int ObVariableSetExecutor::execute_subquery_expr(ObExecContext &ctx,
LOG_WARN("failed to get obj", K(ret), K(idx));
}
}
if (OB_FAIL(ret)) {
} else if (OB_NOT_NULL(conn) && OB_NOT_NULL(sql_proxy) &&
OB_FAIL(sql_proxy->close(conn, true))) {
LOG_WARN("failed to close connection", K(ret));
} else if (tmp_value.need_deep_copy()) {
char *copy_data = NULL;
int64_t copy_size = tmp_value.get_deep_copy_size();
int64_t copy_pos = 0;
if (OB_ISNULL(copy_data = static_cast<char *>(ctx.get_allocator().alloc(copy_size)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("memory allocate failed", K(ret));
} else if (OB_FAIL(value_obj.deep_copy(tmp_value, copy_data, copy_size, copy_pos))) {
LOG_WARN("obj deep copy failed", K(ret));
}
LOG_TRACE("succeed to deep copy current value", K(ret));
} else {
value_obj = tmp_value;
if (OB_SUCC(ret) && (OB_FAIL(ob_write_obj(ctx.get_allocator(), tmp_value, value_obj)))) {
LOG_WARN("failed to write value", K(ret));
}
LOG_TRACE("succ to calculate value by executing inner sql", K(ret), K(value_obj), K(subquery_expr));
}
if (OB_NOT_NULL(conn) && OB_NOT_NULL(sql_proxy)) {
int tmp_ret = sql_proxy->close(conn, true);
if (OB_UNLIKELY(tmp_ret != OB_SUCCESS)) {
LOG_WARN("failed to close sql connection", K(tmp_ret));
}
ret = ret == OB_SUCCESS ? tmp_ret : ret;
}
return ret;
}

View File

@ -250,7 +250,7 @@ int ObDatumHexUtils::hex(const ObExpr &expr, const ObString &in_str, ObEvalCtx &
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc memory failed", K(ret), K(alloc_length));
} else {
static const char *HEXCHARS = upper_case ? "0123456789ABCDEF" : "0123456789abcdef";
const char *HEXCHARS = upper_case ? "0123456789ABCDEF" : "0123456789abcdef";
int32_t pos = 0;
for (int32_t i = 0; i < in_str.length(); ++i) {
buf[pos++] = HEXCHARS[in_str[i] >> 4 & 0xF];

View File

@ -262,7 +262,7 @@ int ObExprJsonSearch::eval_json_search(const ObExpr &expr, ObEvalCtx &ctx, ObDat
}
// check one_or_all flag
bool one_flag;
bool one_flag = false;
if (OB_SUCC(ret) && !is_null) {
json_arg = expr.args_[1];
val_type = json_arg->datum_meta_.type_;

View File

@ -1151,7 +1151,7 @@ int ObExprJsonValue::cast_to_res(common::ObIAllocator *allocator,
case ObMediumIntType:
case ObInt32Type:
case ObIntType: {
int64_t val;
int64_t val = 0;
ret = cast_to_int(j_base, dst_type, val);
if (!try_set_error_val<ObDatum>(res, ret, error_type, error_val, "SIGNED")) {
res.set_int(val);
@ -1163,7 +1163,7 @@ int ObExprJsonValue::cast_to_res(common::ObIAllocator *allocator,
case ObUMediumIntType:
case ObUInt32Type:
case ObUInt64Type: {
uint64_t val;
uint64_t val = 0;
ret = cast_to_uint(j_base, dst_type, val);
if (!try_set_error_val<ObDatum>(res, ret, error_type, error_val, "UNSIGNED")) {
res.set_uint(val);
@ -1171,7 +1171,7 @@ int ObExprJsonValue::cast_to_res(common::ObIAllocator *allocator,
break;
}
case ObDateTimeType: {
int64_t val;
int64_t val = 0;
ret = cast_to_datetime(j_base, accuracy, val);
if (ret == OB_ERR_NULL_VALUE) {
res.set_null();
@ -1192,7 +1192,7 @@ int ObExprJsonValue::cast_to_res(common::ObIAllocator *allocator,
break;
}
case ObDateType: {
int32_t val;
int32_t val = 0;
ret = cast_to_date(j_base, val);
if (!try_set_error_val<ObDatum>(res, ret, error_type, error_val, "DATE")) {
res.set_date(val);
@ -1200,7 +1200,7 @@ int ObExprJsonValue::cast_to_res(common::ObIAllocator *allocator,
break;
}
case ObTimeType: {
int64_t val;
int64_t val = 0;
ret = cast_to_time(j_base, accuracy, val);
if (!try_set_error_val<ObDatum>(res, ret, error_type, error_val, "TIME")) {
res.set_time(val);
@ -1208,7 +1208,7 @@ int ObExprJsonValue::cast_to_res(common::ObIAllocator *allocator,
break;
}
case ObYearType: {
uint8_t val;
uint8_t val = 0;
ret = cast_to_year(j_base, val);
if (!try_set_error_val<ObDatum>(res, ret, error_type, error_val, "YEAR")) {
res.set_year(val);
@ -1217,7 +1217,7 @@ int ObExprJsonValue::cast_to_res(common::ObIAllocator *allocator,
}
case ObFloatType:
case ObUFloatType: {
float out_val;
float out_val = 0;
ret = cast_to_float(j_base, dst_type, out_val);
if (!try_set_error_val<ObDatum>(res, ret, error_type, error_val, "FLOAT")) {
res.set_float(out_val);
@ -1226,7 +1226,7 @@ int ObExprJsonValue::cast_to_res(common::ObIAllocator *allocator,
}
case ObDoubleType:
case ObUDoubleType: {
double out_val;
double out_val = 0;
ret = cast_to_double(j_base, dst_type, out_val);
if (!try_set_error_val<ObDatum>(res, ret, error_type, error_val, "DOUBLE")) {
res.set_double(out_val);
@ -1268,7 +1268,7 @@ int ObExprJsonValue::cast_to_res(common::ObIAllocator *allocator,
break;
}
case ObBitType: {
uint64_t out_val;
uint64_t out_val = 0;
ret = cast_to_bit(j_base, out_val);
if (!try_set_error_val<ObDatum>(res, ret, error_type, error_val, "BIT")) {
res.set_bit(out_val);

View File

@ -45,12 +45,12 @@ int ObExprLastTraceId::eval_last_trace_id(const ObExpr &expr, ObEvalCtx &ctx,
{
int ret = OB_SUCCESS;
UNUSED(expr);
const ObSQLSessionInfo *session_info = NULL;
if (OB_ISNULL(session_info = ctx.exec_ctx_.get_my_session())) {
const ObPhysicalPlanCtx *phy_plan_ctx = NULL;
if (OB_ISNULL(phy_plan_ctx = ctx.exec_ctx_.get_physical_plan_ctx())) {
ret = OB_ERR_UNEXPECTED;
SQL_ENG_LOG(WARN, "session info is null", K(ret));
} else {
const ObCurTraceId::TraceId &trace_id = session_info->get_last_trace_id();
const ObCurTraceId::TraceId &trace_id = phy_plan_ctx->get_last_trace_id();
if (trace_id.is_invalid()) {
expr_datum.set_null();
} else {

View File

@ -1172,9 +1172,9 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObVarcharType, /*VarcharType=>HexStringType */
ObMaxType, /*VarcharType=>ExtendType */
ObVarcharType, /*VarcharType=>UnknownType */
ObTinyTextType, /*VarcharType=>ObTinyTextType */
ObTextType, /* VarcharType=>ObTextType */
ObMediumTextType, /* VarcharType=>ObMediumTextType */
ObLongTextType, /*VarcharType=>ObTinyTextType */
ObLongTextType, /* VarcharType=>ObTextType */
ObLongTextType, /* VarcharType=>ObMediumTextType */
ObLongTextType, /* VarcharType=>ObLongTextType */
ObVarcharType, /* VarcharType=>ObBitType */
ObVarcharType, /* VarcharType=>ObEnumType */
@ -1224,9 +1224,9 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObVarcharType, /*CharType=>HexStringType */
ObMaxType, /*CharType=>ExtendType */
ObVarcharType, /*CharType=>UnknownType */
ObTinyTextType, /*CharType=>ObTinyTextType */
ObTextType, /* CharType=>ObTextType */
ObMediumTextType, /* CharType=>ObMediumTextType */
ObLongTextType, /*CharType=>ObTinyTextType */
ObLongTextType, /* CharType=>ObTextType */
ObLongTextType, /* CharType=>ObMediumTextType */
ObLongTextType, /* CharType=>ObLongTextType */
ObCharType, /* CharType=>ObBitType */
ObCharType, /* CharType=>ObEnumType */
@ -1426,8 +1426,8 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObTinyTextType, /*ObTinyTextType=>DateType */
ObTinyTextType, /*ObTinyTextType=>TimeType */
ObTinyTextType, /*ObTinyTextType=>YearType */
ObTinyTextType, /*ObTinyTextType=>VarcharType */
ObTinyTextType, /*ObTinyTextType=>CharType */
ObLongTextType, /*ObTinyTextType=>VarcharType */
ObLongTextType, /*ObTinyTextType=>CharType */
ObTinyTextType, /*ObTinyTextType=>HexStringType */
ObMaxType, /*ObTinyTextType=>ExtendType */
ObTinyTextType, /*ObTinyTextType=>UnknownType */
@ -1435,9 +1435,9 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObTextType, /* ObTinyTextType=>ObTextType */
ObMediumTextType, /* ObTinyTextType=>ObMediumTextType */
ObLongTextType, /* ObTinyTextType=>ObLongTextType */
ObTextType, /* ObTinyTextType=>ObBitType */
ObTextType, /* ObTinyTextType=>ObEnumType */
ObTextType, /* ObTinyTextType=>ObSetType */
ObLongTextType, /* ObTinyTextType=>ObBitType */
ObLongTextType, /* ObTinyTextType=>ObEnumType */
ObLongTextType, /* ObTinyTextType=>ObSetType */
ObMaxType, /* ObTinyTextType=>ObEnumInnerType */
ObMaxType, /* ObTinyTextType=>ObSetInnerType */
ObTinyTextType, /*ObTinyTextType=>ObTimestampTZType */
@ -1477,8 +1477,8 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObTextType, /*ObTextType=>DateType */
ObTextType, /*ObTextType=>TimeType */
ObTextType, /*ObTextType=>YearType */
ObTextType, /*ObTextType=>VarcharType */
ObTextType, /*ObTextType=>CharType */
ObLongTextType, /*ObTextType=>VarcharType */
ObLongTextType, /*ObTextType=>CharType */
ObTextType, /*ObTextType=>HexStringType */
ObMaxType, /*ObTextType=>ExtendType */
ObTextType, /*ObTextType=>UnknownType */
@ -1486,9 +1486,9 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObTextType, /* ObTextType=>ObTextType */
ObMediumTextType, /* ObTextType=>ObMediumTextType */
ObLongTextType, /* ObTextType=>ObLongTextType */
ObMediumTextType, /* ObTextType=>ObBitType */
ObMediumTextType, /* ObTextType=>ObEnumType */
ObMediumTextType, /* ObTextType=>ObSetType */
ObLongTextType, /* ObTextType=>ObBitType */
ObLongTextType, /* ObTextType=>ObEnumType */
ObLongTextType, /* ObTextType=>ObSetType */
ObMaxType, /* ObTextType=>ObEnumInnerType */
ObMaxType, /* ObTextType=>ObSetInnerType */
ObTextType, /*ObTextType=>ObTimestampTZType */
@ -1529,8 +1529,8 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObMediumTextType, /*ObMediumTextType=>DateType */
ObMediumTextType, /*ObMediumTextType=>TimeType */
ObMediumTextType, /*ObMediumTextType=>YearType */
ObMediumTextType, /*ObMediumTextType=>VarcharType */
ObMediumTextType, /*ObMediumTextType=>CharType */
ObLongTextType, /*ObMediumTextType=>VarcharType */
ObLongTextType, /*ObMediumTextType=>CharType */
ObMediumTextType, /*ObMediumTextType=>HexStringType */
ObMaxType, /*ObMediumTextType=>ExtendType */
ObMediumTextType, /*ObMediumTextType=>UnknownType */
@ -1636,8 +1636,8 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObVarcharType, /*ObBitType=>HexStringType */
ObMaxType, /*ObBitType=>ExtendType */
ObVarcharType, /*ObBitType=>UnknownType */
ObTextType, /*ObBitType=>ObTinyTextType */
ObMediumTextType, /* ObBitType=>ObTextType */
ObLongTextType, /*ObBitType=>ObTinyTextType */
ObLongTextType, /* ObBitType=>ObTextType */
ObLongTextType, /* ObBitType=>ObMediumTextType */
ObLongTextType, /* ObBitType=>ObLongTextType */
ObBitType, /* ObBitType=>ObBitType */
@ -1687,8 +1687,8 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObVarcharType, /*ObEnumType=>HexStringType */
ObMaxType, /*ObEnumType=>ExtendType */
ObVarcharType, /*ObEnumType=>UnknownType */
ObTextType, /*ObEnumType=>ObTinyTextType */
ObMediumTextType, /* ObEnumType=>ObTextType */
ObLongTextType, /*ObEnumType=>ObTinyTextType */
ObLongTextType, /* ObEnumType=>ObTextType */
ObLongTextType, /* ObEnumType=>ObMediumTextType */
ObLongTextType, /* ObEnumType=>ObLongTextType */
ObVarcharType, /* ObEnumType=>ObBitType */
@ -1738,8 +1738,8 @@ static ObObjType MERGE_RESULT_TYPE[ObMaxType][ObMaxType] = {
ObVarcharType, /*ObSetType=>HexStringType */
ObMaxType, /*ObSetType=>ExtendType */
ObVarcharType, /*ObSetType=>UnknownType */
ObTextType, /*ObSetType=>ObTinyTextType */
ObMediumTextType, /* ObSetType=>ObTextType */
ObLongTextType, /*ObSetType=>ObTinyTextType */
ObLongTextType, /* ObSetType=>ObTextType */
ObLongTextType, /* ObSetType=>ObMediumTextType */
ObLongTextType, /* ObSetType=>ObLongTextType */
ObVarcharType, /* ObSetType=>ObBitType */

View File

@ -147,8 +147,8 @@ int ObExprRepeat::repeat(ObString &output,
if ((length > max_result_size / count) || (length > INT_MAX / count)) {
LOG_WARN("Result of repeat was larger than max_allow_packet_size",
K(ret), K(length), K(count), K(max_result_size));
LOG_USER_WARN(OB_ERR_FUNC_RESULT_TOO_LARGE, "repeat", static_cast<int>(max_result_size));
is_null = true;
ret = OB_ERR_FUNC_RESULT_TOO_LARGE;
LOG_USER_ERROR(OB_ERR_FUNC_RESULT_TOO_LARGE, "repeat", static_cast<int>(max_result_size));
} else {
//avoid realloc
if (1 == count) {

View File

@ -681,6 +681,7 @@ OB_DEF_SERIALIZE(ObPhysicalPlanCtx)
OB_UNIS_ENCODE(tenant_schema_version_);
OB_UNIS_ENCODE(cursor_count);
OB_UNIS_ENCODE(plan_start_time_);
OB_UNIS_ENCODE(last_trace_id_);
return ret;
}
@ -762,6 +763,7 @@ OB_DEF_SERIALIZE_SIZE(ObPhysicalPlanCtx)
OB_UNIS_ADD_LEN(tenant_schema_version_);
OB_UNIS_ADD_LEN(cursor_count);
OB_UNIS_ADD_LEN(plan_start_time_);
OB_UNIS_ADD_LEN(last_trace_id_);
return len;
}
@ -842,6 +844,7 @@ OB_DEF_DESERIALIZE(ObPhysicalPlanCtx)
(void)ObSQLUtils::adjust_time_by_ntp_offset(plan_start_time_);
(void)ObSQLUtils::adjust_time_by_ntp_offset(ts_timeout_us_);
}
OB_UNIS_DECODE(last_trace_id_);
return ret;
}

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