Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Fix contexts#1183

Closed
ceyonur wants to merge 8 commits into
masterfrom
fix-contexts
Closed

Fix contexts#1183
ceyonur wants to merge 8 commits into
masterfrom
fix-contexts

Conversation

@ceyonur

@ceyonur ceyonur commented May 22, 2024

Copy link
Copy Markdown
Collaborator

Why this should be merged

Replaced context.TODOs

Fixes: ava-labs/avalanchego#4730

How this was tested

Local UT/e2e tests

How is this documented

No need

@ceyonur ceyonur self-assigned this May 22, 2024
@ceyonur ceyonur requested a review from darioush as a code owner May 22, 2024 20:47
@ceyonur ceyonur marked this pull request as draft May 22, 2024 20:47
@ceyonur ceyonur marked this pull request as ready for review May 23, 2024 00:01
darioush
darioush previously approved these changes May 23, 2024
@patrick-ogrady patrick-ogrady added the DO NOT MERGE This PR is not meant to be merged in its current state label May 28, 2024

@tsachiherman tsachiherman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same comment, which would apply at different locations - but with the same concern:

  • terminating a method mid-flight might leave the database in a different state compared to it's existing behavior.
  • I can't really tell if that would be an issue or not. Some code might need to be written differently to support that. ( i.e. perform a single commit instead of multiple commits ).
  • If there is such a place where it would be hard to break a for-loop, I'd suggest placing the context checking both before and after the loop. That's not ideal, but it wouldn't cause any regression.

Comment thread core/blockchain.go
// snapshots since the disk layer for snapshots will most likely be above the last committed
// state that reprocessing will start from.
func (bc *BlockChain) reprocessState(current *types.Block, reexec uint64) error {
func (bc *BlockChain) reprocessState(ctx context.Context, current *types.Block, reexec uint64) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really live the addition of an expiration context here. Two concerns:

  1. In the case of a context expiration, should we clear out the current block so that this method would be atomic ?
  2. Is there any state issue with partial execution of this method ? i.e. would terminating the execution in the middle would bring the node to some undesired state ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think contexts used to gracefully shutdown are safe to use, but we decided not to merge this PR as contexts from VM init can be closed from parent thread when SetState is called.

@ceyonur ceyonur closed this May 29, 2024
JonathanOppenheimer added a commit that referenced this pull request Oct 2, 2025
Signed-off-by: Stephen Buttolph <stephen@avalabs.org>
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
github-merge-queue Bot pushed a commit that referenced this pull request Oct 13, 2025
Signed-off-by: Stephen Buttolph <stephen@avalabs.org>
Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

DO NOT MERGE This PR is not meant to be merged in its current state

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Replace context.TODOs

4 participants