diff --git a/ingest/ledgerbackend/captive_core_backend.go b/ingest/ledgerbackend/captive_core_backend.go index deb618cf20..9381b7c1f6 100644 --- a/ingest/ledgerbackend/captive_core_backend.go +++ b/ingest/ledgerbackend/captive_core_backend.go @@ -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. diff --git a/ingest/ledgerbackend/captive_core_backend_test.go b/ingest/ledgerbackend/captive_core_backend_test.go index 7de69db927..7da801d60f 100644 --- a/ingest/ledgerbackend/captive_core_backend_test.go +++ b/ingest/ledgerbackend/captive_core_backend_test.go @@ -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{}