lrhkobe opened a new issue #461:
URL: https://github.com/apache/incubator-eventmesh/issues/461


   ## Bug Report
   
   ### Describe the bug
   The global flow control is not work,because the current logic exist problem.
   
   **The wrong way:**
   ```
   public void run() {
        ...
        if (!rateLimiter.tryAcquire(TRY_PERMIT_TIME_OUT, 
TimeUnit.MILLISECONDS)) {
                doFlowControlHandle();
                return;
        }
   
        doSend();
        ...
   }
   
   ```
   In this way, the send thread releases the token immediately after obtaining 
it.
   
   **The right way:** 
   ```
   public void run() {
        ...
        if (rateLimiter.tryAcquire(TRY_PERMIT_TIME_OUT, TimeUnit.MILLISECONDS)) 
{
                doSend();
        }else{
                doFlowControlHandle();
                return;
        }
   
        ...
   }
   ```
   
   **Current in `MessageTransferTask.java`:** 
   ```
   public void run() {
        ...
        if (!cmd.equals(RESPONSE_TO_SERVER) && 
!eventMeshTCPServer.getRateLimiter().tryAcquire(TRY_PERMIT_TIME_OUT, 
TimeUnit.MILLISECONDS)) {
                msg.setHeader(new Header(replyCmd, OPStatus.FAIL.getCode(), 
"Tps overload, global flow control", pkg.getHeader().getSeq()));
                ctx.writeAndFlush(msg).addListener(
                                new ChannelFutureListener() {
                                        @Override
                                        public void 
operationComplete(ChannelFuture future) throws Exception {
                                                
Utils.logSucceedMessageFlow(msg, session.getClient(), startTime, 
taskExecuteTime);
                                        }
                                }
                );
                logger.warn("======Tps overload, global flow control, rate:{}! 
PLEASE CHECK!========", eventMeshTCPServer.getRateLimiter().getRate());
                return;
        }
   
        doSend();
        ...
   }
   ```
   Current code in EventMesh is same with the wrong way.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to