Skip to content

Commit

Permalink
services/horizon: Apply and check migrations on ingesting instances o…
Browse files Browse the repository at this point in the history
…nly (#3586)

This commit reverts 7c92b23 and changes the DB migrations behaviour to only
trigger on ingesting instances.

When checking if there are any migrations required Horizon calls
`migrate.PlanMigration` which sends `CREATE TABLE gorp_migrations`. This write
query is forbidden when using read only database (like replica).

The new flag in 7c92b23 added unnecessary complexity. Ingesting instances are
guaranteed to have write access to a DB.

Thanks @jacekn for the idea!
  • Loading branch information
bartekn committed May 5, 2021
1 parent 4f8deb9 commit bda15c0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,17 @@ func ApplyFlags(config *Config, flags support.ConfigOptions) {
flags.Require()
flags.SetValues()

if config.ApplyMigrations {
applyMigrations(*config)
}

// Migrations should be checked as early as possible
checkMigrations(*config)

// Validate options that should be provided together
validateBothOrNeither("tls-cert", "tls-key")

if config.Ingest {
// Migrations should be checked as early as possible. Apply and check
// only on ingesting instances which are required to have write-access
// to the DB.
if config.ApplyMigrations {
applyMigrations(*config)
}
checkMigrations(*config)

// config.HistoryArchiveURLs contains a single empty value when empty so using
// viper.GetString is easier.
Expand Down

0 comments on commit bda15c0

Please sign in to comment.