fix bk update report_scn & use cluster_version to compat
This commit is contained in:
		@ -209,8 +209,7 @@ int ObTabletMetaTableCompactionOperator::batch_update_unequal_report_scn_tablet(
 | 
			
		||||
    } else if (OB_FAIL(append_tablet_id_array(tenant_id, input_tablet_id_array, start_idx, end_idx, sql))) {
 | 
			
		||||
      LOG_WARN("fail to append tablet id array", KR(ret), K(tenant_id),
 | 
			
		||||
        K(input_tablet_id_array.count()), K(start_idx), K(end_idx));
 | 
			
		||||
    } else if (OB_FAIL(sql.append_fmt(") AND compaction_scn = '%lu' AND report_scn < '%lu'",
 | 
			
		||||
        major_frozen_scn, major_frozen_scn))) {
 | 
			
		||||
    } else if (OB_FAIL(sql.append_fmt(") AND report_scn < '%lu'", major_frozen_scn))) {
 | 
			
		||||
      LOG_WARN("failed to assign sql", K(ret), K(tenant_id), K(start_idx));
 | 
			
		||||
    } else {
 | 
			
		||||
      SMART_VAR(ObISQLClient::ReadResult, result) {
 | 
			
		||||
@ -303,21 +302,23 @@ int ObTabletMetaTableCompactionOperator::inner_batch_update_unequal_report_scn_t
 | 
			
		||||
  int64_t affected_rows = 0;
 | 
			
		||||
  const uint64_t meta_tenant_id = gen_meta_tenant_id(tenant_id);
 | 
			
		||||
  ObSqlString sql;
 | 
			
		||||
  if (OB_FAIL(sql.append_fmt("UPDATE %s SET report_scn='%lu' WHERE tenant_id='%lu' AND ls_id='%ld' AND tablet_id IN (",
 | 
			
		||||
      OB_ALL_TABLET_META_TABLE_TNAME,
 | 
			
		||||
      major_frozen_scn,
 | 
			
		||||
      tenant_id,
 | 
			
		||||
      ls_id.id()))) {
 | 
			
		||||
  if (OB_FAIL(sql.append_fmt(
 | 
			
		||||
          "UPDATE %s t1 SET report_scn=if(compaction_scn>'%lu' ,'%lu', compaction_scn) WHERE "
 | 
			
		||||
          "tenant_id='%lu' AND ls_id='%ld' AND tablet_id IN (",
 | 
			
		||||
          OB_ALL_TABLET_META_TABLE_TNAME, major_frozen_scn, major_frozen_scn,
 | 
			
		||||
          tenant_id, ls_id.id()))) {
 | 
			
		||||
    LOG_WARN("failed to append fmt", K(ret), K(tenant_id), K(ls_id));
 | 
			
		||||
  } else if (OB_FAIL(append_tablet_id_array(tenant_id, unequal_tablet_id_array, 0, unequal_tablet_id_array.count(), sql))) {
 | 
			
		||||
  } else if (OB_FAIL(append_tablet_id_array(tenant_id, unequal_tablet_id_array,
 | 
			
		||||
                                            0, unequal_tablet_id_array.count(),
 | 
			
		||||
                                            sql))) {
 | 
			
		||||
    LOG_WARN("fail to append tablet id array", KR(ret), K(tenant_id), K(unequal_tablet_id_array));
 | 
			
		||||
  } else if (OB_FAIL(sql.append_fmt(") AND compaction_scn >= '%lu' AND report_scn <'%lu'",
 | 
			
		||||
      major_frozen_scn, major_frozen_scn))) {
 | 
			
		||||
  } else if (OB_FAIL(sql.append_fmt(") AND report_scn <'%lu'", major_frozen_scn))) {
 | 
			
		||||
    LOG_WARN("failed to assign sql", K(ret), K(tenant_id), K(ls_id));
 | 
			
		||||
  } else if (OB_FAIL(GCTX.sql_proxy_->write(meta_tenant_id, sql.ptr(), affected_rows))) {
 | 
			
		||||
  } else if (OB_FAIL(GCTX.sql_proxy_->write(meta_tenant_id, sql.ptr(),
 | 
			
		||||
                                            affected_rows))) {
 | 
			
		||||
    LOG_WARN("fail to execute sql", KR(ret), K(tenant_id), K(meta_tenant_id), K(sql));
 | 
			
		||||
  } else if (affected_rows > 0) {
 | 
			
		||||
    LOG_INFO("success to update unequal report_scn", K(ret), K(tenant_id), K(ls_id), K(unequal_tablet_id_array.count()));
 | 
			
		||||
    LOG_INFO("success to update unequal report_scn", K(ret), K(sql), K(tenant_id), K(ls_id), K(unequal_tablet_id_array.count()));
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
@ -360,7 +361,7 @@ int ObTabletMetaTableCompactionOperator::batch_update_report_scn(
 | 
			
		||||
  } else if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, compat_version))) {
 | 
			
		||||
    LOG_WARN("fail to get data version", KR(ret), K(tenant_id));
 | 
			
		||||
  } else if (compat_version < DATA_VERSION_4_1_0_0) {
 | 
			
		||||
    // do nothing
 | 
			
		||||
    // do nothing until schema upgrade
 | 
			
		||||
  } else {
 | 
			
		||||
    ObMySQLTransaction trans;
 | 
			
		||||
    int64_t affected_rows = 0;
 | 
			
		||||
@ -409,7 +410,7 @@ int ObTabletMetaTableCompactionOperator::batch_update_status(
 | 
			
		||||
  } else if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, compat_version))) {
 | 
			
		||||
    LOG_WARN("fail to get data version", KR(ret), K(tenant_id));
 | 
			
		||||
  } else if (compat_version < DATA_VERSION_4_1_0_0) {
 | 
			
		||||
    // do nothing
 | 
			
		||||
    // do nothing until schema upgrade
 | 
			
		||||
  } else {
 | 
			
		||||
    ObMySQLTransaction trans;
 | 
			
		||||
    int64_t affected_rows = 0;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user