RejectedExecutionException: Nested Executions are not allowed

22 views
Skip to first unread message

ant elder

unread,
Mar 22, 2010, 12:48:21 PM3/22/10
to Hazelcast
I've been looking at using the Hazelcast ExecutorService as a way to
do request-response communication between members and I've hit the
"RejectedExecutionException: Nested Executions are not allowed" when
member A talks to member B which then tries to talk to member C.
Playing around in a debugger i can skip over the test in
ExecutorServiceProxy.submit for if the thread starts with
"hz.executor." and it then all seems to work ok so what is the reason
for preventing this? ...and is there any way it could be relaxed?

Many thanks.

...ant

Talip Ozturk

unread,
Mar 22, 2010, 3:08:53 PM3/22/10
to haze...@googlegroups.com
We are trying to prevent from a deadlock where an execution is waiting
on another execution to finish but these two executions are using the
same bounded (fixed-size) thread-pool (executor-service). if there is
no available thread in the thread-pool then the second execution can
never start so causing a deadlock.

if an executor-service task itself (callable or runnable) is executing
another task you should make sure the inner task is not executed on
the same executor-service.

You can create independent executor-services by name.
Hazelcast.getExecutorService(name);

We can completely avoid having the deadlock by changing the
executor-service implementation to use unbounded (cached) thread-pool
instead. I just don't like threads to come and go as they contain
thread-local data. not 100% sure convienced though.

-talip

> --
> You received this message because you are subscribed to the Google Groups "Hazelcast" group.
> To post to this group, send email to haze...@googlegroups.com.
> To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.
>
>

ant elder

unread,
Mar 22, 2010, 4:16:13 PM3/22/10
to haze...@googlegroups.com
Thanks for the quick answer, i guess that makes sense and knowing that
i can get it working with the code below. Its not terribly elegant
though so i wonder if Hazelcast couldn't be doing something more to
help, though i can't think of how right now.

private ExecutorService getExecutorService() {
String threadName = Thread.currentThread().getName();
if (!threadName.startsWith("hz.executor.")) {
return
hzRegistry.getHazelcastInstance().getExecutorService("binding.sca.1");
} else {
String oldName =
threadName.substring(threadName.lastIndexOf("binding.sca."),
threadName.lastIndexOf(".thread-"));
int x =
Integer.parseInt(oldName.substring(oldName.lastIndexOf('.') + 1));
return
hzRegistry.getHazelcastInstance().getExecutorService(oldName.substring(0,
12) + (x + 1));
}
}

...ant

Talip Ozturk

unread,
Mar 22, 2010, 4:23:23 PM3/22/10
to haze...@googlegroups.com
This is looking a little dangerous. You should be very careful about
not creating hundreds of executorservices hanging around.

We also better make Hazelcast default executor service be configurable
in a way that you can force it to be cached (unbounded) instead of
fixed. Please create an issue for this.

-talip

ant elder

unread,
Mar 23, 2010, 2:18:48 AM3/23/10
to haze...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages