This is an automated email from the ASF dual-hosted git repository.

caiconghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 0490b15  [Bug] Fix bug that call frontend service failed when 
rpc_timeout is equal with publish_timeout (#5564)
0490b15 is described below

commit 0490b156c862963bb1dfb05ba5e976ac59b31132
Author: caiconghui <[email protected]>
AuthorDate: Tue Mar 30 19:50:42 2021 +0800

    [Bug] Fix bug that call frontend service failed when rpc_timeout is equal 
with publish_timeout (#5564)
    
    * [Bug] Fix bug that call frontend service failed when rpc_timeout is equal 
with publish_timeout
    
    *This PR is to fix bug that call frontend service failed when rpc_timeout 
is equal with publish_timeout and fix some small issues with log
    
    Co-authored-by: caiconghui [蔡聪辉] <[email protected]>
---
 .../src/main/java/org/apache/doris/master/MasterImpl.java    |  9 ++++++---
 .../src/main/java/org/apache/doris/mysql/MysqlProto.java     |  2 +-
 .../main/java/org/apache/doris/mysql/nio/NMysqlChannel.java  |  2 +-
 .../java/org/apache/doris/service/FrontendServiceImpl.java   |  2 +-
 .../org/apache/doris/transaction/GlobalTransactionMgr.java   | 12 +++++++++++-
 5 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/master/MasterImpl.java 
b/fe/fe-core/src/main/java/org/apache/doris/master/MasterImpl.java
index 3a8d131..2b3217f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/master/MasterImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/master/MasterImpl.java
@@ -94,9 +94,12 @@ public class MasterImpl {
         // check task status
         // retry task by report process
         TStatus taskStatus = request.getTaskStatus();
-        LOG.debug("get task report: {}", request.toString());
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("get task report: {}", request);
+        }
+
         if (taskStatus.getStatusCode() != TStatusCode.OK) {
-            LOG.warn("finish task reports bad. request: {}", 
request.toString());
+            LOG.warn("finish task reports bad. request: {}", request);
         }
 
         // get backend
@@ -109,7 +112,7 @@ public class MasterImpl {
             List<String> errorMsgs = new ArrayList<>();
             errorMsgs.add("backend not exist.");
             tStatus.setErrorMsgs(errorMsgs);
-            LOG.warn("backend does not found. host: {}, be port: {}. task: 
{}", host, bePort, request.toString());
+            LOG.warn("backend does not found. host: {}, be port: {}. task: 
{}", host, bePort, request);
             return result;
         }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java 
b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java
index c608948..3120eab 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlProto.java
@@ -141,7 +141,7 @@ public class MysqlProto {
         try {
             channel.sendAndFlush(serializer.toByteBuffer());
         } catch (IOException e) {
-            LOG.warn("Send and flush channel exception, ignore. Exception: " + 
e.toString());
+            LOG.debug("Send and flush channel exception, ignore.", e);
             return false;
         }
         // Server receive authenticate packet from client.
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/mysql/nio/NMysqlChannel.java 
b/fe/fe-core/src/main/java/org/apache/doris/mysql/nio/NMysqlChannel.java
index 799a005..4260c0b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/nio/NMysqlChannel.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/nio/NMysqlChannel.java
@@ -68,7 +68,7 @@ public class NMysqlChannel extends MysqlChannel {
                 readLen += ret;
             }
         } catch (IOException e) {
-            LOG.warn("Read channel exception, ignore. Exception: " + 
e.toString());
+            LOG.debug("Read channel exception, ignore.", e);
             return 0;
         }
         return readLen;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java 
b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index 739c762..260a641 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -822,7 +822,7 @@ public class FrontendServiceImpl implements 
FrontendService.Iface {
             throw new UserException("unknown database, database=" + dbName);
         }
 
-        long timeoutMs = request.isSetThriftRpcTimeoutMs() ? 
request.getThriftRpcTimeoutMs() : 5000;
+        long timeoutMs = request.isSetThriftRpcTimeoutMs() ? 
request.getThriftRpcTimeoutMs() / 2 : 5000;
         Table table = db.getTableOrThrowException(request.getTbl(), 
TableType.OLAP);
         boolean ret = 
Catalog.getCurrentGlobalTransactionMgr().commitAndPublishTransaction(
                         db, Lists.newArrayList(table), request.getTxnId(),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java
 
b/fe/fe-core/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java
index ca2313c..7dbc0d3 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java
@@ -18,6 +18,7 @@
 package org.apache.doris.transaction;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.StopWatch;
 import org.apache.doris.catalog.Catalog;
 import org.apache.doris.catalog.Database;
 import org.apache.doris.catalog.Table;
@@ -189,6 +190,8 @@ public class GlobalTransactionMgr implements Writable {
             List<TabletCommitInfo> tabletCommitInfos, long timeoutMillis,
             TxnCommitAttachment txnCommitAttachment)
             throws UserException {
+        StopWatch stopWatch = new StopWatch();
+        stopWatch.start();
         if (!MetaLockUtils.tryWriteLockTables(tableList, timeoutMillis, 
TimeUnit.MILLISECONDS)) {
             throw new UserException("get tableList write lock timeout, 
tableList=(" + StringUtils.join(tableList, ",") + ")");
         }
@@ -197,8 +200,15 @@ public class GlobalTransactionMgr implements Writable {
         } finally {
            MetaLockUtils.writeUnlockTables(tableList);
         }
+        stopWatch.stop();
+        long publishTimeoutMillis = timeoutMillis - stopWatch.getTime();
         DatabaseTransactionMgr dbTransactionMgr = 
getDatabaseTransactionMgr(db.getId());
-        return dbTransactionMgr.publishTransaction(db, transactionId, 
timeoutMillis);
+        if (publishTimeoutMillis < 0) {
+            // here commit transaction successfully cost too much time to 
cause publisTimeoutMillis is less than zero,
+            // so we just return false to indicate publish timeout
+            return false;
+        }
+        return dbTransactionMgr.publishTransaction(db, transactionId, 
publishTimeoutMillis);
    }
 
     public void abortTransaction(long dbId, long transactionId, String reason) 
throws UserException {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to