diff --git a/src/share/allocator/ob_memstore_allocator.cpp b/src/share/allocator/ob_memstore_allocator.cpp index f95b0ee37a..58679a0283 100644 --- a/src/share/allocator/ob_memstore_allocator.cpp +++ b/src/share/allocator/ob_memstore_allocator.cpp @@ -110,21 +110,28 @@ void* ObMemstoreAllocator::alloc(AllocHandle& handle, int64_t size, const int64_ COMMON_LOG(TRACE, "MTALLOC.first_alloc", KP(&handle.mt_)); LockGuard guard(lock_); 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()) { handle.set_clock(arena_.retired()); hlist_.set_active(handle); } } - storage::ObTenantFreezer *freezer = nullptr; - if (is_virtual_tenant_id(tenant_id)) { - // virtual tenant should not have memstore. - ret = OB_ERR_UNEXPECTED; - COMMON_LOG(ERROR, "virtual tenant should not have memstore", K(ret), K(tenant_id)); - } else if (FALSE_IT(freezer = MTL(storage::ObTenantFreezer *))) { - } 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)); + if (OB_SUCC(ret)) { + storage::ObTenantFreezer *freezer = nullptr; + if (is_virtual_tenant_id(tenant_id)) { + // virtual tenant should not have memstore. + ret = OB_ERR_UNEXPECTED; + COMMON_LOG(ERROR, "virtual tenant should not have memstore", K(ret), K(tenant_id)); + } else if (FALSE_IT(freezer = MTL(storage::ObTenantFreezer *))) { + } 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; diff --git a/src/storage/memtable/ob_memtable.cpp b/src/storage/memtable/ob_memtable.cpp index 7feda96974..17287421d1 100644 --- a/src/storage/memtable/ob_memtable.cpp +++ b/src/storage/memtable/ob_memtable.cpp @@ -1924,7 +1924,7 @@ bool ObMemtable::ready_for_flush_() set_freeze_state(TabletMemtableFreezeState::READY_FOR_FLUSH); if (0 == mt_stat_.ready_for_flush_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()); } } diff --git a/src/storage/ob_i_tablet_memtable.h b/src/storage/ob_i_tablet_memtable.h index bb9f923293..26d455d511 100644 --- a/src/storage/ob_i_tablet_memtable.h +++ b/src/storage/ob_i_tablet_memtable.h @@ -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::RELEASED == 5, "Invalid State Enum"); STATIC_ASSERT(TabletMemtableFreezeState::FORCE_RELEASED == 6, "Invalid State Enum"); - const static char TABLET_MEMTABLE_FREEZE_STATE_TO_STR[7][20] = - {"INVALID", "ACTIVE", "FREEZING", "READY_FOR_FLUSH", "FLUSHED", "RELEASED", "FORCE_RELEASED"}; + const static char TABLET_MEMTABLE_FREEZE_STATE_TO_STR[7][20] = {"INVALID", + "ACTIVE", + "FREEZING", + "READY_FOR_FLUSH", + "FLUSHED", + "RELEASED", + "FORCE_RELEASED"}; return TABLET_MEMTABLE_FREEZE_STATE_TO_STR[state]; } @@ -199,6 +204,7 @@ public: resolved_active_memtable_left_boundary_(true), unset_active_memtable_logging_blocked_(false), has_backoffed_(false), + offlined_(false), read_barrier_(false), unsubmitted_cnt_(0), logging_blocked_start_time_(0), @@ -224,6 +230,7 @@ public: resolved_active_memtable_left_boundary_ = true; unset_active_memtable_logging_blocked_ = false; has_backoffed_ = false; + offlined_ = false; read_barrier_ = false; freeze_clock_ = 0; freeze_state_ = TabletMemtableFreezeState::INVALID; @@ -314,6 +321,8 @@ public: UNSET_ACTIVE_MEMTABLE_LOGGING_BLOCKED); OB_MEMTABLE_DEFINE_FLAG_OPERATOR(has_backoffed, HAS_BACKOFFED); + + OB_MEMTABLE_DEFINE_FLAG_OPERATOR(offlined, OFFLINED); // ************* memtable flag operator ************* 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_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; } } @@ -379,6 +388,7 @@ public: K(resolved_active_memtable_left_boundary_), K(unset_active_memtable_logging_blocked_), K(has_backoffed_), + K(offlined_), K(read_barrier_), K(freeze_clock_), 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_UNSET_ACTIVE_MEMTABLE_LOGGING_BLOCKED_MASK = 1 << 5; static const uint8_t MEMTABLE_HAS_BACKOFFED_MASK = 1 << 6; + static const uint8_t MEMTABLE_OFFLINED_MASK = 1 << 7; union { // NB: not allow to use it directly @@ -457,6 +468,8 @@ private: // whether the memtable has backoffed its // right boundary because of sync_log_fail bool has_backoffed_ :1; + // whether the memtable is during offline + bool offlined_ :1; }; }; diff --git a/src/storage/tablet/ob_tablet_memtable_mgr.cpp b/src/storage/tablet/ob_tablet_memtable_mgr.cpp index edac2e129d..af44e477aa 100644 --- a/src/storage/tablet/ob_tablet_memtable_mgr.cpp +++ b/src/storage/tablet/ob_tablet_memtable_mgr.cpp @@ -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)); } else { STORAGE_LOG(INFO, "set frozen for offline", K(ls_id), K(i), KPC(memtable)); + memtable->set_offlined(); memtable->set_frozen(); } }