Skip to content

Commit

Permalink
Add flag to enable / disable reaping of lookup tables
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirms committed Jul 1, 2024
1 parent 7060fdd commit cf80b06
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions services/horizon/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,14 @@ func Flags() (*Config, support.ConfigOptions) {
return nil
},
},
{

Check failure on line 690 in services/horizon/internal/flags.go

View workflow job for this annotation

GitHub Actions / golangci

missing type in composite literal (typecheck)
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,
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/ingest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type Config struct {
HistoryArchiveCaching bool

DisableStateVerification bool
EnableReapLookupTables bool
ReapLookupTables bool
EnableExtendedLogLedgerStats bool

MaxReingestRetries int
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/ingest/resume_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit cf80b06

Please sign in to comment.