[4.0] dec unsubmitted cnt that is added in prepare of multi-transaction for replay when transaction abort
This commit is contained in:
		@ -620,7 +620,7 @@ int ObTablet::set_multi_data_for_commit(
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
 | 
			
		||||
  bool is_callback = true;
 | 
			
		||||
  TRANS_LOG(INFO, "set_multi_data_for_commit", K(multi_source_data_unit));
 | 
			
		||||
  TRANS_LOG(INFO, "set_multi_data_for_commit", K(multi_source_data_unit), K(ref_op));
 | 
			
		||||
  if (IS_NOT_INIT) {
 | 
			
		||||
    ret = OB_NOT_INIT;
 | 
			
		||||
    TRANS_LOG(WARN, "not inited", K(ret), K_(is_inited));
 | 
			
		||||
 | 
			
		||||
@ -1003,6 +1003,21 @@ int ObTabletBindingHelper::set_log_ts(const ObIArray<ObTabletID> &tablet_ids) co
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObTabletBindingHelper::check_need_dec_cnt_for_abort(const ObTabletTxMultiSourceDataUnit &tx_data, bool &need_dec)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  const int cnt = tx_data.get_unsync_cnt_for_multi_data(); 
 | 
			
		||||
  need_dec = false;
 | 
			
		||||
  if ((tx_data.is_tx_end() && cnt == 2) || (!tx_data.is_tx_end() && cnt == 1)) {
 | 
			
		||||
    need_dec = true;
 | 
			
		||||
  } else if ((tx_data.is_tx_end() && cnt == 1) || (!tx_data.is_tx_end() && cnt == 0)) {
 | 
			
		||||
  } else {
 | 
			
		||||
    ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
    LOG_WARN("invalid cnt", K(ret), K(tx_data));
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// for commit or abort, reentrant for replay
 | 
			
		||||
int ObTabletBindingHelper::unlock_tablet_binding(ObTabletHandle &handle, const ObMulSourceDataNotifyArg &trans_flags)
 | 
			
		||||
{
 | 
			
		||||
@ -1034,8 +1049,12 @@ int ObTabletBindingHelper::unlock_tablet_binding(ObTabletHandle &handle, const O
 | 
			
		||||
        tx_data.tx_id_ = ObTabletCommon::FINAL_TX_ID;
 | 
			
		||||
        tx_data.tx_log_ts_ = abort_without_redo ? old_log_ts : log_ts;
 | 
			
		||||
        const int64_t memtable_log_ts = (OB_INVALID_TIMESTAMP == log_ts) ? ObLogTsRange::MAX_TS: log_ts;
 | 
			
		||||
        MemtableRefOp ref_op = (abort_without_redo ? MemtableRefOp::DEC_REF : MemtableRefOp::NONE);
 | 
			
		||||
        if (OB_FAIL(tablet->set_tablet_final_status(tx_data, memtable_log_ts, for_replay, ref_op))) {
 | 
			
		||||
        bool need_dec = false;
 | 
			
		||||
        MemtableRefOp ref_op = MemtableRefOp::NONE;
 | 
			
		||||
        if (OB_FAIL(check_need_dec_cnt_for_abort(tx_data, need_dec))) {
 | 
			
		||||
          LOG_WARN("failed to save tx data", K(ret), K(tx_data), K(log_ts), K(for_replay));
 | 
			
		||||
        } else if (FALSE_IT(ref_op = (need_dec ? MemtableRefOp::DEC_REF : MemtableRefOp::NONE))) {
 | 
			
		||||
        } else if (OB_FAIL(tablet->set_tablet_final_status(tx_data, memtable_log_ts, for_replay, ref_op))) {
 | 
			
		||||
          LOG_WARN("failed to save tx data", K(ret), K(tx_data), K(log_ts), K(for_replay), K(ref_op));
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@ -155,6 +155,7 @@ public:
 | 
			
		||||
 | 
			
		||||
  // common
 | 
			
		||||
  static bool has_lob_tablets(const obrpc::ObBatchCreateTabletArg &arg, const obrpc::ObCreateTabletInfo &info);
 | 
			
		||||
  static int check_need_dec_cnt_for_abort(const ObTabletTxMultiSourceDataUnit &tx_data, bool &need_dec);
 | 
			
		||||
  static int lock_and_set_tx_data(ObTabletHandle &handle, ObTabletTxMultiSourceDataUnit &tx_data, const bool for_replay);
 | 
			
		||||
  static int lock_tablet_binding(ObTabletHandle &handle, const transaction::ObMulSourceDataNotifyArg &trans_flags);
 | 
			
		||||
  static int set_log_ts(ObTabletHandle &handle, const transaction::ObMulSourceDataNotifyArg &trans_flags);
 | 
			
		||||
 | 
			
		||||
@ -849,12 +849,11 @@ int ObTabletCreateDeleteHelper::roll_back_remove_tablet(
 | 
			
		||||
    } else {
 | 
			
		||||
      LOG_WARN("failed to get tablet", K(ret), K(ls_id), K(tablet_id));
 | 
			
		||||
    }
 | 
			
		||||
  } else if (trans_flags.for_replay_) {
 | 
			
		||||
    // for replay, no need to dec ref for memtable
 | 
			
		||||
  } else {
 | 
			
		||||
    ObTablet *tablet = tablet_handle.get_obj();
 | 
			
		||||
    ObTabletMemtableMgr *memtable_mgr = static_cast<ObTabletMemtableMgr*>(tablet->get_memtable_mgr());
 | 
			
		||||
    ObSEArray<ObTableHandleV2, MAX_MEMSTORE_CNT> memtable_handle_array;
 | 
			
		||||
    bool need_dec = false;
 | 
			
		||||
    if (OB_FAIL(memtable_mgr->get_all_memtables(memtable_handle_array))) {
 | 
			
		||||
      LOG_WARN("failed to get all memtables", K(ret), K(ls_id), K(tablet_id));
 | 
			
		||||
    } else if (memtable_handle_array.empty()) {
 | 
			
		||||
@ -874,7 +873,9 @@ int ObTabletCreateDeleteHelper::roll_back_remove_tablet(
 | 
			
		||||
        LOG_INFO("last memtable does not have msd, do nothing", K(ret), K(ls_id), K(tablet_id), K(cnt));
 | 
			
		||||
      } else if (OB_FAIL(tablet->get_tx_data(tx_data))) {
 | 
			
		||||
        LOG_WARN("failed to get tx data", K(ret), K(ls_id), K(tablet_id), K(cnt));
 | 
			
		||||
      } else if (OB_FAIL(tablet->save_multi_source_data_unit(&tx_data, ObLogTsRange::MAX_TS,
 | 
			
		||||
      } else if (OB_FAIL(ObTabletBindingHelper::check_need_dec_cnt_for_abort(tx_data, need_dec))) {
 | 
			
		||||
        LOG_WARN("failed to save tx data", K(ret), K(tx_data), K(trans_flags));
 | 
			
		||||
      } else if (need_dec && OB_FAIL(tablet->save_multi_source_data_unit(&tx_data, ObLogTsRange::MAX_TS,
 | 
			
		||||
          trans_flags.for_replay_, MemtableRefOp::DEC_REF, true/*is_callback*/))) {
 | 
			
		||||
        LOG_WARN("failed to save msd", K(ret), K(ls_id), K(tablet_id), K(cnt));
 | 
			
		||||
      } else {
 | 
			
		||||
@ -1255,11 +1256,10 @@ int ObTabletCreateDeleteHelper::do_abort_remove_tablet(
 | 
			
		||||
    is_valid = false;
 | 
			
		||||
    LOG_INFO("tablet status is not DELETING", K(ret), K(key), K(trans_flags), K(tx_data));
 | 
			
		||||
  } else {
 | 
			
		||||
    if (trans_flags.for_replay_) {
 | 
			
		||||
    } else if (trans_flags.is_redo_synced()) {
 | 
			
		||||
      // on redo cb has been called
 | 
			
		||||
      // do nothing(on redo cb has already done DEC_REF)
 | 
			
		||||
    } else {
 | 
			
		||||
    bool need_dec = false;
 | 
			
		||||
    if (OB_FAIL(ObTabletBindingHelper::check_need_dec_cnt_for_abort(tx_data, need_dec))) {
 | 
			
		||||
      LOG_WARN("failed to save tx data", K(ret), K(tx_data), K(trans_flags));
 | 
			
		||||
    } else if (need_dec) {
 | 
			
		||||
      ref_op = MemtableRefOp::DEC_REF;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user