-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
ECC/Z3-RequestTop PriorityCurrent objectives and issuesCurrent objectives and issuesbugSomething isn't workingSomething isn't working
Description
zaino/zaino-state/src/chain_index.rs
Lines 418 to 437 in fc4a511
| /// Shut down the sync process, for a cleaner drop | |
| /// an error indicates a failure to cleanly shutdown. Dropping the | |
| /// chain index should still stop everything | |
| pub async fn shutdown(&self) -> Result<(), FinalisedStateError> { | |
| self.finalized_db.shutdown().await?; | |
| self.mempool.close(); | |
| self.status.store(StatusType::Closing as usize); | |
| Ok(()) | |
| } | |
| /// Displays the status of the chain_index | |
| pub fn status(&self) -> StatusType { | |
| let finalized_status = self.finalized_db.status(); | |
| let mempool_status = self.mempool.status(); | |
| let combined_status = StatusType::from(self.status.load()) | |
| .combine(finalized_status) | |
| .combine(mempool_status); | |
| self.status.store(combined_status as usize); | |
| combined_status | |
| } |
I noticed a couple of issues here (there may be more):
NodeBackedChainIndex::shutdowncalls its inner shutdown methods, and only setsself.statustoStatusType::Closingonce they all return. This means that there is a window of time where a subscriber can checkNodeBackedChainIndex::statusand see the indexer is running, then try to perform some action whileself.finalized_dbis actually in a partially or fully shut down state.- There happens to be no race with any caller that executes after
self.mempool.close()starts, because that method sets its internal status toStatusType::Closingfirst, and thenNodeBackedChainIndex::statuswill take that as the most important status when combining. But we can't rely on that overall.
- There happens to be no race with any caller that executes after
- If the
self.status.store(StatusType::Closing)call insideNodeBackedChainIndex::shutdownwere moved to the start of the method (to fix the above race condition), this would introduce a race condition between that andNodeBackedChainIndex::status, because the latter also callsself.status.store()and could overwrite theStatusType::Closingstatus, creating another window in which an external subscriber can observe the status of the indexer to be "running" when it is actually partially shut down.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ECC/Z3-RequestTop PriorityCurrent objectives and issuesCurrent objectives and issuesbugSomething isn't workingSomething isn't working
Type
Projects
Status
Backlog