You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Glen Geng (Jira)" <ji...@apache.org> on 2020/12/01 06:25:00 UTC

[jira] [Comment Edited] (HDDS-4533) Avoid rewriting pipeline information during PipelineStateManagerV2Impl initialization

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

Glen Geng edited comment on HDDS-4533 at 12/1/20, 6:24 AM:
-----------------------------------------------------------

Thanks [~nanda] for pointing out this issue !

 

I think you must mean following code
{code:java}
public class PipelineStateManagerV2Impl implements StateManager {

  // .....

  private void initialize() throws IOException {
    if (pipelineStore == null || nodeManager == null) {
      throw new IOException("PipelineStore cannot be null");
    }
    if (pipelineStore.isEmpty()) {
      LOG.info("No pipeline exists in current db");
      return;
    }
    TableIterator<PipelineID, ? extends Table.KeyValue<PipelineID, Pipeline>>
        iterator = pipelineStore.iterator();
    while (iterator.hasNext()) {
      Pipeline pipeline = iterator.next().getValue();
      addPipeline(pipeline.getProtobufMessage());
    }
  }

  @Override
  public void addPipeline(HddsProtos.Pipeline pipelineProto)
      throws IOException {
    Pipeline pipeline = Pipeline.getFromProtobuf(pipelineProto);
    pipelineStore.put(pipeline.getId(), pipeline);
    pipelineStateMap.addPipeline(pipeline);
    nodeManager.addPipeline(pipeline);
    LOG.info("Created pipeline {}.", pipeline);
  }
{code}
I consider that we may remove the initialize() method, here is the reason:

 

Given a replicated state machine managed by raft, after the start of system, the applyIndex will be initialized to 0, the StateMachineUpdater will apply the log entires until applyIndex advance to lastLogIndex to restore the state machine. P.S, this is the situation that snapshot is not enabled.

 

In our case, the log entries will be the method addPipeline()/removePipeline()/updatePipelineState(), which means that the underlying raft server will help us to do the initialization job.

 

What we need to do is to call RaftServerImpl#isLeaderReady() to make sure that once becoming leader, current SCM should not handle any incoming client request unless all of the log entries have been applied.

 
{code:java}
public boolean isLeaderReady() {
  if (!isLeader()) {
    return false;
  }

  final LeaderState leaderState = role.getLeaderState().orElse(null);
  if (leaderState == null || !leaderState.isReady()) {
    return false;
  }

  return true;
}


boolean isReady() {
  return server.getState().getLastAppliedIndex() >= placeHolderIndex;
}
{code}
 


was (Author: glengeng):
Thanks [~nanda] for pointing out this issue !

 

I think you must mean following code
{code:java}
public class PipelineStateManagerV2Impl implements StateManager {

  // .....

  private void initialize() throws IOException {
    if (pipelineStore == null || nodeManager == null) {
      throw new IOException("PipelineStore cannot be null");
    }
    if (pipelineStore.isEmpty()) {
      LOG.info("No pipeline exists in current db");
      return;
    }
    TableIterator<PipelineID, ? extends Table.KeyValue<PipelineID, Pipeline>>
        iterator = pipelineStore.iterator();
    while (iterator.hasNext()) {
      Pipeline pipeline = iterator.next().getValue();
      addPipeline(pipeline.getProtobufMessage());
    }
  }

  @Override
  public void addPipeline(HddsProtos.Pipeline pipelineProto)
      throws IOException {
    Pipeline pipeline = Pipeline.getFromProtobuf(pipelineProto);
    pipelineStore.put(pipeline.getId(), pipeline);
    pipelineStateMap.addPipeline(pipeline);
    nodeManager.addPipeline(pipeline);
    LOG.info("Created pipeline {}.", pipeline);
  }
{code}
I consider that we may remove the initialize() method, here is the reason:

 

Given a replicated state machine managed by raft, after the start of system, the applyIndex will be initialized to 0, the StateMachineUpdater will apply the log entires until applyIndex advance to lastLogIndex to restore the state machine. P.S, this is the situation that snapshot is not enabled.

 

In our case, the log entries will be the method addPipeline()/removePipeline()/updatePipelineState(), which means that the underlying raft server will help us to do the initialization job.

 

What we need to do is to call RaftServerImpl#isLeaderReady() to make sure that once becoming leader, current SCM should not handle any incoming client request unless all of the log entries have been applied.

 

 

> Avoid rewriting pipeline information during PipelineStateManagerV2Impl initialization
> -------------------------------------------------------------------------------------
>
>                 Key: HDDS-4533
>                 URL: https://issues.apache.org/jira/browse/HDDS-4533
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>          Components: SCM HA
>            Reporter: Nanda kumar
>            Priority: Major
>              Labels: newbie
>
> {{PipelineStateManagerV2Impl}} adds the pipeline back to the pipeline table (RocksDB) during initialization which is unnecessary. This can be avoided.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org