--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/67d1a325-8993-4404-a0a5-b1f51eb483b9%40googlegroups.com.
Hi Scott, you are absolutely right on your findings. A Future must be disposed to release resources, and this /still/ is the responsibility of the caller.
The reason this happens is the API itself which returns a Future object, and due to the distributed nature of the application, its not easy to trackthe reference of the ScheduledFuture and whether its in use or not. This means that if you indeed hold a reference to that, and we auto-dispose, youwill end up with a "dead" Future object.
Having said that, I have seen the same thing been asked 2-3 times, so it seems like a useful feature.I will have another look at it, to see whether we can include this with minimal effort, but feel free to contribute a solution, we appreciate them :-)
At the moment your only option would be to create another repeatable task, ie. 'task-cleaner' which periodically checks, which Futures are completed, and dispose them.This means that you have to keep track of the futures in a list, and read-and-remove entries from that list within your task-cleaner.
An alternative approach would be to wrap all your Runnables/Callables in an AutoDisposable class of yours, which can use the DurableExecutorService to execute a dispose task.
This is a bit more complex for my taste, so its up to you.
On Sat, May 16, 2020 at 1:04 PM <sc...@indosoft.com> wrote:
--I'm submitting many fire-and-forget tasks that are scheduled to "fire" after a specified delay. From reading the documentation, it looks like I need to unconditionally call IScheduledFuture.dispose() according to an example in 10.3.2 of https://docs.hazelcast.org/docs/3.12.2/manual/html-single/index.html#scheduled-exec-srv-examples:future.dispose(); // Always dispose futures that are not in use any more, to release resourcesMy problem is that the only thing that knows about the task (hence the "forget" part) is the task itself, which ends up being responsible for its own disposal. The most convenient time to dispose of it ends up being within a transaction. If I call IScheduledFuture.dispose() from within the running task thread, I invariably end up with a ThreadInterruptedException at commit time. This forces me to pass the Future back along to the eventual parent caller, outside the transaction, to dispose of it only immediately before my Runnable.run() or Callable.call() method returns. This is invariably outside the transaction, which can be difficult to implement. Is there a simpler solution to these fire-and-forget delayed tasks?
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haze...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/67d1a325-8993-4404-a0a5-b1f51eb483b9%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/55293058-1e90-45c2-a1d2-f9d9be001f0b%40googlegroups.com.
Hi Belen,
Thanks for your comment here.
The naming of the tasks certainly plays a role in the behavior you are seeing but not due to disposal.
The maximum capacity of 100, is per partition, so if you have 271 (default partition count) partitions, then you can have thousands of tasks without seeing this exception.
When you start naming tasks, you are forcing them to reside on a particular partition (the one that the name hashes to), thus its easier to hit that error.FWIT In Hazelcast 4.0 we introduced capacity setting per-node as well, which makes this restriction much more predictable.
To recap, disposal of the tasks is never automatic, since the API returns a Future, the caller is responsible for disposing it.
I created a feature request (https://github.com/hazelcast/hazelcast/issues/16994), feel free to upvote it, or even contribute to it :-)
Hope this helps
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/55293058-1e90-45c2-a1d2-f9d9be001f0b%40googlegroups.com.
I'm hoping that if I both cancel the task and reschedule it as part of Synchronization.afterCompletion() I'll avoid the complexity of bubbling the IScheduledFuture up to the topmost caller and still avoid InterruptedExceptions.
I'm also hoping I can figure out how to check out and build Hazelcast on my own so I can start contributing with more than just lengthy forum posts.
I'm also looking forward to TransactionalDurableExecutorService and TransactionalScheduledExecutorService with two-phase commit. A guy can dream.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/5bfd803d-6158-45fa-ada8-c36e1c759b78%40googlegroups.com.