@@ -1492,16 +1492,10 @@ private static ObPartitionEntry getPartitionLocationFromResultSetByTablet(TableE
14921492 while (rs .next ()) {
14931493 if (ObGlobal .isSchemaVersionSupport ()) {
14941494 long curSchemaVersion = rs .getLong ("schema_version" );
1495- if (schemaVersion != curSchemaVersion ) {
1496- logger
1497- .warn (
1498- "getPartitionLocationFromResultSetByTablet schema_version does not match for table: {}, exist version: {}, new version: {}" ,
1499- tableEntry .getTableEntryKey ().getTableName (), schemaVersion ,
1500- curSchemaVersion );
1501- throw new ObTableSchemaVersionMismatchException (
1502- "Schema version mismatched, need to retry, tableName: { "
1503- + tableEntry .getTableEntryKey ().getTableName () + " }." );
1504- }
1495+ String errMsg = "getPartitionLocationFromResultSetByTablet schema_version does not match for table: " + tableEntry .getTableEntryKey ().getTableName ()
1496+ + ", exist version: " + schemaVersion
1497+ + ", new version: " + curSchemaVersion ;
1498+ checkSchemaVersionMatch (schemaVersion , curSchemaVersion , errMsg );
15051499 }
15061500 ReplicaLocation replica = buildReplicaLocation (rs );
15071501 long partitionId = rs .getLong ("tablet_id" );
@@ -1575,16 +1569,10 @@ private static ObPartitionEntry getPartitionLocationFromResultSet(TableEntry tab
15751569 while (rs .next ()) {
15761570 if (ObGlobal .isSchemaVersionSupport ()) {
15771571 long curSchemaVersion = rs .getLong ("schema_version" );
1578- if (schemaVersion != curSchemaVersion ) {
1579- logger
1580- .warn (
1581- "getPartitionLocationFromResultSet schema_version does not match for table: {}, exist version: {}, new version: {}" ,
1582- tableEntry .getTableEntryKey ().getTableName (), schemaVersion ,
1583- curSchemaVersion );
1584- throw new ObTableSchemaVersionMismatchException (
1585- "Schema version mismatched, need to retry, tableName: { "
1586- + tableEntry .getTableEntryKey ().getTableName () + " }." );
1587- }
1572+ String errMsg = "getPartitionLocationFromResultSet schema_version does not match for table: " + tableEntry .getTableEntryKey ().getTableName ()
1573+ + ", exist version: " + schemaVersion
1574+ + ", new version: " + curSchemaVersion ;
1575+ checkSchemaVersionMatch (schemaVersion , curSchemaVersion , errMsg );
15881576 }
15891577 ReplicaLocation replica = buildReplicaLocation (rs );
15901578 long partitionId ;
@@ -1728,16 +1716,10 @@ private static ObPartitionInfo parsePartitionInfo(ResultSet rs, TableEntry table
17281716 while (rs .next ()) {
17291717 if (ObGlobal .isSchemaVersionSupport ()) {
17301718 long curSchemaVersion = rs .getLong ("schema_version" );
1731- if (schemaVersion != curSchemaVersion ) {
1732- logger
1733- .warn (
1734- "parsePartitionInfo schema_version does not match for table: {}, exist version: {}, new version: {}" ,
1735- tableEntry .getTableEntryKey ().getTableName (), schemaVersion ,
1736- curSchemaVersion );
1737- throw new ObTableSchemaVersionMismatchException (
1738- "Schema version mismatched, need to retry, tableName: "
1739- + tableEntry .getTableEntryKey ().getTableName () + "." );
1740- }
1719+ String errMsg = "parsePartitionInfo schema_version does not match for table: " + tableEntry .getTableEntryKey ().getTableName ()
1720+ + ", exist version: " + schemaVersion
1721+ + ", new version: " + curSchemaVersion ;
1722+ checkSchemaVersionMatch (schemaVersion , curSchemaVersion , errMsg );
17411723 }
17421724 // get part info for the first loop
17431725 if (isFirstRow ) {
@@ -2002,16 +1984,11 @@ private static Map<Long, Long> parseKeyHashPart(ResultSet rs, TableEntry tableEn
20021984 while (rs .next ()) {
20031985 if (ObGlobal .isSchemaVersionSupport ()) {
20041986 long curSchemaVersion = rs .getLong ("schema_version" );
2005- if (schemaVersion != curSchemaVersion ) {
2006- logger
2007- .warn (
2008- "parseKeyHashPart schema_version does not match for table: {}, is sub part:{}, exist version: {}, new version: {}" ,
2009- tableEntry .getTableEntryKey ().getTableName (), isSubPart , schemaVersion ,
2010- curSchemaVersion );
2011- throw new ObTableSchemaVersionMismatchException (
2012- "Schema version mismatched, need to retry, tableName: { "
2013- + tableEntry .getTableEntryKey ().getTableName () + " }." );
2014- }
1987+ String errMsg = "parseKeyHashPart schema_version does not match for table: " + tableEntry .getTableEntryKey ().getTableName ()
1988+ + ", is sub part: " + isSubPart
1989+ + ", exist version: " + schemaVersion
1990+ + ", new version: " + curSchemaVersion ;
1991+ checkSchemaVersionMatch (schemaVersion , curSchemaVersion , errMsg );
20151992 }
20161993 ObPartDesc subPartDesc = tableEntry .getPartitionInfo ().getSubPartDesc ();
20171994 if (null != subPartDesc ) {
@@ -2068,16 +2045,11 @@ private static List<ObComparableKV<ObPartitionKey, Long>> parseRangePart(ResultS
20682045 while (rs .next ()) {
20692046 if (ObGlobal .isSchemaVersionSupport ()) {
20702047 long curSchemaVersion = rs .getLong ("schema_version" );
2071- if (schemaVersion != curSchemaVersion ) {
2072- logger
2073- .warn (
2074- "parseRangePart schema_version does not match for table: {}, is sub part: {}, exist version: {}, new version: {}" ,
2075- tableEntry .getTableEntryKey ().getTableName (), isSubPart , schemaVersion ,
2076- curSchemaVersion );
2077- throw new ObTableSchemaVersionMismatchException (
2078- "Schema version mismatched, need to retry, tableName: { "
2079- + tableEntry .getTableEntryKey ().getTableName () + " }." );
2080- }
2048+ String errMsg = "parseRangePart schema_version does not match for table: " + tableEntry .getTableEntryKey ().getTableName ()
2049+ + ", is sub part: " + isSubPart
2050+ + ", exist version: " + schemaVersion
2051+ + ", new version: " + curSchemaVersion ;
2052+ checkSchemaVersionMatch (schemaVersion , curSchemaVersion , errMsg );
20812053 }
20822054 if (null != subRangePartDesc && !isSubPart && subRangePartDesc .getPartNum () == 0 ) {
20832055 // client only support template partition table
@@ -2171,16 +2143,10 @@ private static Map<ObPartitionKey, Long> parseListPartSets(ResultSet rs, TableEn
21712143 while (rs .next ()) {
21722144 if (ObGlobal .isSchemaVersionSupport ()) {
21732145 long curSchemaVersion = rs .getLong ("schema_version" );
2174- if (schemaVersion != curSchemaVersion ) {
2175- logger
2176- .warn (
2177- "parseListPartSets schema_version does not match for table: {}, exist version: {}, new version: {}" ,
2178- tableEntry .getTableEntryKey ().getTableName (), schemaVersion ,
2179- curSchemaVersion );
2180- throw new ObTableSchemaVersionMismatchException (
2181- "Schema version mismatched, need to retry, tableName: { "
2182- + tableEntry .getTableEntryKey ().getTableName () + " }." );
2183- }
2146+ String errMsg = "parseListPartSets schema_version does not match for table: " + tableEntry .getTableEntryKey ().getTableName ()
2147+ + ", exist version: " + schemaVersion
2148+ + ", new version: " + curSchemaVersion ;
2149+ checkSchemaVersionMatch (schemaVersion , curSchemaVersion , errMsg );
21842150 }
21852151 String [] setArray = parseListPartSetsCommon (rs , tableEntry );
21862152 ObPartitionKey key = null ;
@@ -2209,6 +2175,13 @@ private static Map<ObPartitionKey, Long> parseListPartSets(ResultSet rs, TableEn
22092175 return sets ;
22102176 }
22112177
2178+ private static void checkSchemaVersionMatch (long expect , long actual , String errMsg ) throws ObTableSchemaVersionMismatchException {
2179+ if (expect != actual ) {
2180+ logger .warn (errMsg );
2181+ throw new ObTableSchemaVersionMismatchException (errMsg );
2182+ }
2183+ }
2184+
22122185 public static ConfigServerInfo loadRsListForConfigServerInfo (ConfigServerInfo configServer ,
22132186 String paramURL ,
22142187 String dataSourceName ,
0 commit comments