check commit_scn before writing ddl commit log
This commit is contained in:
		@ -2344,16 +2344,17 @@ int ObRpcRemoteWriteDDLCommitLogP::process()
 | 
			
		||||
      ObTabletHandle tablet_handle;
 | 
			
		||||
      if (OB_FAIL(data_tablet_mgr->wrlock(ObTabletDirectLoadMgr::TRY_LOCK_TIMEOUT, lock_tid))) {
 | 
			
		||||
        LOG_WARN("failed to wrlock", K(ret), K(arg_));
 | 
			
		||||
      } else if (OB_FAIL(ls->get_tablet(table_key.tablet_id_, tablet_handle, ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US, ObMDSGetTabletMode::READ_WITHOUT_CHECK))) {
 | 
			
		||||
        LOG_WARN("get tablet failed", K(ret), K(table_key));
 | 
			
		||||
      } else if (OB_FAIL(sstable_redo_writer.write_commit_log(false,
 | 
			
		||||
                                                              table_key,
 | 
			
		||||
                                                              arg_.start_scn_,
 | 
			
		||||
                                                              direct_load_mgr_handle,
 | 
			
		||||
                                                              tablet_handle,
 | 
			
		||||
                                                              commit_scn,
 | 
			
		||||
                                                              is_remote_write,
 | 
			
		||||
                                                              lock_tid))) {
 | 
			
		||||
        LOG_WARN("fail to remote write commit log", K(ret), K(table_key), K_(arg));
 | 
			
		||||
      } else if (OB_FAIL(ls->get_tablet(table_key.tablet_id_, tablet_handle, ObTabletCommon::DEFAULT_GET_TABLET_DURATION_US, ObMDSGetTabletMode::READ_WITHOUT_CHECK))) {
 | 
			
		||||
        LOG_WARN("get tablet failed", K(ret), K(table_key));
 | 
			
		||||
      } else if (OB_FAIL(data_tablet_mgr->commit(*tablet_handle.get_obj(),
 | 
			
		||||
                                                 arg_.start_scn_,
 | 
			
		||||
                                                 commit_scn,
 | 
			
		||||
 | 
			
		||||
@ -1228,6 +1228,7 @@ int ObDDLRedoLogWriter::write_commit_log(
 | 
			
		||||
    const ObITable::TableKey &table_key,
 | 
			
		||||
    const share::SCN &start_scn,
 | 
			
		||||
    ObTabletDirectLoadMgrHandle &direct_load_mgr_handle,
 | 
			
		||||
    ObTabletHandle &tablet_handle,
 | 
			
		||||
    SCN &commit_scn,
 | 
			
		||||
    bool &is_remote_write,
 | 
			
		||||
    uint32_t &lock_tid)
 | 
			
		||||
@ -1260,6 +1261,9 @@ int ObDDLRedoLogWriter::write_commit_log(
 | 
			
		||||
  } else if (start_scn != direct_load_mgr_handle.get_obj()->get_start_scn()) {
 | 
			
		||||
    ret = OB_TASK_EXPIRED;
 | 
			
		||||
    LOG_WARN("current task is restarted", K(ret), K(start_scn), "current_start_scn", direct_load_mgr_handle.get_obj()->get_start_scn());
 | 
			
		||||
  } else if (direct_load_mgr_handle.get_obj()->get_commit_scn(tablet_handle.get_obj()->get_tablet_meta()).is_valid_and_not_min()) {
 | 
			
		||||
    commit_scn = direct_load_mgr_handle.get_obj()->get_commit_scn(tablet_handle.get_obj()->get_tablet_meta());
 | 
			
		||||
    LOG_WARN("already committed", K(ret), K(start_scn), K(commit_scn), K(direct_load_mgr_handle.get_obj()->get_start_scn()), K(log));
 | 
			
		||||
  } else if (!remote_write_) {
 | 
			
		||||
    if (OB_FAIL(local_write_ddl_commit_log(
 | 
			
		||||
      log, ObDDLClogType::DDL_COMMIT_LOG, ls_id_, ls->get_log_handler(), direct_load_mgr_handle, handle, lock_tid))) {
 | 
			
		||||
 | 
			
		||||
@ -270,6 +270,7 @@ public:
 | 
			
		||||
      const ObITable::TableKey &table_key,
 | 
			
		||||
      const share::SCN &start_scn,
 | 
			
		||||
      ObTabletDirectLoadMgrHandle &direct_load_mgr_handle,
 | 
			
		||||
      ObTabletHandle &tablet_handle,
 | 
			
		||||
      share::SCN &commit_scn,
 | 
			
		||||
      bool &is_remote_write,
 | 
			
		||||
      uint32_t &lock_tid);
 | 
			
		||||
 | 
			
		||||
@ -2144,9 +2144,6 @@ int ObTabletFullDirectLoadMgr::close(const int64_t execution_id, const SCN &star
 | 
			
		||||
      // Why use is_task_end_ rather than commit_scn_.
 | 
			
		||||
      // sqc may switch to follower, and the commit_scn will not be set.
 | 
			
		||||
      LOG_INFO("had already closed", K(ret));
 | 
			
		||||
    } else if (get_commit_scn(tablet_handle.get_obj()->get_tablet_meta()).is_valid_and_not_min()) {
 | 
			
		||||
      commit_scn = get_commit_scn(tablet_handle.get_obj()->get_tablet_meta());
 | 
			
		||||
      FLOG_INFO("already committed", K(ret), K(commit_scn), "tablet_meta", tablet_handle.get_obj()->get_tablet_meta());
 | 
			
		||||
    } else if (OB_FAIL(redo_writer.init(ls_id_, tablet_id_))) {
 | 
			
		||||
      LOG_WARN("init redo writer failed", K(ret), K(ls_id_), K(tablet_id_));
 | 
			
		||||
    } else {
 | 
			
		||||
@ -2155,7 +2152,7 @@ int ObTabletFullDirectLoadMgr::close(const int64_t execution_id, const SCN &star
 | 
			
		||||
      if (OB_FAIL(direct_load_mgr_handle.set_obj(this))) {
 | 
			
		||||
        LOG_WARN("set direct load mgr handle failed", K(ret));
 | 
			
		||||
      } else if (OB_FAIL(redo_writer.write_commit_log(true, table_key_,
 | 
			
		||||
          start_scn, direct_load_mgr_handle, commit_scn, is_remote_write, lock_tid))) {
 | 
			
		||||
          start_scn, direct_load_mgr_handle, tablet_handle, commit_scn, is_remote_write, lock_tid))) {
 | 
			
		||||
        LOG_WARN("fail write ddl commit log", K(ret), K(table_key_), K(sqc_build_ctx_));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user