[ https://issues.apache.org/jira/browse/IGNITE-21538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17841264#comment-17841264 ]
Kirill Sizov commented on IGNITE-21538: ---------------------------------------- Created a PoC in the attached github PR. > 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)