Skip to content

Commit 4d9a296

Browse files
committed
remove lock in refreshTableLocationByTabletId
1 parent e46c25c commit 4d9a296

File tree

3 files changed

+221
-207
lines changed

3 files changed

+221
-207
lines changed

src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,33 +1340,14 @@ public TableEntry refreshTableLocationByTabletId(TableEntry tableEntry, String t
13401340
}
13411341
long lastRefreshTime = tableEntry.getPartitionEntry().getPartitionInfo(tabletId).getLastUpdateTime();
13421342
long currentTime = System.currentTimeMillis();
1343-
if (currentTime - lastRefreshTime < tableEntryRefreshLockTimeout) {
1343+
if (currentTime - lastRefreshTime < 1000) {
13441344
return tableEntry;
13451345
}
1346-
1347-
Lock lock = tableEntry.refreshLockMap.computeIfAbsent(tabletId, k -> new ReentrantLock());
1348-
1349-
if (!lock.tryLock(tableEntryRefreshLockTimeout, TimeUnit.MILLISECONDS)) {
1350-
String errMsg = String.format("Try to lock table-entry refreshing timeout. DataSource: %s, TableName: %s, Timeout: %d.",
1351-
dataSourceName, tableName, tableEntryRefreshLockTimeout);
1352-
RUNTIME.error(errMsg);
1353-
throw new ObTableEntryRefreshException(errMsg);
1354-
}
1355-
1356-
try {
1357-
lastRefreshTime = tableEntry.getPartitionEntry().getPartitionInfo(tabletId).getLastUpdateTime();
1358-
currentTime = System.currentTimeMillis();
1359-
if (currentTime - lastRefreshTime < tableEntryRefreshLockTimeout) {
1360-
return tableEntry;
1361-
}
1362-
tableEntry = loadTableEntryLocationWithPriority(serverRoster, tableEntryKey, tableEntry, tabletId,
1363-
tableEntryAcquireConnectTimeout, tableEntryAcquireSocketTimeout,
1364-
serverAddressPriorityTimeout, serverAddressCachingTimeout, sysUA);
1346+
tableEntry = loadTableEntryLocationWithPriority(serverRoster, tableEntryKey, tableEntry, tabletId,
1347+
tableEntryAcquireConnectTimeout, tableEntryAcquireSocketTimeout,
1348+
serverAddressPriorityTimeout, serverAddressCachingTimeout, sysUA);
13651349

1366-
tableEntry.prepareForWeakRead(serverRoster.getServerLdcLocation());
1367-
} finally {
1368-
lock.unlock();
1369-
}
1350+
tableEntry.prepareForWeakRead(serverRoster.getServerLdcLocation());
13701351

13711352
} catch (ObTableNotExistException | ObTableServerCacheExpiredException e) {
13721353
RUNTIME.error("RefreshTableEntry encountered an exception", e);

0 commit comments

Comments
 (0)