-
Couldn't load subscription status.
- Fork 9.1k
HDDS-1406. Avoid usage of commonPool in RatisPipelineUtils. #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to make submit call for each datanode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use a simple executor as fork join pool is an executor for fork join tasks. Also we can always keep the number of threads to three as there is a network call involved in the task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used ForkJoinPool can be used for normal tasks also. Refer NonFrok Join Clients.
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ForkJoinPool.html
Used this ForJoinPool here to take advantage of its WorkSteal Algorithm in allocating/claiming threads. I think this might be useful. More can be read from the documentation.
And if no of available processors is less than 3, even setting to 3 will not have any advantage. This is the reason for setting this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use three threads as these threads would ultimately be blocked on network IO and will not be CPU intensive. Also we need to shutdown the fork join pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
1a51c85 to
2cbbb60
Compare
|
/retest |
|
Thank You @arp7 for offline review comments. |
|
💔 -1 overall
This message was automatically generated. |
2cbbb60 to
e667cf0
Compare
|
Thank You @lokeshj1703 for the review. |
e667cf0 to
7300b49
Compare
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
...op-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/RatisPipelineUtils.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shutdown will wait for previously submitted tasks to complete. You can probably call shutdownNow since we don't care about the completion on shutdown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
7300b49 to
b877751
Compare
|
Thank You @arp7 for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Bharat. A couple of more minor comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't log here, just throw IOException that wraps the ExecutionException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, don't log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging here, because in the actual createPipelines method in BackGroudPipelineCreator which calls this method when we throw IOException they break from while loop. That is the reason for the logging. Let me know if we still don't want to log here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That method is already logging right:
pipelineManager.createPipeline(type, factor);
} catch (IOException ioe) {
break;
} catch (Throwable t) {
LOG.error("Error while creating pipelines {}", t);
break;
}
So if we log here the exception will be logged twice. Perhaps I'm looking at it wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We return IOException, so in case of IOException we have no logging right?
It has only break;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify the code a bit by catching multiple exceptions in one clause. e.g.
catch(ExecutionException|RejectedExecutionException e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
💔 -1 overall
This message was automatically generated. |
|
/retest |
|
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please check if one of the threads is not used up in waiting for parallel stream to finish execution? If it does then there are only two threads available for making a rpc call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid making it static? The problem with static occurs in the MiniOzoneCluster tests. Once SCM is stopped by one of the tests, the fork join pool will be shutdown and will not be available again for execution. I think this might be a reason for unit test failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
Test failures are not related to this patch. |
|
Thank You @lokeshj1703 for the review. |
|
💔 -1 overall
This message was automatically generated. |
|
|
||
| PipelineFactory(NodeManager nodeManager, PipelineStateManager stateManager, | ||
| Configuration conf) { | ||
| Configuration conf, RatisPipelineUtils ratisPipelineUtils) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bharatviswa504 Thanks for adding the changes! An instance of RatisPipelineUtils does not seem right as it is a utility class. Could we move the functions of RatisPipelineUtils to RatisPipelineProvider instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
Thank You @lokeshj1703 for the review. |
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
| } | ||
|
|
||
| @VisibleForTesting | ||
| public PipelineProvider getProvider(ReplicationType type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to expose this api for now. In the test where it is used, we can call pipelineManager.createPipeline instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| void triggerPipelineCreation(); | ||
|
|
||
| PipelineFactory getPipelineFactory(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to expose this api as well. The shutdown for pipelineFactory should be called from PipelineManager itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| @Override | ||
| public void shutdown() { | ||
| forkJoinPool.shutdownNow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also wait for the tasks to finish. We need to use awaitTermination call. We can use timeout of 60 seconds? That is what is used in Scheduler class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done based on arpit's comment, as on an unclean shutdown this terminate abruptly. So we can use shutdownNow(), instead of awaitTermination in normal case too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bharatviswa504 I agree. We need to use shutdownNow but we also need to use awaitTermination. shutdownNow would interrupt the running tasks but the running task should handle the interrupt. If the task does not exit on interrupt, it is a better idea to wait for the task to finish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| (pool -> { | ||
| final ForkJoinWorkerThread worker = ForkJoinPool. | ||
| defaultForkJoinWorkerThreadFactory.newThread(pool); | ||
| worker.setName("ratisCreatePipeline" + worker.getPoolIndex()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT - "ratisCreatePipeline" - Can we make it all capital?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| * @param pipeline - Pipeline to be created | ||
| * @throws IOException if creation fails | ||
| */ | ||
| public void createPipeline(Pipeline pipeline) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this fn and replace it with initializePipeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| } | ||
|
|
||
| @Override | ||
| public PipelineFactory getPipelineFactory() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont need to expose this api. We can add a shutdown call for the pipelineFactory in the SCMPipelineManager#close fn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| @Override | ||
| public void shutdown() { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT - Can we add a comment like //do nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| } | ||
|
|
||
| // shutdown pipeline provider. | ||
| pipelineManager.getPipelineFactory().shutdown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| @Override | ||
| public void shutdown() { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT - Can we add a comment like // do nothing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| HddsProtos.ReplicationType.RATIS); | ||
| try { | ||
| RatisPipelineUtils.createPipeline(pipelines.get(0), conf); | ||
| ratisPipelineProvider.createPipeline(pipelines.get(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use pipelineManager#create call instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
Thank You @lokeshj1703 for the review. |
| private final Configuration conf; | ||
|
|
||
| // Set parallelism at 3, as now in Ratis we create 1 and 3 node pipelines. | ||
| private final int parallelisimForPool = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo. parallelis'i'mForPool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
@lokeshj1703 Addressed the review comments. |
|
💔 -1 overall
This message was automatically generated. |
|
@bharatviswa504 Thanks for updating the PR! The changes look good to me. +1. |
|
@bharatviswa504 can you check if the UT failure is related to the patch? |
|
Thank You @lokeshj1703 and @arp7 for the review. |
Author: Sanil15 <[email protected]> Reviewers: Jagadish<[email protected]> Closes apache#714 from Sanil15/SAMZA-1930

No description provided.