You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: address slow shutdowns in aggregation loop (#1297)
<!--
Please read and fill out this form before submitting your PR.
Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->
## Overview
<!--
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue.
-->
I started trying to debug the test failure in #1058 and #1095 by first
cleaning up the test output. I replaced the stdout logger with the file
logger and that highlighted some panic conditions of writing to a closed
file, which meant there were some hanging threads. The test that was
easiest to catch the panic was `TestTx`.
One of the issues was the indexer didn't have a ctx so wasn't shutting
down cleanly.
The second was the edge case of the aggregation loop execution taking
some time, resulting in the node shutting down in the middle. I added
the ctx check at the end so that any updates are ideally saved to the
store before we exit.
I tested this locally by running the failing test in a loop. Prior to
these changes it panicked every time, afterwards, you can run the test
in a loop without failure.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
## Summary by CodeRabbit
Refactor:
- Enhanced the node shutdown process in `block/manager.go` to skip
publishing if the node is already shut down, improving system
efficiency.
- Modified the `createAndStartIndexerService` function in `node/full.go`
to require a context during initialization, allowing for better control
over the service's lifecycle.
Tests:
- Updated `node/full_client_test.go` to use a cancellable context and a
new file logger, improving test reliability and logging capabilities.
- Modified `state/txindex/indexer_service_test.go` to use a cancellable
context, ensuring proper cleanup after tests.
Style:
- Updated `state/txindex/indexer_service.go` to include a context in the
`IndexerService` struct and handle its cancellation, aligning with the
context-oriented design.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Manav Aggarwal <[email protected]>
0 commit comments