[ 
https://issues.apache.org/jira/browse/RATIS-878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17091103#comment-17091103
 ] 

runzhiwang edited comment on RATIS-878 at 4/24/20, 2:28 AM:
------------------------------------------------------------

[~ljain]    [~szetszwo]    [~shashikant] 
Hi, there are 2 ideas to avoid the infinite restart of LogAppender.  Which one 
do you prefer ?
1. Limit the number of alive GrpcLogAppenders, say 3. When creating the 4th 
GrpcLogAppender, it has to wait until a previous appender dead. It can
  slow down the restart, but in the log.close case, it can not stop the 
infinite restart of LogAppender.
  
2. Limit the number of GrpcLogAppender restart times in a certain time 
interval, say 1 hour. When creating the 4th GrpcLogAppender,
   if the 1st GrpcLogAppender restart exceed 1 hour and is dead, we can restart 
the 4th, otherwise we should fail and close the pipeline. 
   It can stop the infinite restart of LogAppender.
   The pseudo code as follow. 


{code:java}
Queue<TimeStamp, LogAppender> queue;

restart() {
   if  (checkCanRestart()) {
      newLogAppender = restartLogAppender();
      
      if  (queue.size == 3)  {
        queue.poll();
      }

      queue.add(<now, newLogAppender>);
  } else {
    fail and close pipeline;
  }
}

boolean checkCanRestart() {
  if (queue.size() < 3) {
    return true;
  }
  
  if ((now - queue.peek().TimeStamp > 1 hour) and 
(queue.peek().LogAppender.isAlive == false)) {
     return true;
  }
  
  return false;
} 
{code}



was (Author: yjxxtd):
[~ljain]    [~szetszwo]    [~shashikant] 
Hi, there are 2 ideas to avoid the infinite restart of LogAppender.  Which one 
do you prefer ?
1. Limit the number of alive GrpcLogAppenders, say 3. When creating the 4th 
GrpcLogAppender, it has to wait until a previous appender dead. It can
  slow down the restart, but in the log.close case, it can not stop the 
infinite restart of LogAppender.
  
2. Limit the number of GrpcLogAppender restart times in a certain time 
interval, say 1 hour. When creating the 4th GrpcLogAppender,
   if the 1st GrpcLogAppender restart exceed 1 hour and is dead, we can restart 
the 4th, otherwise we should fail and close the pipeline. 
   It can stop the infinite restart of LogAppender.
   The pseudo code as follow. 


{code:java}
Queue<TimeStamp, LogAppender> queue;

restart() {
        if (checkCanRestart()) {
           newLogAppender = restartLogAppender();
           
           if (queue.size == 3) {
                 queue.poll();
           }

           queue.add(<now, newLogAppender>);
        } else {
           fail and close pipeline;
        }
}

boolean checkCanRestart() {
  if (queue.size() < 3) {
    return true;
  }
  
  if ((now - queue.peek().TimeStamp > 1 hour) and 
(queue.peek().LogAppender.isAlive == false)) {
     return true;
  }
  
  return false;
} 
{code}


> Infinite restart of  LogAppender
> --------------------------------
>
>                 Key: RATIS-878
>                 URL: https://issues.apache.org/jira/browse/RATIS-878
>             Project: Ratis
>          Issue Type: Bug
>            Reporter: runzhiwang
>            Assignee: runzhiwang
>            Priority: Major
>
> The details please refer it here 
> [RATIS-840|https://issues.apache.org/jira/browse/RATIS-840].



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to