kevinrr888 commented on code in PR #5817:
URL: https://github.com/apache/accumulo/pull/5817#discussion_r2298607086
##########
core/src/main/java/org/apache/accumulo/core/fate/FateExecutor.java:
##########
@@ -107,23 +106,27 @@ public FateExecutor(Fate<T> fate, T environment,
Set<Fate.FateOperation> fateOps
*/
protected void resizeFateExecutor(Map<Set<Fate.FateOperation>,Integer>
poolConfigs,
long idleCheckIntervalMillis) {
- final var pool = transactionExecutor;
final int configured = poolConfigs.get(fateOps);
- ThreadPools.resizePool(pool, () -> configured, poolName);
+ ThreadPools.resizePool(transactionExecutor, () -> configured, poolName);
synchronized (runningTxRunners) {
final int running = runningTxRunners.size();
final int needed = configured - running;
log.trace("resizing pools configured:{} running:{} needed:{}
fateOps:{}", configured, running,
needed, fateOps);
-
if (needed > 0) {
// If the pool grew, then ensure that there is a TransactionRunner for
each thread
for (int i = 0; i < needed; i++) {
+ if (transactionExecutor.isShutdown()) {
+ log.trace("Not adding TransactionRunner, FateExecutor is
shutdown.");
+ break;
+ }
try {
- pool.execute(new TransactionRunner());
+ final TransactionRunner tr = new TransactionRunner();
+ runningTxRunners.add(tr);
+ transactionExecutor.execute(tr);
} catch (RejectedExecutionException e) {
// RejectedExecutionException could be shutting down
- if (pool.isShutdown()) {
+ if (transactionExecutor.isShutdown()) {
// The exception is expected in this case, no need to spam the
logs.
log.trace("Expected error adding transaction runner to FaTE
executor pool. "
+ "The pool is shutdown.", e);
Review Comment:
I'm still not sure about these changes.
1) I'm not sure if we should be checking if the executor is shutdown, I
think that would be best handled with the `RejectedExecutionException`
2) I don't think this current code handles the case where the transaction
runner is added, but the `execute` results in RejectedExecutionException. In
this current code, if the `transactionExecutor.isShutdown()` the tr would never
be added, but if the `RejectedExecutionException` occurs for some other reason,
the tr wouldn't be removed from runningTxRunners.
Maybe fix is always add the tr to runningTxRunners, call execute, if
RejectedExecutionException remove the tr from runningTxRunners. Those that
start successfully will cleanup after they finish running (removed in their
`run` method) and those that cannot be executed will immediately be removed (in
handling RejectedExecutionException).
--
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]