diff --git a/services/horizon/internal/config.go b/services/horizon/internal/config.go index 3414b1aaea..b0e1ecb9df 100644 --- a/services/horizon/internal/config.go +++ b/services/horizon/internal/config.go @@ -85,6 +85,8 @@ type Config struct { // If ReapFrequency is set to 2 history is reaped after ingesting every two ledgers. // etc... ReapFrequency uint + // ReapLookupTables enables the reaping of history lookup tables + ReapLookupTables bool // StaleThreshold represents the number of ledgers a history database may be // out-of-date by before horizon begins to respond with an error to history // requests. diff --git a/services/horizon/internal/flags.go b/services/horizon/internal/flags.go index 7321d07fb2..9930fee69f 100644 --- a/services/horizon/internal/flags.go +++ b/services/horizon/internal/flags.go @@ -687,6 +687,14 @@ func Flags() (*Config, support.ConfigOptions) { return nil }, }, + { + Name: "reap-lookup-tables", + ConfigKey: &config.ReapLookupTables, + OptType: types.Bool, + FlagDefault: true, + Usage: "enables the reaping of history lookup tables.", + UsedInCommands: IngestionCommands, + }, &support.ConfigOption{ Name: "history-stale-threshold", ConfigKey: &config.StaleThreshold, diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index 5bff414ac3..650a08b426 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -95,7 +95,7 @@ type Config struct { HistoryArchiveCaching bool DisableStateVerification bool - EnableReapLookupTables bool + ReapLookupTables bool EnableExtendedLogLedgerStats bool MaxReingestRetries int @@ -757,7 +757,7 @@ func (s *system) maybeVerifyState(lastIngestedLedger uint32, expectedBucketListH } func (s *system) maybeReapLookupTables(lastIngestedLedger uint32) { - if !s.config.EnableReapLookupTables { + if !s.config.ReapLookupTables { return } diff --git a/services/horizon/internal/ingest/resume_state_test.go b/services/horizon/internal/ingest/resume_state_test.go index 5167eb195a..feb5e13bb0 100644 --- a/services/horizon/internal/ingest/resume_state_test.go +++ b/services/horizon/internal/ingest/resume_state_test.go @@ -402,9 +402,9 @@ func (s *ResumeTestTestSuite) TestReapingObjectsDisabled() { } func (s *ResumeTestTestSuite) TestErrorReapingObjectsIgnored() { - s.system.config.EnableReapLookupTables = true + s.system.config.ReapLookupTables = true defer func() { - s.system.config.EnableReapLookupTables = false + s.system.config.ReapLookupTables = false }() s.historyQ.On("Begin", s.ctx).Return(nil).Once() s.historyQ.On("GetLastLedgerIngest", s.ctx).Return(uint32(100), nil).Once() diff --git a/services/horizon/internal/init.go b/services/horizon/internal/init.go index 137ff26aff..c245970117 100644 --- a/services/horizon/internal/init.go +++ b/services/horizon/internal/init.go @@ -99,7 +99,7 @@ func initIngester(app *App) { DisableStateVerification: app.config.IngestDisableStateVerification, StateVerificationCheckpointFrequency: uint32(app.config.IngestStateVerificationCheckpointFrequency), StateVerificationTimeout: app.config.IngestStateVerificationTimeout, - EnableReapLookupTables: app.config.HistoryRetentionCount > 0, + ReapLookupTables: app.config.ReapLookupTables && app.config.HistoryRetentionCount > 0, EnableExtendedLogLedgerStats: app.config.IngestEnableExtendedLogLedgerStats, RoundingSlippageFilter: app.config.RoundingSlippageFilter, SkipTxmeta: app.config.SkipTxmeta,