Skip to content

Commit

Permalink
Remove --captive-core-reuse-storage-dir flag
Browse files Browse the repository at this point in the history
  • Loading branch information
erika-sdf committed Nov 5, 2021
1 parent fa20a49 commit c993dc1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 64 deletions.
4 changes: 0 additions & 4 deletions ingest/ledgerbackend/captive_core_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ type CaptiveCoreConfig struct {
// stored. We always append /captive-core to this directory, since we clean
// it up entirely on shutdown.
StoragePath string
// ReuseStoragePath determines if the storage dir in StoragePath should
// be reused between Stellar-Core executions. Defaults to false because of
// Stellar-Core 17.1.0 issue.
ReuseStoragePath bool
}

// NewCaptive returns a new CaptiveStellarCore instance.
Expand Down
21 changes: 9 additions & 12 deletions ingest/ledgerbackend/stellar_core_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ type stellarCoreRunner struct {
processExited bool
processExitError error

storagePath string
reuseStoragePath bool
nonce string
storagePath string
nonce string

log *log.Entry
}
Expand All @@ -83,7 +82,7 @@ func createRandomHexString(n int) string {

func newStellarCoreRunner(config CaptiveCoreConfig, mode stellarCoreRunnerMode) (*stellarCoreRunner, error) {
var fullStoragePath string
if runtime.GOOS == "windows" || mode == stellarCoreRunnerModeOffline || !config.ReuseStoragePath {
if runtime.GOOS == "windows" || mode == stellarCoreRunnerModeOffline {
// On Windows, first we ALWAYS append something to the base storage path,
// because we will delete the directory entirely when Horizon stops. We also
// add a random suffix in order to ensure that there aren't naming
Expand Down Expand Up @@ -119,12 +118,11 @@ func newStellarCoreRunner(config CaptiveCoreConfig, mode stellarCoreRunnerMode)
ctx, cancel := context.WithCancel(config.Context)

runner := &stellarCoreRunner{
executablePath: config.BinaryPath,
ctx: ctx,
cancel: cancel,
storagePath: fullStoragePath,
reuseStoragePath: config.ReuseStoragePath,
mode: mode,
executablePath: config.BinaryPath,
ctx: ctx,
cancel: cancel,
storagePath: fullStoragePath,
mode: mode,
nonce: fmt.Sprintf(
"captive-stellar-core-%x",
rand.New(rand.NewSource(time.Now().UnixNano())).Uint64(),
Expand Down Expand Up @@ -471,8 +469,7 @@ func (r *stellarCoreRunner) close() error {

if runtime.GOOS == "windows" ||
(r.processExitError != nil && r.processExitError != context.Canceled) ||
r.mode == stellarCoreRunnerModeOffline ||
!r.reuseStoragePath {
r.mode == stellarCoreRunnerModeOffline {
// It's impossible to send SIGINT on Windows so buckets can become
// corrupted. If we can't reuse it, then remove it.
// We also remove the storage path if there was an error terminating the
Expand Down
27 changes: 0 additions & 27 deletions ingest/ledgerbackend/stellar_core_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func TestCloseBeforeStartOnline(t *testing.T) {
Log: log.New(),
Context: context.Background(),
Toml: captiveCoreToml,
ReuseStoragePath: true,
}, stellarCoreRunnerModeOnline)
assert.NoError(t, err)

Expand All @@ -63,32 +62,6 @@ func TestCloseBeforeStartOnline(t *testing.T) {
assert.NoError(t, err)
}

func TestCloseBeforeStartOnlineReuseFlagFalse(t *testing.T) {
captiveCoreToml, err := NewCaptiveCoreToml(CaptiveCoreTomlParams{})
assert.NoError(t, err)

captiveCoreToml.AddExamplePubnetValidators()

runner, err := newStellarCoreRunner(CaptiveCoreConfig{
HistoryArchiveURLs: []string{"http://localhost"},
Log: log.New(),
Context: context.Background(),
Toml: captiveCoreToml,
ReuseStoragePath: false,
}, stellarCoreRunnerModeOnline)
assert.NoError(t, err)

tempDir := runner.storagePath
info, err := os.Stat(tempDir)
assert.NoError(t, err)
assert.True(t, info.IsDir())

assert.NoError(t, runner.close())

_, err = os.Stat(tempDir)
assert.Error(t, err)
}

func TestCloseBeforeStartOnlineWithError(t *testing.T) {
captiveCoreToml, err := NewCaptiveCoreToml(CaptiveCoreTomlParams{})
assert.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions services/horizon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).
### Changes

* Add an endpoint that allows querying for which liquidity pools an account is participating in
* Remove a feature flag `--captive-core-reuse-storage-dir` (`false` by default) that allows disabling permanent buckets directory of Captive Stellar-Core. This work around is no longer needed since the underlying bug has been fixed in 17.3.0. ([4048](https://github.com/stellar/go/pull/4048))

## v2.10.0

Expand Down
8 changes: 0 additions & 8 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,6 @@ func Flags() (*Config, support.ConfigOptions) {
Usage: "Storage location for Captive Core bucket data",
ConfigKey: &config.CaptiveCoreStoragePath,
},
&support.ConfigOption{
Name: "captive-core-reuse-storage-path",
OptType: types.Bool,
Required: false,
FlagDefault: false,
Usage: "determines if storage-path should be reused, disabled by default because of Stellar-Core 17.1.0 issue",
ConfigKey: &config.CaptiveCoreReuseStoragePath,
},
&support.ConfigOption{
Name: "captive-core-peer-port",
OptType: types.Uint,
Expand Down
20 changes: 9 additions & 11 deletions services/horizon/internal/ingest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,15 @@ const (
var log = logpkg.DefaultLogger.WithField("service", "ingest")

type Config struct {
CoreSession db.SessionInterface
StellarCoreURL string
StellarCoreCursor string
EnableCaptiveCore bool
CaptiveCoreBinaryPath string
CaptiveCoreStoragePath string
CaptiveCoreReuseStoragePath bool
CaptiveCoreToml *ledgerbackend.CaptiveCoreToml
RemoteCaptiveCoreURL string
NetworkPassphrase string
CoreSession db.SessionInterface
StellarCoreURL string
StellarCoreCursor string
EnableCaptiveCore bool
CaptiveCoreBinaryPath string
CaptiveCoreStoragePath string
CaptiveCoreToml *ledgerbackend.CaptiveCoreToml
RemoteCaptiveCoreURL string
NetworkPassphrase string

HistorySession db.SessionInterface
HistoryArchiveURL string
Expand Down Expand Up @@ -224,7 +223,6 @@ func NewSystem(config Config) (System, error) {
ledgerbackend.CaptiveCoreConfig{
BinaryPath: config.CaptiveCoreBinaryPath,
StoragePath: config.CaptiveCoreStoragePath,
ReuseStoragePath: config.CaptiveCoreReuseStoragePath,
Toml: config.CaptiveCoreToml,
NetworkPassphrase: config.NetworkPassphrase,
HistoryArchiveURLs: []string{config.HistoryArchiveURL},
Expand Down
1 change: 0 additions & 1 deletion services/horizon/internal/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func initIngester(app *App) {
StellarCoreCursor: app.config.CursorName,
CaptiveCoreBinaryPath: app.config.CaptiveCoreBinaryPath,
CaptiveCoreStoragePath: app.config.CaptiveCoreStoragePath,
CaptiveCoreReuseStoragePath: app.config.CaptiveCoreReuseStoragePath,
CaptiveCoreToml: app.config.CaptiveCoreToml,
RemoteCaptiveCoreURL: app.config.RemoteCaptiveCoreURL,
EnableCaptiveCore: app.config.EnableCaptiveCoreIngestion,
Expand Down
1 change: 0 additions & 1 deletion services/horizon/internal/integration/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
)

var defaultCaptiveCoreParameters = map[string]string{
"captive-core-reuse-storage-path": "true",
horizon.StellarCoreBinaryPathName: os.Getenv("CAPTIVE_CORE_BIN"),
horizon.StellarCoreURLFlagName: "",
horizon.StellarCoreDBURLFlagName: "",
Expand Down

0 comments on commit c993dc1

Please sign in to comment.