Graceful exit #4
Labels
No Label
bug
critical
duplicate
enhancement
epic
help wanted
in progress
invalid
low priority
question
rebase
v1
v5
wontfix
Copied from Github
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cerc-io/go-ethereum#4
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "graceful-exit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Looking good! Left a few comments - mostly interested in the error condition in the for loop
Just curious - does this name provide additional functionality/would the body of the goroutine behave differently without it?
wondering if it makes sense to fail here - seems like parent block being nil should never happen, unless maybe we're at the genesis block?
wouldn't this trigger
subErr
within two more passes through the for loop? are we expectinglen(bc.ChainEvents) < 2)
?Looks like it is letting the select break exit the for loop, otherwise I think you could do something like
to get the same behavior
but wouldn't the existing code with just
break
(without a named loop) also do the same thing?A plain break in the case block would only break out of the select statement afaik. It acts the same as the implicit breaks at the end of each case block or like breaks in a C switch-statement. Or maybe that's only with go switches and not selects?
That's a good point. I think that when we exit the geth command there's a chance that
GetBlockByHash
won't find the parent block, potentially because the connection to the db has already closed (?). But I think adding a error here is a good idea, because if it happens any other time, it would mean something is wrong.My understanding is similar to what Ian said. If we just have a
break
without the named loop, it'll break from the current iteration through the select loop, so it would continue looping, and I don't think the go routine would be ended.It looks like named loops are used in several other places in the codebase, but I'd also be happy to change it to the implementation that @i-norden mentioned above, if that makes more sense.
Actually the more that I think about it, I'm not sure how/where an error would go and bubble up, since we're running the loop in a goroutine.
I wonder if we could follow a similar pattern as the previous for loop, using a named loop. So that if
parentBlock == nil
it will break from the for loop, and end the service.just a note for reference, the channel passed into the Subscription should "ample buffer space to avoid blocking other subscribers"
For the first test (
testErrorInChainEventLoop
) I think that this should return thesubErr
when the for loop gets to the third event - since the counter starts at 0 (for the first event), and then is incremented to 1 (for the second event). Not sure if this is the best way to illustrate this though, it's a bit confusing I think, so if you have any other ideas, I'd be happy to change it!I'm totally good with the named loop, just missed that omitting the name would only break out of the
select
statement (rather than thefor
loop, as desired)Sounds good - I trust your judgment. We can always watch for this statement in the logs, if nothing else
I missed that this was a test helper 🤦♂️
👍
Cool, yeah, I'm not entirely sure this is the best way to handle it, but I think that watching for this in the logs is great call.