[FIX] dead loop when create ddl kv
This commit is contained in:
@ -68,11 +68,17 @@ int ObDirectLoadTableGuard::prepare_memtable(ObDDLKV *&res_memtable)
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
res_memtable = nullptr;
|
res_memtable = nullptr;
|
||||||
bool tried_freeze = false;
|
bool tried_freeze = false;
|
||||||
|
bool need_retry = false;
|
||||||
const int64_t INC_MACRO_BLOCK_COUNT_FREEZE_TRIGGER =
|
const int64_t INC_MACRO_BLOCK_COUNT_FREEZE_TRIGGER =
|
||||||
10 * 10L * 1024L * 1024L * 1024L / OB_SERVER_BLOCK_MGR.get_macro_block_size();
|
10 * 10L * 1024L * 1024L * 1024L / OB_SERVER_BLOCK_MGR.get_macro_block_size();
|
||||||
const int64_t INC_MACRO_BLOCK_MEMORY_FREEZE_TRIGGER = 50 * 1024 * 1024; // 50M;
|
const int64_t INC_MACRO_BLOCK_MEMORY_FREEZE_TRIGGER = 50 * 1024 * 1024; // 50M;
|
||||||
|
const int64_t start_time = ObClockGenerator::getClock();
|
||||||
|
|
||||||
|
// this do_while loop up to twice
|
||||||
|
// the first time : may trigger independent freeze
|
||||||
|
// the second time : just acquire direct load memtable to write
|
||||||
do {
|
do {
|
||||||
|
need_retry = false;
|
||||||
ObDDLKV *ddl_kv = nullptr;
|
ObDDLKV *ddl_kv = nullptr;
|
||||||
if (OB_FAIL(acquire_memtable_once_())) {
|
if (OB_FAIL(acquire_memtable_once_())) {
|
||||||
STORAGE_LOG(WARN, "acquire direct load memtable failed", KR(ret), KPC(this));
|
STORAGE_LOG(WARN, "acquire direct load memtable failed", KR(ret), KPC(this));
|
||||||
@ -84,7 +90,7 @@ int ObDirectLoadTableGuard::prepare_memtable(ObDDLKV *&res_memtable)
|
|||||||
ddl_kv->get_memory_used() >= INC_MACRO_BLOCK_MEMORY_FREEZE_TRIGGER)) {
|
ddl_kv->get_memory_used() >= INC_MACRO_BLOCK_MEMORY_FREEZE_TRIGGER)) {
|
||||||
reset(); // ATTENTION!!! : must reset guard, or freeze cannot finish
|
reset(); // ATTENTION!!! : must reset guard, or freeze cannot finish
|
||||||
tried_freeze = true; // only try independent freeze once
|
tried_freeze = true; // only try independent freeze once
|
||||||
ret = OB_EAGAIN; // to execute loop again
|
need_retry = true;
|
||||||
|
|
||||||
int tmp_ret = OB_SUCCESS;
|
int tmp_ret = OB_SUCCESS;
|
||||||
if (OB_TMP_FAIL(ddl_kv->freeze())) {
|
if (OB_TMP_FAIL(ddl_kv->freeze())) {
|
||||||
@ -97,7 +103,7 @@ int ObDirectLoadTableGuard::prepare_memtable(ObDDLKV *&res_memtable)
|
|||||||
res_memtable = ddl_kv;
|
res_memtable = ddl_kv;
|
||||||
has_acquired_memtable_ = true;
|
has_acquired_memtable_ = true;
|
||||||
}
|
}
|
||||||
} while (OB_EAGAIN == ret);
|
} while (OB_SUCC(ret) && need_retry);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -129,7 +135,6 @@ int ObDirectLoadTableGuard::acquire_memtable_once_()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
const int64_t MAX_RETRY_CREATE_MEMTABLE_TIME = 1LL * 1000LL * 1000LL;
|
|
||||||
if ((OB_ALLOCATE_MEMORY_FAILED == ret || OB_MINOR_FREEZE_NOT_ALLOW == ret) &&
|
if ((OB_ALLOCATE_MEMORY_FAILED == ret || OB_MINOR_FREEZE_NOT_ALLOW == ret) &&
|
||||||
(ObClockGenerator::getClock() - start_time < MAX_RETRY_CREATE_MEMTABLE_TIME)) {
|
(ObClockGenerator::getClock() - start_time < MAX_RETRY_CREATE_MEMTABLE_TIME)) {
|
||||||
ret = OB_SUCCESS;
|
ret = OB_SUCCESS;
|
||||||
|
|||||||
@ -25,6 +25,9 @@ class ObTablet;
|
|||||||
class ObDDLKV;
|
class ObDDLKV;
|
||||||
|
|
||||||
class ObDirectLoadTableGuard {
|
class ObDirectLoadTableGuard {
|
||||||
|
private:
|
||||||
|
static const int64_t MAX_RETRY_CREATE_MEMTABLE_TIME = 1LL * 1000LL * 1000LL; // 1 second
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DISABLE_COPY_ASSIGN(ObDirectLoadTableGuard);
|
DISABLE_COPY_ASSIGN(ObDirectLoadTableGuard);
|
||||||
ObDirectLoadTableGuard(ObTablet &tablet, const share::SCN &scn, const bool for_replay);
|
ObDirectLoadTableGuard(ObTablet &tablet, const share::SCN &scn, const bool for_replay);
|
||||||
|
|||||||
Reference in New Issue
Block a user