[BUG] remove error when alloc memory when offlined for memtable
This commit is contained in:
@ -110,21 +110,28 @@ void* ObMemstoreAllocator::alloc(AllocHandle& handle, int64_t size, const int64_
|
|||||||
COMMON_LOG(TRACE, "MTALLOC.first_alloc", KP(&handle.mt_));
|
COMMON_LOG(TRACE, "MTALLOC.first_alloc", KP(&handle.mt_));
|
||||||
LockGuard guard(lock_);
|
LockGuard guard(lock_);
|
||||||
if (handle.is_frozen()) {
|
if (handle.is_frozen()) {
|
||||||
COMMON_LOG(ERROR, "cannot alloc because allocator is frozen", K(ret), K(handle.mt_));
|
ret = OB_EAGAIN;
|
||||||
|
if (!handle.mt_.get_offlined()) {
|
||||||
|
COMMON_LOG(ERROR, "cannot alloc because allocator is frozen", K(ret), K(handle.mt_));
|
||||||
|
} else {
|
||||||
|
COMMON_LOG(WARN, "cannot alloc because allocator is frozen", K(ret), K(handle.mt_));
|
||||||
|
}
|
||||||
} else if (!handle.is_id_valid()) {
|
} else if (!handle.is_id_valid()) {
|
||||||
handle.set_clock(arena_.retired());
|
handle.set_clock(arena_.retired());
|
||||||
hlist_.set_active(handle);
|
hlist_.set_active(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
storage::ObTenantFreezer *freezer = nullptr;
|
if (OB_SUCC(ret)) {
|
||||||
if (is_virtual_tenant_id(tenant_id)) {
|
storage::ObTenantFreezer *freezer = nullptr;
|
||||||
// virtual tenant should not have memstore.
|
if (is_virtual_tenant_id(tenant_id)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
// virtual tenant should not have memstore.
|
||||||
COMMON_LOG(ERROR, "virtual tenant should not have memstore", K(ret), K(tenant_id));
|
ret = OB_ERR_UNEXPECTED;
|
||||||
} else if (FALSE_IT(freezer = MTL(storage::ObTenantFreezer *))) {
|
COMMON_LOG(ERROR, "virtual tenant should not have memstore", K(ret), K(tenant_id));
|
||||||
} else if (OB_FAIL(freezer->check_memstore_full_internal(is_out_of_mem))) {
|
} else if (FALSE_IT(freezer = MTL(storage::ObTenantFreezer *))) {
|
||||||
COMMON_LOG(ERROR, "fail to check tenant out of mem limit", K(ret), K(tenant_id));
|
} else if (OB_FAIL(freezer->check_memstore_full_internal(is_out_of_mem))) {
|
||||||
|
COMMON_LOG(ERROR, "fail to check tenant out of mem limit", K(ret), K(tenant_id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *res = nullptr;
|
void *res = nullptr;
|
||||||
|
|||||||
@ -1924,7 +1924,7 @@ bool ObMemtable::ready_for_flush_()
|
|||||||
set_freeze_state(TabletMemtableFreezeState::READY_FOR_FLUSH);
|
set_freeze_state(TabletMemtableFreezeState::READY_FOR_FLUSH);
|
||||||
if (0 == mt_stat_.ready_for_flush_time_) {
|
if (0 == mt_stat_.ready_for_flush_time_) {
|
||||||
mt_stat_.ready_for_flush_time_ = ObTimeUtility::current_time();
|
mt_stat_.ready_for_flush_time_ = ObTimeUtility::current_time();
|
||||||
freezer_->get_stat().remove_memtable_info(get_tablet_id());
|
freezer_->get_stat().remove_memtable_info(get_tablet_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -136,8 +136,13 @@ const static char *TABLET_MEMTABLE_FREEZE_STATE_TO_STR(const int64_t state)
|
|||||||
STATIC_ASSERT(TabletMemtableFreezeState::FLUSHED == 4, "Invalid State Enum");
|
STATIC_ASSERT(TabletMemtableFreezeState::FLUSHED == 4, "Invalid State Enum");
|
||||||
STATIC_ASSERT(TabletMemtableFreezeState::RELEASED == 5, "Invalid State Enum");
|
STATIC_ASSERT(TabletMemtableFreezeState::RELEASED == 5, "Invalid State Enum");
|
||||||
STATIC_ASSERT(TabletMemtableFreezeState::FORCE_RELEASED == 6, "Invalid State Enum");
|
STATIC_ASSERT(TabletMemtableFreezeState::FORCE_RELEASED == 6, "Invalid State Enum");
|
||||||
const static char TABLET_MEMTABLE_FREEZE_STATE_TO_STR[7][20] =
|
const static char TABLET_MEMTABLE_FREEZE_STATE_TO_STR[7][20] = {"INVALID",
|
||||||
{"INVALID", "ACTIVE", "FREEZING", "READY_FOR_FLUSH", "FLUSHED", "RELEASED", "FORCE_RELEASED"};
|
"ACTIVE",
|
||||||
|
"FREEZING",
|
||||||
|
"READY_FOR_FLUSH",
|
||||||
|
"FLUSHED",
|
||||||
|
"RELEASED",
|
||||||
|
"FORCE_RELEASED"};
|
||||||
return TABLET_MEMTABLE_FREEZE_STATE_TO_STR[state];
|
return TABLET_MEMTABLE_FREEZE_STATE_TO_STR[state];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +204,7 @@ public:
|
|||||||
resolved_active_memtable_left_boundary_(true),
|
resolved_active_memtable_left_boundary_(true),
|
||||||
unset_active_memtable_logging_blocked_(false),
|
unset_active_memtable_logging_blocked_(false),
|
||||||
has_backoffed_(false),
|
has_backoffed_(false),
|
||||||
|
offlined_(false),
|
||||||
read_barrier_(false),
|
read_barrier_(false),
|
||||||
unsubmitted_cnt_(0),
|
unsubmitted_cnt_(0),
|
||||||
logging_blocked_start_time_(0),
|
logging_blocked_start_time_(0),
|
||||||
@ -224,6 +230,7 @@ public:
|
|||||||
resolved_active_memtable_left_boundary_ = true;
|
resolved_active_memtable_left_boundary_ = true;
|
||||||
unset_active_memtable_logging_blocked_ = false;
|
unset_active_memtable_logging_blocked_ = false;
|
||||||
has_backoffed_ = false;
|
has_backoffed_ = false;
|
||||||
|
offlined_ = false;
|
||||||
read_barrier_ = false;
|
read_barrier_ = false;
|
||||||
freeze_clock_ = 0;
|
freeze_clock_ = 0;
|
||||||
freeze_state_ = TabletMemtableFreezeState::INVALID;
|
freeze_state_ = TabletMemtableFreezeState::INVALID;
|
||||||
@ -314,6 +321,8 @@ public:
|
|||||||
UNSET_ACTIVE_MEMTABLE_LOGGING_BLOCKED);
|
UNSET_ACTIVE_MEMTABLE_LOGGING_BLOCKED);
|
||||||
|
|
||||||
OB_MEMTABLE_DEFINE_FLAG_OPERATOR(has_backoffed, HAS_BACKOFFED);
|
OB_MEMTABLE_DEFINE_FLAG_OPERATOR(has_backoffed, HAS_BACKOFFED);
|
||||||
|
|
||||||
|
OB_MEMTABLE_DEFINE_FLAG_OPERATOR(offlined, OFFLINED);
|
||||||
// ************* memtable flag operator *************
|
// ************* memtable flag operator *************
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -330,7 +339,7 @@ public:
|
|||||||
void set_push_table_into_gc_queue_time(const int64_t timestamp) { mt_stat_.push_table_into_gc_queue_time_ = timestamp; }
|
void set_push_table_into_gc_queue_time(const int64_t timestamp) { mt_stat_.push_table_into_gc_queue_time_ = timestamp; }
|
||||||
void set_freeze_state(const TabletMemtableFreezeState state)
|
void set_freeze_state(const TabletMemtableFreezeState state)
|
||||||
{
|
{
|
||||||
if (state >= TabletMemtableFreezeState::ACTIVE && state <= TabletMemtableFreezeState::FORCE_RELEASED) {
|
if (state >= TabletMemtableFreezeState::ACTIVE && state < TabletMemtableFreezeState::MAX_FREEZE_STATE) {
|
||||||
freeze_state_ = state;
|
freeze_state_ = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,6 +388,7 @@ public:
|
|||||||
K(resolved_active_memtable_left_boundary_),
|
K(resolved_active_memtable_left_boundary_),
|
||||||
K(unset_active_memtable_logging_blocked_),
|
K(unset_active_memtable_logging_blocked_),
|
||||||
K(has_backoffed_),
|
K(has_backoffed_),
|
||||||
|
K(offlined_),
|
||||||
K(read_barrier_),
|
K(read_barrier_),
|
||||||
K(freeze_clock_),
|
K(freeze_clock_),
|
||||||
K(freeze_state_),
|
K(freeze_state_),
|
||||||
@ -435,6 +445,7 @@ private:
|
|||||||
static const uint8_t MEMTABLE_RESOLVED_ACTIVE_MEMTABLE_LEFT_BOUNDARY_MASK = 1 << 4;
|
static const uint8_t MEMTABLE_RESOLVED_ACTIVE_MEMTABLE_LEFT_BOUNDARY_MASK = 1 << 4;
|
||||||
static const uint8_t MEMTABLE_UNSET_ACTIVE_MEMTABLE_LOGGING_BLOCKED_MASK = 1 << 5;
|
static const uint8_t MEMTABLE_UNSET_ACTIVE_MEMTABLE_LOGGING_BLOCKED_MASK = 1 << 5;
|
||||||
static const uint8_t MEMTABLE_HAS_BACKOFFED_MASK = 1 << 6;
|
static const uint8_t MEMTABLE_HAS_BACKOFFED_MASK = 1 << 6;
|
||||||
|
static const uint8_t MEMTABLE_OFFLINED_MASK = 1 << 7;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
// NB: not allow to use it directly
|
// NB: not allow to use it directly
|
||||||
@ -457,6 +468,8 @@ private:
|
|||||||
// whether the memtable has backoffed its
|
// whether the memtable has backoffed its
|
||||||
// right boundary because of sync_log_fail
|
// right boundary because of sync_log_fail
|
||||||
bool has_backoffed_ :1;
|
bool has_backoffed_ :1;
|
||||||
|
// whether the memtable is during offline
|
||||||
|
bool offlined_ :1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -994,6 +994,7 @@ int ObTabletMemtableMgr::set_frozen_for_all_memtables()
|
|||||||
STORAGE_LOG(WARN, "memtable is nullptr", K(ret), K(ls_id), KP(memtable), K(i));
|
STORAGE_LOG(WARN, "memtable is nullptr", K(ret), K(ls_id), KP(memtable), K(i));
|
||||||
} else {
|
} else {
|
||||||
STORAGE_LOG(INFO, "set frozen for offline", K(ls_id), K(i), KPC(memtable));
|
STORAGE_LOG(INFO, "set frozen for offline", K(ls_id), K(i), KPC(memtable));
|
||||||
|
memtable->set_offlined();
|
||||||
memtable->set_frozen();
|
memtable->set_frozen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user