[4.1] tablet gc and tablet persist disassociation
This commit is contained in:
		@ -1175,42 +1175,52 @@ int ObLS::replay_get_tablet(const common::ObTabletID &tablet_id,
 | 
			
		||||
                            ObTabletHandle &handle) const
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  int tmp_ret = OB_SUCCESS;
 | 
			
		||||
  const ObTabletMapKey key(ls_meta_.ls_id_, tablet_id);
 | 
			
		||||
  const SCN tablet_change_checkpoint_scn = ls_meta_.get_tablet_change_checkpoint_scn();
 | 
			
		||||
  ObTabletHandle tablet_handle;
 | 
			
		||||
  SCN min_scn;
 | 
			
		||||
 | 
			
		||||
  if (IS_NOT_INIT) {
 | 
			
		||||
    ret = OB_NOT_INIT;
 | 
			
		||||
    LOG_WARN("ls is not inited", K(ret));
 | 
			
		||||
    LOG_WARN("ls is not inited", KR(ret));
 | 
			
		||||
  } else if (OB_UNLIKELY(!tablet_id.is_valid() || !scn.is_valid())) {
 | 
			
		||||
    ret = OB_INVALID_ARGUMENT;
 | 
			
		||||
    LOG_WARN("invalid args", K(ret), K(tablet_id), K(scn));
 | 
			
		||||
    LOG_WARN("invalid args", KR(ret), K(tablet_id), K(scn));
 | 
			
		||||
  } else if (OB_FAIL(ObTabletCreateDeleteHelper::get_tablet(key, tablet_handle))) {
 | 
			
		||||
    if (OB_TABLET_NOT_EXIST != ret) {
 | 
			
		||||
      LOG_WARN("failed to get tablet", K(ret), K(key));
 | 
			
		||||
    } else if (scn <= tablet_change_checkpoint_scn) {
 | 
			
		||||
      LOG_WARN("tablet already deleted", K(ret), K(key), K(scn), K(tablet_change_checkpoint_scn));
 | 
			
		||||
    } else {
 | 
			
		||||
      LOG_WARN("tablet already gc", K(ret), K(key), K(scn), K(tablet_change_checkpoint_scn));
 | 
			
		||||
    } else if (OB_TMP_FAIL(MTL(ObLogService*)->get_log_replay_service()->get_min_unreplayed_scn(ls_meta_.ls_id_, min_scn))) {
 | 
			
		||||
      ret = tmp_ret;
 | 
			
		||||
      LOG_WARN("failed to get_min_unreplayed_scn", KR(ret), K_(ls_meta), K(scn), K(tablet_id));
 | 
			
		||||
    } else if (!min_scn.is_valid()) {
 | 
			
		||||
      ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
      LOG_WARN("min_scn is invalid", KR(ret), K(key), K(scn), K(tablet_change_checkpoint_scn));
 | 
			
		||||
    } else if (scn > min_scn) {
 | 
			
		||||
      ret = OB_EAGAIN;
 | 
			
		||||
      LOG_INFO("tablet does not exist, but need retry", K(ret), K(key), K(scn), K(tablet_change_checkpoint_scn));
 | 
			
		||||
      LOG_INFO("tablet does not exist, but need retry", KR(ret), K(key), K(scn), K(tablet_change_checkpoint_scn), K(min_scn));
 | 
			
		||||
    } else {
 | 
			
		||||
      LOG_INFO("tablet already gc, but scn is more than min scn", KR(ret), K(key), K(scn), K(tablet_change_checkpoint_scn), K(min_scn));
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    ObTabletTxMultiSourceDataUnit tx_data;
 | 
			
		||||
    if (OB_FAIL(tablet_handle.get_obj()->get_tx_data(tx_data))) {
 | 
			
		||||
      LOG_WARN("failed to get tablet tx data", K(ret), K(tablet_handle));
 | 
			
		||||
      LOG_WARN("failed to get tablet tx data", KR(ret), K(tablet_handle));
 | 
			
		||||
    } else if (ObTabletStatus::CREATING == tx_data.tablet_status_) {
 | 
			
		||||
      ret = OB_EAGAIN;
 | 
			
		||||
      LOG_INFO("tablet is CREATING, need retry", K(ret), K(key), K(tx_data), K(scn));
 | 
			
		||||
      LOG_INFO("tablet is CREATING, need retry", KR(ret), K(key), K(tx_data), K(scn));
 | 
			
		||||
    } else if (ObTabletStatus::NORMAL == tx_data.tablet_status_) {
 | 
			
		||||
      // do nothing
 | 
			
		||||
    } else if (ObTabletStatus::DELETING == tx_data.tablet_status_) {
 | 
			
		||||
      LOG_INFO("tablet is DELETING, just continue", K(ret), K(key), K(tx_data), K(scn));
 | 
			
		||||
      LOG_INFO("tablet is DELETING, just continue", KR(ret), K(key), K(tx_data), K(scn));
 | 
			
		||||
    } else if (ObTabletStatus::DELETED == tx_data.tablet_status_) {
 | 
			
		||||
      ret = OB_TABLET_NOT_EXIST;
 | 
			
		||||
      LOG_INFO("tablet is already deleted", K(ret), K(key), K(tx_data), K(scn));
 | 
			
		||||
      LOG_INFO("tablet is already deleted", KR(ret), K(key), K(tx_data), K(scn));
 | 
			
		||||
    } else {
 | 
			
		||||
      ret = OB_EAGAIN;
 | 
			
		||||
      LOG_INFO("tablet may be in creating procedure", K(ret), K(key), K(tx_data), K(scn));
 | 
			
		||||
      LOG_INFO("tablet may be in creating procedure", KR(ret), K(key), K(tx_data), K(scn));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -779,20 +779,20 @@ int ObTabletBindingHelper::replay_get_tablet(const ObTabletMapKey &key, ObTablet
 | 
			
		||||
 | 
			
		||||
  if (OB_FAIL(ObTabletCreateDeleteHelper::get_tablet(key, tablet_handle))) {
 | 
			
		||||
    if (OB_TABLET_NOT_EXIST != ret) {
 | 
			
		||||
      LOG_WARN("failed to get tablet", K(ret), K(key));
 | 
			
		||||
      LOG_WARN("failed to get tablet", KR(ret), K(key));
 | 
			
		||||
    } else if (trans_flags_.scn_ <= tablet_change_checkpoint_scn) {
 | 
			
		||||
      LOG_WARN("tablet already deleted", K(ret), K(key), K(trans_flags_), K(tablet_change_checkpoint_scn));
 | 
			
		||||
      LOG_WARN("tablet already gc", KR(ret), K(key), K(trans_flags_), K(tablet_change_checkpoint_scn));
 | 
			
		||||
    } else {
 | 
			
		||||
      ret = OB_EAGAIN;
 | 
			
		||||
      LOG_INFO("tablet does not exist, but need retry", K(ret), K(key), K(trans_flags_));
 | 
			
		||||
      LOG_INFO("tablet already gc, trans_flags_.scn_ is not less than tablet_change_checkpoint_scn",
 | 
			
		||||
               KR(ret), K(key), K(trans_flags_), K(tablet_change_checkpoint_scn));
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    ObTabletTxMultiSourceDataUnit tx_data;
 | 
			
		||||
    if (OB_FAIL(tablet_handle.get_obj()->get_tx_data(tx_data))) {
 | 
			
		||||
      LOG_WARN("failed to get tablet tx data", K(ret), K(tablet_handle));
 | 
			
		||||
      LOG_WARN("failed to get tablet tx data", KR(ret), K(tablet_handle));
 | 
			
		||||
    } else if (ObTabletStatus::DELETED == tx_data.tablet_status_) {
 | 
			
		||||
      ret = OB_TABLET_NOT_EXIST;
 | 
			
		||||
      LOG_INFO("tablet is already deleted", K(ret), K(key), K(tx_data));
 | 
			
		||||
      LOG_INFO("tablet is already deleted", KR(ret), K(key), K(tx_data));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -159,35 +159,34 @@ void ObTabletGCService::ObTabletGCTask::runTimerTask()
 | 
			
		||||
            STORAGE_LOG(INFO, "no any log callback and no need to update clog checkpoint",
 | 
			
		||||
              K(freezer->get_ls_id()), K(checkpoint_scn), KPC(ls), K(ls->get_ls_meta()));
 | 
			
		||||
          }
 | 
			
		||||
          // 2. get gc tablet
 | 
			
		||||
          else if ((times == 0 || ObTabletGCHandler::is_tablet_gc_trigger(tablet_persist_trigger))
 | 
			
		||||
                   && OB_FAIL(tablet_gc_handler->get_unpersist_tablet_ids(deleted_tablet_ids, checkpoint_scn, only_deleted))) {
 | 
			
		||||
          // 2. get gc tablet. persist tablet must gc tablet
 | 
			
		||||
          else if (OB_FAIL(tablet_gc_handler->get_unpersist_tablet_ids(deleted_tablet_ids, only_deleted))) {
 | 
			
		||||
            need_retry = true;
 | 
			
		||||
            STORAGE_LOG(WARN, "failed to get_unpersist_tablet_ids", KPC(ls), KR(ret));
 | 
			
		||||
          }
 | 
			
		||||
          // 3. get unpersist_tablet_ids
 | 
			
		||||
          else if (OB_FAIL(tablet_gc_handler->get_unpersist_tablet_ids(unpersist_tablet_ids, checkpoint_scn, !only_deleted))) {
 | 
			
		||||
          // 3. check and gc deleted_tablet_ids. tablet_change_ts cannot update when gc tablet failed.
 | 
			
		||||
          else if (!deleted_tablet_ids.empty() && OB_FAIL(tablet_gc_handler->gc_tablets(deleted_tablet_ids))) {
 | 
			
		||||
            need_retry = true;
 | 
			
		||||
            STORAGE_LOG(WARN, "failed to gc tablet", KR(ret), K(deleted_tablet_ids));
 | 
			
		||||
          }
 | 
			
		||||
          // 4. get unpersist_tablet_ids
 | 
			
		||||
          else if ((times == 0 || ObTabletGCHandler::is_set_tablet_persist_trigger(tablet_persist_trigger))
 | 
			
		||||
                   && OB_FAIL(tablet_gc_handler->get_unpersist_tablet_ids(unpersist_tablet_ids, !only_deleted))) {
 | 
			
		||||
            need_retry = true;
 | 
			
		||||
            STORAGE_LOG(WARN, "failed to get_unpersist_tablet_ids", KPC(ls), KR(ret));
 | 
			
		||||
          }
 | 
			
		||||
          // 4. flush unpersit_tablet_ids
 | 
			
		||||
          else if (OB_FAIL(tablet_gc_handler->flush_unpersist_tablet_ids(unpersist_tablet_ids, checkpoint_scn))) {
 | 
			
		||||
          // 5. flush unpersit_tablet_ids
 | 
			
		||||
          else if ((times == 0 || ObTabletGCHandler::is_set_tablet_persist_trigger(tablet_persist_trigger))
 | 
			
		||||
                   && OB_FAIL(tablet_gc_handler->flush_unpersist_tablet_ids(unpersist_tablet_ids, checkpoint_scn))) {
 | 
			
		||||
            need_retry = true;
 | 
			
		||||
            STORAGE_LOG(WARN, "failed to flush_unpersist_tablet_ids", KPC(ls), KR(ret), K(unpersist_tablet_ids));
 | 
			
		||||
          }
 | 
			
		||||
          // 5. update tablet_change_checkpoint in log meta
 | 
			
		||||
          else if (OB_FAIL(ls->set_tablet_change_checkpoint_scn(checkpoint_scn))) {
 | 
			
		||||
          // 6. update tablet_change_checkpoint in log meta
 | 
			
		||||
          else if ((times == 0 || ObTabletGCHandler::is_set_tablet_persist_trigger(tablet_persist_trigger))
 | 
			
		||||
                   && OB_FAIL(ls->set_tablet_change_checkpoint_scn(checkpoint_scn))) {
 | 
			
		||||
            need_retry = true;
 | 
			
		||||
            STORAGE_LOG(WARN, "failed to set_tablet_change_checkpoint_scn", KPC(ls), KR(ret), K(checkpoint_scn));
 | 
			
		||||
          }
 | 
			
		||||
          // 6. check and gc deleted_tablet_ids
 | 
			
		||||
          else if (times == 0 || ObTabletGCHandler::is_tablet_gc_trigger(tablet_persist_trigger)) {
 | 
			
		||||
            // to do check gc and gc tablets
 | 
			
		||||
            if (!deleted_tablet_ids.empty() && OB_FAIL(tablet_gc_handler->gc_tablets(deleted_tablet_ids))) {
 | 
			
		||||
              need_retry = true;
 | 
			
		||||
              STORAGE_LOG(WARN, "failed to gc tablet", KR(ret), K(deleted_tablet_ids));
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
          STORAGE_LOG(INFO, "[tabletgc] tablet in a ls persist and gc process end", KR(ret), KPC(ls), K(checkpoint_scn), K(deleted_tablet_ids), K(unpersist_tablet_ids));
 | 
			
		||||
          if (need_retry) {
 | 
			
		||||
            STORAGE_LOG(INFO, "[tabletgc] persist or gc error, need try", KR(ret), KPC(ls), K(checkpoint_scn), K(tablet_persist_trigger));
 | 
			
		||||
@ -268,7 +267,6 @@ uint8_t ObTabletGCHandler::get_tablet_persist_trigger_and_reset()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObTabletGCHandler::get_unpersist_tablet_ids(common::ObTabletIDArray &unpersist_tablet_ids,
 | 
			
		||||
                                                const SCN checkpoint_scn,
 | 
			
		||||
                                                bool only_deleted /* = false */)
 | 
			
		||||
{
 | 
			
		||||
  int64_t ret = OB_SUCCESS;
 | 
			
		||||
@ -305,15 +303,14 @@ int ObTabletGCHandler::get_unpersist_tablet_ids(common::ObTabletIDArray &unpersi
 | 
			
		||||
        if (OB_FAIL(tablet_handle.get_obj()->get_tx_data(tx_data))) {
 | 
			
		||||
          LOG_WARN("failed to get tx data", K(ret), K(tablet_id));
 | 
			
		||||
        } else if (only_deleted) {
 | 
			
		||||
          if (ObTabletStatus::DELETED == tx_data.tablet_status_
 | 
			
		||||
              && tx_data.tx_scn_ <= checkpoint_scn) {
 | 
			
		||||
            STORAGE_LOG(INFO, "[tabletgc] get tx_data for gc", K(tx_data), K(tablet_meta), K(checkpoint_scn));
 | 
			
		||||
          if (ObTabletStatus::DELETED == tx_data.tablet_status_) {
 | 
			
		||||
            STORAGE_LOG(INFO, "[tabletgc] get tx_data for gc", K(tx_data), K(tablet_meta));
 | 
			
		||||
            if (OB_FAIL(unpersist_tablet_ids.push_back(tablet_id))) {
 | 
			
		||||
              STORAGE_LOG(WARN, "failed to push_back deleted tablet", KR(ret));
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        } else if (tx_data.tx_scn_ > tablet_meta.clog_checkpoint_scn_) {
 | 
			
		||||
          STORAGE_LOG(INFO, "[tabletgc] get tx_data for persist", K(tx_data), K(tablet_meta), K(checkpoint_scn));
 | 
			
		||||
          STORAGE_LOG(INFO, "[tabletgc] get tx_data for persist", K(tx_data), K(tablet_meta));
 | 
			
		||||
          if (OB_FAIL(unpersist_tablet_ids.push_back(tablet_id))) {
 | 
			
		||||
            STORAGE_LOG(WARN, "failed to push_back", KR(ret));
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
@ -53,7 +53,6 @@ public:
 | 
			
		||||
  void set_tablet_gc_trigger();
 | 
			
		||||
  uint8_t get_tablet_persist_trigger_and_reset();
 | 
			
		||||
  int get_unpersist_tablet_ids(common::ObTabletIDArray &unpersist_create_tablet_ids,
 | 
			
		||||
                               const share::SCN checkpoint_scn,
 | 
			
		||||
                               bool only_deleted = false);
 | 
			
		||||
  int flush_unpersist_tablet_ids(const common::ObTabletIDArray &unpersist_tablet_ids,
 | 
			
		||||
                                 const share::SCN checkpoint_scn);
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user