diff --git a/src/sql/engine/dml/ob_dml_service.h b/src/sql/engine/dml/ob_dml_service.h index e20bd8b9b5..705eff1045 100644 --- a/src/sql/engine/dml/ob_dml_service.h +++ b/src/sql/engine/dml/ob_dml_service.h @@ -379,6 +379,7 @@ int ObDASIndexDMLAdaptor::write_tablet_with_ignore(DMLIterator & affected_rows = 0; const ObDASWriteBuffer::DmlRow *dml_row = nullptr; ObDASWriteBuffer::Iterator write_iter; + const bool with_local_index = related_ctdefs_ != nullptr && !related_ctdefs_->empty(); if (OB_FAIL(iter.get_write_buffer().begin(write_iter))) { LOG_WARN("begin write iterator failed", K(ret)); } @@ -406,6 +407,7 @@ int ObDASIndexDMLAdaptor::write_tablet_with_ignore(DMLIterator & DMLIterator single_row_iter(ctdef_, single_row_buffer, *das_allocator_); if (OB_FAIL(ObDMLService::init_dml_param(*ctdef_, *rtdef_, *snapshot_, write_branch_id_, *das_allocator_, dml_param_))) { SQL_DAS_LOG(WARN, "init dml param failed", K(ret), KPC_(ctdef), KPC_(rtdef)); + } else if (with_local_index && FALSE_IT(dml_param_.write_flag_.set_skip_flush_redo())) { } else if (OB_FAIL(write_rows(ls_id_, tablet_id_, *ctdef_, @@ -413,7 +415,7 @@ int ObDASIndexDMLAdaptor::write_tablet_with_ignore(DMLIterator & single_row_iter, table_affected_rows))) { SQL_DAS_LOG(WARN, "write rows failed", K(ret), K(ls_id_), K(tablet_id_), KPC(ctdef_), KPC(rtdef_)); - } else if (related_ctdefs_ != nullptr && !related_ctdefs_->empty()) { + } else if (with_local_index) { //write local index for (int64_t i = 0; OB_SUCC(ret) && i < related_ctdefs_->count(); ++i) { const CtDefType *related_ctdef = static_cast(related_ctdefs_->at(i)); @@ -433,6 +435,7 @@ int ObDASIndexDMLAdaptor::write_tablet_with_ignore(DMLIterator & dml_param_))) { SQL_DAS_LOG(WARN, "init index dml param failed", K(ret), KPC(related_ctdef), KPC(related_rtdef)); + } else if (i == related_ctdefs_->count() - 1 && FALSE_IT(dml_param_.write_flag_.unset_skip_flush_redo())) { } else if (OB_FAIL(write_rows(ls_id_, related_tablet_id, *related_ctdef, diff --git a/src/storage/lob/ob_lob_persistent_adaptor.cpp b/src/storage/lob/ob_lob_persistent_adaptor.cpp index 7166358b6b..c6bc241210 100644 --- a/src/storage/lob/ob_lob_persistent_adaptor.cpp +++ b/src/storage/lob/ob_lob_persistent_adaptor.cpp @@ -436,6 +436,7 @@ int ObPersistentLobApator::build_lob_meta_table_dml( dml_base_param.encrypt_meta_ = &dml_base_param.encrypt_meta_legacy_; dml_base_param.snapshot_ = param.snapshot_; dml_base_param.check_schema_version_ = false; // lob tablet should not check schema version + dml_base_param.write_flag_.set_lob_aux(); if (param.seq_no_st_.is_valid()) { if (param.used_seq_cnt_ < param.total_seq_cnt_) { dml_base_param.spec_seq_no_ = param.seq_no_st_ + param.used_seq_cnt_; diff --git a/src/storage/memtable/mvcc/ob_mvcc_ctx.cpp b/src/storage/memtable/mvcc/ob_mvcc_ctx.cpp index 073e4f1d63..a9b8d3e627 100644 --- a/src/storage/memtable/mvcc/ob_mvcc_ctx.cpp +++ b/src/storage/memtable/mvcc/ob_mvcc_ctx.cpp @@ -286,7 +286,9 @@ ObMvccWriteGuard::~ObMvccWriteGuard() int ret = OB_SUCCESS; transaction::ObPartTransCtx *tx_ctx = ctx_->get_trans_ctx(); ctx_->write_done(); - if (OB_NOT_NULL(memtable_)) { + if (write_ret_ && OB_SUCCESS == *write_ret_ + && OB_NOT_NULL(memtable_) + && try_flush_redo_) { bool is_freeze = memtable_->is_frozen_memtable(); ret = tx_ctx->submit_redo_after_write(is_freeze/*force*/, write_seq_no_); if (OB_FAIL(ret)) { @@ -314,6 +316,9 @@ int ObMvccWriteGuard::write_auth(storage::ObStoreCtx &store_ctx) } else { ctx_ = mem_ctx; write_seq_no_ = store_ctx.mvcc_acc_ctx_.tx_scn_; + try_flush_redo_ = !(store_ctx.mvcc_acc_ctx_.write_flag_.is_skip_flush_redo() + // for lob column write, delay flush redo to its main tablet's write + || store_ctx.mvcc_acc_ctx_.write_flag_.is_lob_aux()); } return ret; } diff --git a/src/storage/memtable/mvcc/ob_mvcc_ctx.h b/src/storage/memtable/mvcc/ob_mvcc_ctx.h index 28acd6b2ca..595225bfd4 100644 --- a/src/storage/memtable/mvcc/ob_mvcc_ctx.h +++ b/src/storage/memtable/mvcc/ob_mvcc_ctx.h @@ -249,8 +249,15 @@ public: : exclusive_(exclusive), ctx_(NULL), memtable_(NULL), - write_seq_no_() + write_ret_(NULL), + write_seq_no_(), + try_flush_redo_(true) {} + ObMvccWriteGuard(const int &ret, const bool exclusive = false) + : ObMvccWriteGuard(exclusive) + { + write_ret_ = &ret; + } ~ObMvccWriteGuard(); void set_memtable(ObMemtable *memtable) { memtable_ = memtable; @@ -269,7 +276,9 @@ private: const bool exclusive_; // if true multiple write_auth will be serialized ObMemtableCtx *ctx_; ObMemtable *memtable_; + const int *write_ret_; // used to sense write result is ok or fail transaction::ObTxSEQ write_seq_no_; + bool try_flush_redo_; }; } } diff --git a/src/storage/memtable/ob_concurrent_control.h b/src/storage/memtable/ob_concurrent_control.h index e5493eed5e..092999201d 100644 --- a/src/storage/memtable/ob_concurrent_control.h +++ b/src/storage/memtable/ob_concurrent_control.h @@ -31,7 +31,9 @@ struct ObWriteFlag #define OBWF_BIT_INSERT_UP 1 #define OBWF_BIT_WRITE_ONLY_INDEX 1 #define OBWF_BIT_CHECK_ROW_LOCKED 1 - #define OBWF_BIT_RESERVED 57 + #define OBWF_BIT_LOB_AUX 1 + #define OBWF_BIT_SKIP_FLUSH_REDO 1 + #define OBWF_BIT_RESERVED 55 static const uint64_t OBWF_MASK_TABLE_API = (0x1UL << OBWF_BIT_TABLE_API) - 1; static const uint64_t OBWF_MASK_TABLE_LOCK = (0x1UL << OBWF_BIT_TABLE_LOCK) - 1; @@ -53,6 +55,8 @@ struct ObWriteFlag uint64_t is_insert_up_ : OBWF_BIT_INSERT_UP; // 0: false(default), 1: true uint64_t is_write_only_index_ : OBWF_BIT_WRITE_ONLY_INDEX; // 0: false(default), 1: true uint64_t is_check_row_locked_ : OBWF_BIT_CHECK_ROW_LOCKED; // 0: false(default), 1: true + uint64_t is_lob_aux_ : OBWF_BIT_LOB_AUX; // 0: false(default), 1: true + uint64_t is_skip_flush_redo_ : OBWF_BIT_SKIP_FLUSH_REDO; // 0: false(default), 1: true uint64_t reserved_ : OBWF_BIT_RESERVED; }; }; @@ -73,6 +77,11 @@ struct ObWriteFlag inline void set_is_write_only_index() { is_write_only_index_ = true; } inline bool is_check_row_locked() const { return is_check_row_locked_; } inline void set_check_row_locked() { is_check_row_locked_ = true; } + inline bool is_lob_aux() const { return is_lob_aux_; } + inline void set_lob_aux() { is_lob_aux_ = true; } + inline bool is_skip_flush_redo() const { return is_skip_flush_redo_; } + inline void set_skip_flush_redo() { is_skip_flush_redo_ = true; } + inline void unset_skip_flush_redo() { is_skip_flush_redo_ = false; } TO_STRING_KV("is_table_api", is_table_api_, "is_table_lock", is_table_lock_, @@ -80,7 +89,9 @@ struct ObWriteFlag "is_dml_batch_opt", is_dml_batch_opt_, "is_insert_up", is_insert_up_, "is_write_only_index", is_write_only_index_, - "is_check_row_locked", is_check_row_locked_); + "is_check_row_locked", is_check_row_locked_, + "is_lob_aux", is_lob_aux_, + "is_skip_flush_redo", is_skip_flush_redo_); OB_UNIS_VERSION(1); }; diff --git a/src/storage/memtable/ob_memtable.cpp b/src/storage/memtable/ob_memtable.cpp index 4886d07b4f..daa20ad619 100644 --- a/src/storage/memtable/ob_memtable.cpp +++ b/src/storage/memtable/ob_memtable.cpp @@ -386,7 +386,7 @@ int ObMemtable::multi_set( storage::ObRowsInfo &rows_info) { int ret = OB_SUCCESS; - ObMvccWriteGuard guard; + ObMvccWriteGuard guard(ret); ObMemtableKeyGenerator mtk_generator; if (IS_NOT_INIT) { TRANS_LOG(WARN, "Not inited", K(*this)); @@ -486,7 +486,7 @@ int ObMemtable::set( const share::ObEncryptMeta *encrypt_meta) { int ret = OB_SUCCESS; - ObMvccWriteGuard guard; + ObMvccWriteGuard guard(ret); ObMemtableKeyGenerator mtk_generator; if (IS_NOT_INIT) { TRANS_LOG(WARN, "not init", K(*this)); @@ -548,7 +548,7 @@ int ObMemtable::set( const share::ObEncryptMeta *encrypt_meta) { int ret = OB_SUCCESS; - ObMvccWriteGuard guard; + ObMvccWriteGuard guard(ret); ObMemtableKeyGenerator mtk_generator; if (IS_NOT_INIT) { TRANS_LOG(WARN, "not init", K(*this)); @@ -604,7 +604,7 @@ int ObMemtable::lock( const common::ObNewRow &row) { int ret = OB_SUCCESS; - ObMvccWriteGuard guard; + ObMvccWriteGuard guard(ret); ObStoreRowkey tmp_key; ObMemtableKey mtk; @@ -654,7 +654,7 @@ int ObMemtable::lock( const blocksstable::ObDatumRowkey &rowkey) { int ret = OB_SUCCESS; - ObMvccWriteGuard guard; + ObMvccWriteGuard guard(ret); ObMemtableKey mtk; if (IS_NOT_INIT) { diff --git a/src/storage/ob_i_store.cpp b/src/storage/ob_i_store.cpp index 6a4e383094..01e30e06df 100644 --- a/src/storage/ob_i_store.cpp +++ b/src/storage/ob_i_store.cpp @@ -73,7 +73,7 @@ void ObStoreCtx::reset() tablet_id_.reset(); table_iter_ = nullptr; table_version_ = INT64_MAX; - timeout_ = -1; + timeout_ = 0; mvcc_acc_ctx_.reset(); tablet_stat_.reset(); is_read_store_ctx_ = false; diff --git a/src/storage/tx/ob_trans_rpc.h b/src/storage/tx/ob_trans_rpc.h index 359354420a..425500390c 100644 --- a/src/storage/tx/ob_trans_rpc.h +++ b/src/storage/tx/ob_trans_rpc.h @@ -267,7 +267,8 @@ int ObTxRPCCB::process() && !receiver_ls_id_.is_scheduler_ls() && receiver_ls_id_.is_valid() && need_refresh_location_cache_(status)) { - if (OB_FAIL(refresh_location_cache(receiver_ls_id_))) { + int tmp_ret = OB_SUCCESS; + if (OB_TMP_FAIL(refresh_location_cache(receiver_ls_id_))) { TRANS_LOG(WARN, "refresh location cache error", KR(ret), K_(trans_id), "ls", receiver_ls_id_, K(result), K(dst), K(status), K_(msg_type)); } else if (REACH_TIME_INTERVAL(LOG_INTERVAL_US)) { diff --git a/src/storage/tx/ob_trans_service_v4.cpp b/src/storage/tx/ob_trans_service_v4.cpp index 2c84231ad8..cbbf1381e8 100644 --- a/src/storage/tx/ob_trans_service_v4.cpp +++ b/src/storage/tx/ob_trans_service_v4.cpp @@ -984,7 +984,10 @@ int ObTransService::get_read_store_ctx(const ObTxReadSnapshot &snapshot, { int ret = OB_SUCCESS; ObLSID ls_id = store_ctx.ls_id_; - if (!ls_id.is_valid() || !snapshot.valid_) { + if (OB_UNLIKELY(store_ctx.timeout_ < 0)) { + ret = OB_INVALID_ARGUMENT; + TRANS_LOG(WARN, "store_ctx.timeout_ is invalid", K(ret), K(store_ctx), K(lbt())); + } else if (OB_UNLIKELY(!ls_id.is_valid() || !snapshot.valid_)) { ret = OB_INVALID_ARGUMENT; TRANS_LOG(WARN, "invalid ls_id or invalid snapshot store_ctx", K(ret), K(snapshot), K(store_ctx), K(lbt())); } else if (snapshot.is_special()) { @@ -1128,9 +1131,12 @@ int ObTransService::get_write_store_ctx(ObTxDesc &tx, } else if (tx.access_mode_ == ObTxAccessMode::STANDBY_RD_ONLY) { ret = OB_STANDBY_READ_ONLY; TRANS_LOG(WARN, "tx is standby readonly", K(ret), K(ls_id), K(tx), KPC(this)); - } else if (!snapshot.valid_) { + } else if (OB_UNLIKELY(!snapshot.valid_)) { ret = OB_INVALID_ARGUMENT; - TRANS_LOG(WARN, "snapshot invalid", K(ret), K(snapshot)); + TRANS_LOG(WARN, "snapshot invalid", K(ret), K(snapshot), K(lbt())); + } else if (OB_UNLIKELY(store_ctx.timeout_ < 0)) { + ret = OB_INVALID_ARGUMENT; + TRANS_LOG(WARN, "store_ctx.timeout_ is invalid", K(ret), K(store_ctx), K(lbt())); } else if (snapshot.is_none_read() && OB_FAIL(acquire_local_snapshot_(ls_id, snap.version_, diff --git a/src/storage/tx/ob_tx_big_segment_buf.cpp b/src/storage/tx/ob_tx_big_segment_buf.cpp index 34abcc43cf..f81e6bc5c5 100644 --- a/src/storage/tx/ob_tx_big_segment_buf.cpp +++ b/src/storage/tx/ob_tx_big_segment_buf.cpp @@ -200,7 +200,8 @@ int ObTxBigSegmentBuf::split_one_part(char *part_buf, TRANS_LOG(DEBUG, "init part header for split_one_part", K(ret), K(part_header), KPC(this)); tmp_pos = part_buf_pos; - if (OB_FAIL(part_header.serialize(part_buf, part_buf_len, tmp_pos))) { + if (OB_FAIL(ret)) { + } else if (OB_FAIL(part_header.serialize(part_buf, part_buf_len, tmp_pos))) { TRANS_LOG(WARN, "serialize part header failed", K(ret), KP(part_buf), K(part_buf_len), K(tmp_pos), KPC(this)); } else if (tmp_pos + part_header.part_length_ > part_buf_len diff --git a/src/storage/tx/ob_tx_log.cpp b/src/storage/tx/ob_tx_log.cpp index f10c00a37a..b03a360a90 100644 --- a/src/storage/tx/ob_tx_log.cpp +++ b/src/storage/tx/ob_tx_log.cpp @@ -813,7 +813,7 @@ int ObTxRedoLog::format_mutator_row_(const memtable::ObMemtableMutatorRow &row, // old row arg.writer_ptr_->dump_key("OldRow Cols"); arg.writer_ptr_->start_object(); - if (OB_FAIL(format_row_data_(old_row, arg))) { + if (OB_SUCC(ret) && OB_FAIL(format_row_data_(old_row, arg))) { TRANS_LOG(WARN, "format old_row failed", K(ret)); } arg.writer_ptr_->end_object(); diff --git a/src/storage/tx/ob_tx_ls_log_writer.cpp b/src/storage/tx/ob_tx_ls_log_writer.cpp index ebba071728..779dab4a0e 100644 --- a/src/storage/tx/ob_tx_ls_log_writer.cpp +++ b/src/storage/tx/ob_tx_ls_log_writer.cpp @@ -138,7 +138,7 @@ int ObTxLSLogCb::on_failure() if (OB_ISNULL(base_wr_)) { ret = OB_INVALID_ARGUMENT; TRANS_LOG(WARN, "[TxLsLogWriter] invalid arguments", KP(base_wr_)); - } else if (base_wr_->on_failure(this)) { + } else if (OB_FAIL(base_wr_->on_failure(this))) { TRANS_LOG(WARN, "[TxLsLogWriter] on_failure failed", KR(ret), K(log_ts_), K(type_)); } return ret; diff --git a/src/storage/tx/ob_tx_retain_ctx_mgr.cpp b/src/storage/tx/ob_tx_retain_ctx_mgr.cpp index be257976a5..37944ca9d5 100644 --- a/src/storage/tx/ob_tx_retain_ctx_mgr.cpp +++ b/src/storage/tx/ob_tx_retain_ctx_mgr.cpp @@ -52,7 +52,7 @@ int ObAdvanceLSCkptTask::try_advance_ls_ckpt_ts() ret = OB_INVALID_ARGUMENT; } TRANS_LOG(WARN, "get ls faild", K(ret), K(MTL(ObLSService *))); - } else if (ls_handle.get_ls()->advance_checkpoint_by_flush(target_ckpt_ts_)) { + } else if (OB_FAIL(ls_handle.get_ls()->advance_checkpoint_by_flush(target_ckpt_ts_))) { TRANS_LOG(WARN, "advance checkpoint ts failed", K(ret), K(ls_id_), K(target_ckpt_ts_)); } diff --git a/src/storage/tx/ob_xa_ctx.cpp b/src/storage/tx/ob_xa_ctx.cpp index edf3b4f159..b1e74b9982 100644 --- a/src/storage/tx/ob_xa_ctx.cpp +++ b/src/storage/tx/ob_xa_ctx.cpp @@ -2360,7 +2360,7 @@ int ObXACtx::set_exiting_() } tx_desc_ = NULL; } - if (OB_FAIL(xa_ctx_mgr_->erase_xa_ctx(trans_id_))) { + if (OB_SUCC(ret) && OB_FAIL(xa_ctx_mgr_->erase_xa_ctx(trans_id_))) { TRANS_LOG(WARN, "erase xa ctx failed", K(ret), K_(xid), K(*this)); } } diff --git a/src/storage/tx/ob_xa_rpc.cpp b/src/storage/tx/ob_xa_rpc.cpp index 8ad90a17dc..9f7bb833ba 100644 --- a/src/storage/tx/ob_xa_rpc.cpp +++ b/src/storage/tx/ob_xa_rpc.cpp @@ -290,7 +290,7 @@ int ObXAEndRPCRequest::init(const ObTransID &tx_id, (!ObXAFlag::is_valid(end_flag, ObXAReqType::XA_END))) { ret = OB_INVALID_ARGUMENT; TRANS_LOG(WARN, "invalid argument", KR(ret), K(tx_id), K(xid), K(end_flag)); - } else if (MTL(ObTransService *)->get_tx_stmt_info(tx_desc, stmt_info_)) { + } else if (OB_FAIL(MTL(ObTransService *)->get_tx_stmt_info(tx_desc, stmt_info_))) { TRANS_LOG(WARN, "get tx stmt info failed", KR(ret)); // } else if (OB_FAIL(trans_desc_.trans_deep_copy(trans_desc))) { // TRANS_LOG(WARN, "deep copy trans desc failed", KR(ret)); @@ -441,7 +441,7 @@ int ObXAStartStmtRPCResponse::init(const ObTransID &tx_id, if (!tx_id.is_valid() || !tx_desc.is_valid() || 0 > response_id) { ret = OB_INVALID_ARGUMENT; TRANS_LOG(WARN, "invalid argument", KR(ret), K(tx_id), K(response_id)); - } else if (MTL(ObTransService *)->get_tx_stmt_info(tx_desc, stmt_info_)) { + } else if (OB_FAIL(MTL(ObTransService *)->get_tx_stmt_info(tx_desc, stmt_info_))) { TRANS_LOG(WARN, "get tx stmt info failed", KR(ret)); } else { tx_id_ = tx_id; @@ -487,7 +487,7 @@ int ObXAEndStmtRPCRequest::init(const ObTransID &tx_id, if (!tx_id.is_valid() || !tx_desc.is_valid() || !xid.is_valid()) { ret = OB_INVALID_ARGUMENT; TRANS_LOG(WARN, "invalid argument", KR(ret), K(tx_id), K(xid)); - } else if (MTL(ObTransService *)->get_tx_stmt_info(tx_desc, stmt_info_)) { + } else if (OB_FAIL(MTL(ObTransService *)->get_tx_stmt_info(tx_desc, stmt_info_))) { TRANS_LOG(WARN, "get tx stmt info failed", KR(ret)); } else { tx_id_ = tx_id; diff --git a/src/storage/tx_table/ob_tx_data_table.cpp b/src/storage/tx_table/ob_tx_data_table.cpp index 30f3f74e66..3debcc6788 100644 --- a/src/storage/tx_table/ob_tx_data_table.cpp +++ b/src/storage/tx_table/ob_tx_data_table.cpp @@ -203,7 +203,7 @@ int ObTxDataTable::offline() if (IS_NOT_INIT) { ret = OB_NOT_INIT; STORAGE_LOG(WARN, "tx data table is not inited", KR(ret), KPC(this)); - } else if (get_memtable_mgr_()->offline()) { + } else if (OB_FAIL(get_memtable_mgr_()->offline()) && OB_NOT_INIT != ret) { STORAGE_LOG(WARN, "release memtables failed", KR(ret)); } else if (OB_FAIL(clean_memtables_cache_())) { STORAGE_LOG(WARN, "clean memtables cache failed", KR(ret), KPC(this)); diff --git a/src/storage/tx_table/ob_tx_table.cpp b/src/storage/tx_table/ob_tx_table.cpp index 5e7f357554..1ff4a0f032 100644 --- a/src/storage/tx_table/ob_tx_table.cpp +++ b/src/storage/tx_table/ob_tx_table.cpp @@ -446,8 +446,7 @@ int ObTxTable::remove_tablet() LOG_WARN("remove tx data tablet failed", K(ret)); ob_usleep(1000 * 1000); ob_abort(); - } - if (OB_FAIL(remove_tablet_(LS_TX_CTX_TABLET))) { + } else if (OB_FAIL(remove_tablet_(LS_TX_CTX_TABLET))) { LOG_WARN("remove tx ctx tablet failed", K(ret)); ob_usleep(1000 * 1000); ob_abort();