-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exp/ingest/ledgerbackend: Handle Stellar-Core process exit gracefully #2803
exp/ingest/ledgerbackend: Handle Stellar-Core process exit gracefully #2803
Conversation
return | ||
case c.metaC <- metaResult{meta, nil}: | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified this code. There's no need to check c.stop
here because even we discard one result from metaC
in Close
to unblock it. So even if the code is waiting here, it will be unlocked by Close
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -271,6 +286,20 @@ func (c *CaptiveStellarCore) PrepareRange(ledgerRange Range) error { | |||
} | |||
|
|||
for { | |||
select { | |||
case <-c.shutdown: | |||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bartekn should we call c.Close()
here too before returning - is seem like sendLedgerMeta
could still be running on the goroutine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because c.shutdown
can be only closed by calling c.Close
. So it implies that c.Close
was called.
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
This commit adds a code that handles Stellar-Core process exit gracefully. Added
processExit
unbuffered channel tostellarCoreRunner
that receives the error in case Stellar-Core crashed or was terminated with an error or nil error if it was shutdown gracefully. The channel is later used inPrepareRange
that returns an error if the process was stopped while prepare was running and insendLedgerMeta
that adds error to a meta channel that will be read by one of the followingGetLedger
calls.Close #2705.
Why
Right now when Stellar-Core crashes,
CaptiveStellarCore
simply wait for the next ledger without restarting it.