[
https://issues.apache.org/jira/browse/IGNITE-21538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17836096#comment-17836096
]
Kirill Sizov edited comment on IGNITE-21538 at 4/11/24 10:16 AM:
------------------------------------------------------------------
The suggested design includes:
1. Add a counter to track all running async requests for each component.
2. Each root async method (that creates a new future) of a component will
increment the counter. Once the future completes, the counter decrements.
3. When beforeShutdown() is called, it waits for the counter to become 0.
4. No counter increments is expected when a synchronous method is called.
The node design states that all synchronous methods are called from
asynchronous ones and we will anyway wait for this operation to complete on the
upper level.
The calls from the bottom to the top (from leaf components to their containers)
should be safe as we expect that the container components stop only when all
leaf components are stopped.
was (Author: JIRAUSER301198):
The suggested design includes:
1. Add a counter to track all running async requests for each component.
2. Each root async method (that creates a new future) of a component will
increment the counter. Once the future completes, the counter decrements.
3. When beforeShutdown() is called, it waits for the counter to become 0.
4. No counter increments is expected when a synchronous method is called.
The node design states that all synchronous methods are called from
asynchronous ones and we will anyway wait for this operation to complete on the
upper level.
The calls from the bottom to the top (from leaf components to their containers)
should be safe as we expect that the container components stop after all leaf
components are stopped.
> Rework component lifecycle mode to asynchronous
> -----------------------------------------------
>
> Key: IGNITE-21538
> URL: https://issues.apache.org/jira/browse/IGNITE-21538
> Project: Ignite
> Issue Type: Task
> Affects Versions: 3.0.0-beta2
> Reporter: Alexey Scherbakov
> Assignee: Kirill Sizov
> Priority: Major
> Labels: ignite-3
> Fix For: 3.0
>
>
> Current design for comp lifecycle has issues:
> 1. It was designed for synchronous components, but almost all components are
> asynchronous.
> This causes to appear ugly things like _inBusyLockAsync_ and inefficient code
> like
> _public @Nullable TxStateMeta stateMeta(UUID txId) \{ return
> inBusyLock(busyLock, () -> txStateVolatileStorage.state(txId)); }_
> 2. Currently it's not possible to do truly graceful node shutdown, because IO
> layer is disabled out-of-order, causing operation failures without a chance
> to finish.
> I suggest reworking comp lifecycle to async model:
> 1. Each component tracks it's inflight async ops (as list of async chains)
> 2. On start components are initialized using _CompletableFuture<Void>
> startAsync()_ method from root to leafs of dependency tree
> 3. On shutdown
> 3.1 _CompletableFuture<Void>beforeShutdown_ is called on comp from leafs to
> root direction in dependency tree. This step waits for all active futures to
> complete. Any new operation return a future completed with
> _NodeStoppingException_
> 3.2 stop is called on comp from leafs to root direction in dependency tree.
> This step destroys component resources, like pools, etc.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)