Skip to content

Commit c92cb1c

Browse files
committed
add log, add time check when refresh rsList
1 parent ce32274 commit c92cb1c

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public class ObTableClient extends AbstractObTableClient implements Lifecycle {
9595
Constants.PROXY_SYS_USER_NAME,
9696
"");
9797

98-
private TableRoute tableRoute = null;
98+
private volatile TableRoute tableRoute = null;
9999

100100
private volatile RunningMode runningMode = RunningMode.NORMAL;
101101

@@ -880,6 +880,13 @@ public void syncRefreshMetadata(boolean forceRenew) throws Exception {// do not
880880
}
881881
try {
882882
// double check timestamp
883+
if (System.currentTimeMillis() - lastRefreshMetadataTimestamp < 5000L) {
884+
logger
885+
.warn(
886+
"have to wait for more than 5 seconds to refresh metadata, it has refreshed at: {}",
887+
lastRefreshMetadataTimestamp);
888+
return;
889+
}
883890
if (!forceRenew
884891
&& System.currentTimeMillis() - lastRefreshMetadataTimestamp < metadataRefreshInterval) {
885892
logger

src/main/java/com/alipay/oceanbase/rpc/bolt/transport/ObTableConnection.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public void checkStatus() throws Exception {
230230
reconnect("Check connection is null");
231231
}
232232
if (connection.getChannel() == null || !connection.getChannel().isActive()) {
233+
LOGGER.warn("[latency monitor] need to reconnect server: {}:{}", obTable.getIp(), obTable.getPort());
233234
reconnect("Check connection failed for address: " + connection.getUrl());
234235
}
235236
if (!connection.getChannel().isWritable()) {

src/main/java/com/alipay/oceanbase/rpc/bolt/transport/ObTableRemoting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public ObPayload invokeSync(final ObTableConnection conn, final ObPayload reques
8484
return null;
8585
} else if (!response.isSuccess()) {
8686
String errMessage = TraceUtil.formatTraceMessage(conn, request,
87-
"get an error response: " + response.getMessage());
87+
"get an error response: " + response.getMessage() + ", transportCode: " + response.getTransportCode());
8888
logger.warn(errMessage);
8989
response.releaseByteBuf();
9090
ExceptionUtil.throwObTableTransportException(errMessage, response.getTransportCode());

src/main/java/com/alipay/oceanbase/rpc/location/model/RouteTableRefresher.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public RouteTableRefresher(ObTableClient tableClient) {
4444
* */
4545
private void doRsListCheck() {
4646
try {
47+
logger.info("[latency monitor] background refresher start");
4748
TableRoute tableRoute = tableClient.getTableRoute();
4849
ConfigServerInfo configServer = tableRoute.getConfigServerInfo();
4950
List<ObServerAddr> oldRsList = configServer.getRsList();
@@ -52,6 +53,7 @@ private void doRsListCheck() {
5253
tableClient.getRsListAcquireConnectTimeout(),
5354
tableClient.getRsListAcquireReadTimeout(), tableClient.getRsListAcquireTryTimes(),
5455
tableClient.getRsListAcquireRetryInterval());
56+
logger.info("[latency monitor] finish loadRsListForConfigServerInfo");
5557
List<ObServerAddr> newRsList = newConfigServer.getRsList();
5658
boolean needRefresh = false;
5759
if (oldRsList.size() != newRsList.size()) {
@@ -71,6 +73,7 @@ private void doRsListCheck() {
7173
}
7274
}
7375
}
76+
logger.info("[latency monitor] finish needRefresh checking, needRefresh: {}", needRefresh);
7477
if (needRefresh) {
7578
newConfigServer = LocationUtil.refreshIDC2RegionMapFroConfigServerInfo(
7679
newConfigServer, tableClient.getParamURL(),
@@ -81,6 +84,7 @@ private void doRsListCheck() {
8184
tableRoute.setConfigServerInfo(newConfigServer);
8285
tableRoute.refreshRosterByRsList(newRsList);
8386
}
87+
logger.info("[latency monitor] finish doRsListCheck");
8488
} catch (Exception e) {
8589
logger.warn("RouteTableRefresher::doRsListCheck fail", e);
8690
}

src/main/java/com/alipay/oceanbase/rpc/location/model/TableRoute.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class TableRoute {
6464
private OdpInfo odpInfo = null;
6565
private RouteTableRefresher routeRefresher = null;
6666

67-
public Lock refreshTableRosterLock = new ReentrantLock();
67+
public final Lock refreshTableRosterLock = new ReentrantLock();
6868

6969
public TableRoute(ObTableClient tableClient, ObUserAuth sysUA) {
7070
this.tableClient = tableClient;
@@ -656,6 +656,7 @@ public ObTableParam getTableParam(String tableName, Row rowkey) throws Exception
656656

657657
public ObTableParam getTableParamWithRoute(String tableName, Row rowkey, ObServerRoute route)
658658
throws Exception {
659+
logger.info("[latency monitor] start to execute getTableParamWithRoute");
659660
TableEntry tableEntry = getTableEntry(tableName);
660661
if (tableEntry == null) {
661662
logger.error("tableEntry is null, tableName: {}", tableName);
@@ -807,13 +808,14 @@ private ObTableParam getTableInternal(String tableName, TableEntry tableEntry, l
807808
tableClient.syncRefreshMetadata(true);
808809
// the addr is wrong, need to refresh location
809810
if (logger.isInfoEnabled()) {
810-
logger.info("Cannot get ObTable by addr {}, refreshing metadata.", addr);
811+
logger.info("Cannot get ObTable by addr {}, refreshing metadata, tryTimes: {}.", addr, retryTimes);
811812
}
812813
// refresh tablet location based on the latest roster, in case that some of the observers have been killed
813814
// and used the old location
814815
tableEntry = refreshPartitionLocation(tableName, tabletId, tableEntry);
815816
obPartitionLocationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
816817
replica = getPartitionLocation(obPartitionLocationInfo, route);
818+
logger.warn("[latency monitor] new replica location, {}:{}", replica.getAddr().getIp(), replica.getAddr().getSvrPort());
817819

818820
if (replica == null) {
819821
RUNTIME.error("Cannot get replica by tabletId: " + tabletId);

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientLSBatchOpsImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ private LsOperationsMap prepareByFirstOperation(LsOperationsMap lsOperationsMap,
480480

481481
private LsOperationsMap prepareByEachOperation(LsOperationsMap lsOperationsMap,
482482
BatchIdxOperationPairList operationsWithIndex) throws Exception {
483+
logger.info("[latency monitor] start to execute prepareByEachOperation");
483484
for (int i = 0; i < operationsWithIndex.size(); i++) {
484485
ObPair<Integer, ObTableSingleOp> operation = operationsWithIndex.get(i);
485486
Row rowKey = calculateRowKey(operation);
@@ -534,6 +535,7 @@ public LsOperationsMap partitionPrepare()
534535
public void partitionExecute(ObTableSingleOpResult[] results,
535536
Map.Entry<Long, TabletOperationsMap> lsOperation)
536537
throws Exception {
538+
logger.info("[latency monitor] start to execute partitionExecute");
537539
long lsId = lsOperation.getKey();
538540
TabletOperationsMap tabletOperationsMap = lsOperation.getValue();
539541
if (tabletOperationsMap.isEmpty()) {
@@ -729,6 +731,7 @@ public void partitionExecute(ObTableSingleOpResult[] results,
729731
} else {
730732
if (ex instanceof ObTableTransportException &&
731733
((ObTableTransportException) ex).getErrorCode() == TransportCodes.BOLT_TIMEOUT) {
734+
logger.warn("[latency monitor] meet BOLT_TIMEOUT, need to syncRefreshMetadata, tryTimes: {}", tryTimes);
732735
obTableClient.syncRefreshMetadata(true);
733736
}
734737
obTableClient.calculateContinuousFailure(realTableName, ex.getMessage());

0 commit comments

Comments
 (0)