Skip to content

Commit

Permalink
services/horizon: Fix DB metrics when replica enabled (#3668)
Browse files Browse the repository at this point in the history
This commit fixes the duplicate metrics in `db.Session` that prevents Horizon
from starting.

An attempt to run Horizon with read replica middleware results in an error:

panic: duplicate metrics collector registration attempted
  • Loading branch information
bartekn authored Jun 7, 2021
1 parent 1a050fd commit 2ca3f84
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
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/).
### Code Changes

* Fix bug in `horizon db reingest range` command, which would throw a duplicate entry conflict error from the DB. ([3661](https://github.com/stellar/go/pull/3661)).
* Fix bug in DB metrics preventing Horizon from starting when read-only replica middleware is enabled. ([3668](https://github.com/stellar/go/pull/3668)).

## v2.4.0

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 @@ -62,7 +62,7 @@ func mustInitHorizonDB(app *App) {
)}

app.primaryHistoryQ = &history.Q{mustNewDBSession(
db.HistorySubservice,
db.HistoryPrimarySubservice,
app.config.DatabaseURL,
maxIdle,
maxOpen,
Expand Down
1 change: 1 addition & 0 deletions support/db/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var QueryTypeContextKey = CtxKey("query_type")
type Subservice string

var CoreSubservice = Subservice("core")
var HistoryPrimarySubservice = Subservice("history_primary")
var HistorySubservice = Subservice("history")
var IngestSubservice = Subservice("ingest")

Expand Down

0 comments on commit 2ca3f84

Please sign in to comment.