From 72060316df930961bee4f9701e8e66d606d60a06 Mon Sep 17 00:00:00 2001 From: JackShi148 Date: Thu, 8 May 2025 11:54:45 +0800 Subject: [PATCH] fix odp mode fail to force refresh partition meta --- .../rpc/location/model/TableLocations.java | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/alipay/oceanbase/rpc/location/model/TableLocations.java b/src/main/java/com/alipay/oceanbase/rpc/location/model/TableLocations.java index 0a699bd0..1990a4f2 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/location/model/TableLocations.java +++ b/src/main/java/com/alipay/oceanbase/rpc/location/model/TableLocations.java @@ -134,12 +134,12 @@ public TableEntry refreshMeta(String tableName, ServerRoster serverRoster, try { if (!acquired) { acquired = lock.tryLock(tableEntryRefreshLockTimeout, TimeUnit.MILLISECONDS); - } - if (!acquired) { - String errMsg = "try to lock tableEntry refreshing timeout, tableName:" + tableName - + " , timeout:" + tableEntryRefreshLockTimeout + "."; - RUNTIME.warn(errMsg); - throw new ObTableTryLockTimeoutException(errMsg); + if (!acquired) { + String errMsg = "try to lock tableEntry refreshing timeout, tableName:" + tableName + + " , timeout:" + tableEntryRefreshLockTimeout + "."; + RUNTIME.warn(errMsg); + throw new ObTableTryLockTimeoutException(errMsg); + } } logger.debug("success to acquire refresh table meta lock, tableName: {}", tableName); tableEntry = locations.get(tableName); @@ -316,12 +316,12 @@ public TableEntry refreshPartitionLocation(TableEntry tableEntry, String tableNa try { if (!acquired) { acquired = lock.tryLock(tableEntryRefreshLockTimeout, TimeUnit.MILLISECONDS); - } - if (!acquired) { - String errMsg = "try to lock tablet location refreshing timeout " + " ,tableName:" - + tableName + " , timeout:" + tableEntryRefreshLockTimeout + "."; - RUNTIME.warn(errMsg); - throw new ObTableTryLockTimeoutException(errMsg); + if (!acquired) { + String errMsg = "try to lock tablet location refreshing timeout " + " ,tableName:" + + tableName + " , timeout:" + tableEntryRefreshLockTimeout + "."; + RUNTIME.warn(errMsg); + throw new ObTableTryLockTimeoutException(errMsg); + } } logger.debug("success acquire refresh table location lock, tableName: {}", tableName); locationInfo = tableEntry.getPartitionEntry().getPartitionInfo(tabletId); @@ -443,12 +443,12 @@ public TableEntry refreshTabletLocationBatch(TableEntry tableEntry, String table try { if (!acquired) { acquired = lock.tryLock(tableEntryRefreshLockTimeout, TimeUnit.MILLISECONDS); - } - if (!acquired) { - String errMsg = "try to lock locations refreshing in batch timeout " + " ,tableName:" - + tableName + " , timeout:" + tableEntryRefreshLockTimeout + "."; - RUNTIME.warn(errMsg); - throw new ObTableTryLockTimeoutException(errMsg); + if (!acquired) { + String errMsg = "try to lock locations refreshing in batch timeout " + " ,tableName:" + + tableName + " , timeout:" + tableEntryRefreshLockTimeout + "."; + RUNTIME.warn(errMsg); + throw new ObTableTryLockTimeoutException(errMsg); + } } logger.debug("success to acquire refresh tablet locations in batch lock, tableName: {}", tableName); lastRefreshTime = tableEntry.getPartitionEntry().getLastRefreshAllTime(); @@ -579,14 +579,16 @@ public TableEntry refreshODPMeta(String tableName, boolean forceRefresh, ObTable try { // attempt lock the refreshing action, avoiding concurrent refreshing // use the time-out mechanism, avoiding the rpc hanging up - acquired = lock.tryLock(tableClient.getODPTableEntryRefreshLockTimeout(), - TimeUnit.MILLISECONDS); if (!acquired) { - String errMsg = "try to lock odpTable-entry refreshing timeout " + " ,tableName:" - + tableName + " , timeout:" - + tableClient.getODPTableEntryRefreshLockTimeout() + "."; - RUNTIME.warn(errMsg); - throw new ObTableTryLockTimeoutException(errMsg); + acquired = lock.tryLock(tableClient.getODPTableEntryRefreshLockTimeout(), + TimeUnit.MILLISECONDS); + if (!acquired) { + String errMsg = "try to lock odpTable-entry refreshing timeout " + " ,tableName:" + + tableName + " , timeout:" + + tableClient.getODPTableEntryRefreshLockTimeout() + "."; + RUNTIME.warn(errMsg); + throw new ObTableTryLockTimeoutException(errMsg); + } } if (locations.get(tableName) != null) { odpTableEntry = locations.get(tableName); @@ -633,6 +635,7 @@ public TableEntry refreshODPMeta(String tableName, boolean forceRefresh, ObTable } } locations.put(tableName, odpTableEntry); + return odpTableEntry; } catch (ObTableTryLockTimeoutException e) { // if try lock timeout, need to retry RUNTIME.warn("wait to try lock to timeout when refresh table meta, tryTimes: {}",