Skip to content

Commit

Permalink
services/horizon: Improve error handling for when stellar-core crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
urvisavla committed Jun 5, 2023
1 parent 148bf79 commit 835eca7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ingest/ledgerbackend/captive_core_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,16 +572,16 @@ func (c *CaptiveStellarCore) checkMetaPipeResult(result metaResult, ok bool) err
return err
}
if !ok || result.err != nil {
if result.err != nil {
// Case 3 - Some error was encountered while consuming the ledger stream emitted by captive core.
return result.err
} else if exited, err := c.stellarCoreRunner.getProcessExitError(); exited {
if exited, err := c.stellarCoreRunner.getProcessExitError(); exited {
// Case 2 - The stellar core process exited unexpectedly
if err == nil {
return errors.Errorf("stellar core exited unexpectedly")
} else {
return errors.Wrap(err, "stellar core exited unexpectedly")
}
} else if result.err != nil {
// Case 3 - Some error was encountered while consuming the ledger stream emitted by captive core.
return result.err
} else if !ok {
// This case should never happen because the ledger buffer channel can only be closed
// if and only if the process exits or the context is canceled.
Expand Down
1 change: 1 addition & 0 deletions ingest/ledgerbackend/captive_core_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ func TestCaptiveGetLedger_ErrReadingMetaResult(t *testing.T) {
mockRunner.On("close").Return(nil).Run(func(args mock.Arguments) {
cancel()
}).Once()
mockRunner.On("getProcessExitError").Return(false, nil)

// even if the request to fetch the latest checkpoint succeeds, we should fail at creating the subprocess
mockArchive := &historyarchive.MockArchive{}
Expand Down

0 comments on commit 835eca7

Please sign in to comment.