From c993dc19e3264273121150cf2e9b431ab3c5d218 Mon Sep 17 00:00:00 2001 From: erika-sdf Date: Thu, 4 Nov 2021 17:49:51 -0700 Subject: [PATCH] Remove --captive-core-reuse-storage-dir flag --- ingest/ledgerbackend/captive_core_backend.go | 4 --- ingest/ledgerbackend/stellar_core_runner.go | 21 +++++++-------- .../ledgerbackend/stellar_core_runner_test.go | 27 ------------------- services/horizon/CHANGELOG.md | 1 + services/horizon/internal/flags.go | 8 ------ services/horizon/internal/ingest/main.go | 20 +++++++------- services/horizon/internal/init.go | 1 - .../internal/integration/parameters_test.go | 1 - 8 files changed, 19 insertions(+), 64 deletions(-) diff --git a/ingest/ledgerbackend/captive_core_backend.go b/ingest/ledgerbackend/captive_core_backend.go index 00f5ea3416..b51f1c3d64 100644 --- a/ingest/ledgerbackend/captive_core_backend.go +++ b/ingest/ledgerbackend/captive_core_backend.go @@ -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. diff --git a/ingest/ledgerbackend/stellar_core_runner.go b/ingest/ledgerbackend/stellar_core_runner.go index ef1dd30058..df9d8fc271 100644 --- a/ingest/ledgerbackend/stellar_core_runner.go +++ b/ingest/ledgerbackend/stellar_core_runner.go @@ -65,9 +65,8 @@ type stellarCoreRunner struct { processExited bool processExitError error - storagePath string - reuseStoragePath bool - nonce string + storagePath string + nonce string log *log.Entry } @@ -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 @@ -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(), @@ -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 diff --git a/ingest/ledgerbackend/stellar_core_runner_test.go b/ingest/ledgerbackend/stellar_core_runner_test.go index 55348aefc5..18e6b0656a 100644 --- a/ingest/ledgerbackend/stellar_core_runner_test.go +++ b/ingest/ledgerbackend/stellar_core_runner_test.go @@ -47,7 +47,6 @@ func TestCloseBeforeStartOnline(t *testing.T) { Log: log.New(), Context: context.Background(), Toml: captiveCoreToml, - ReuseStoragePath: true, }, stellarCoreRunnerModeOnline) assert.NoError(t, err) @@ -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) diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index c75abbdff8..460d7c7980 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -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 diff --git a/services/horizon/internal/flags.go b/services/horizon/internal/flags.go index 6387166be1..4c6fdf7675 100644 --- a/services/horizon/internal/flags.go +++ b/services/horizon/internal/flags.go @@ -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, diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index b321d6512b..f775b089d7 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -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 @@ -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}, diff --git a/services/horizon/internal/init.go b/services/horizon/internal/init.go index ef791e8441..2bbbadf091 100644 --- a/services/horizon/internal/init.go +++ b/services/horizon/internal/init.go @@ -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, diff --git a/services/horizon/internal/integration/parameters_test.go b/services/horizon/internal/integration/parameters_test.go index 65beaa1025..204cd8bd86 100644 --- a/services/horizon/internal/integration/parameters_test.go +++ b/services/horizon/internal/integration/parameters_test.go @@ -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: "",