Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix harmonydb metrics #13

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL=/usr/bin/env bash

GOCC?=go

FFI_PATH:=extern/filecoin-ffi/
Expand Down Expand Up @@ -104,4 +106,4 @@ dist-clean:
# TODO API GEN
# TODO DOCS GEN

# TODO DEVNET IMAGES
# TODO DEVNET IMAGES
15 changes: 8 additions & 7 deletions harmony/harmonydb/harmonydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/yugabyte/pgx/v5/pgxpool"
"golang.org/x/xerrors"

lotusdb "github.com/filecoin-project/lotus/lib/harmony/harmonydb"
"github.com/filecoin-project/lotus/node/config"
)

Expand Down Expand Up @@ -104,7 +105,7 @@ func New(hosts []string, username, password, database, port string, itestID ITes

cfg.ConnConfig.OnNotice = func(conn *pgconn.PgConn, n *pgconn.Notice) {
logger.Debug("database notice: " + n.Message + ": " + n.Detail)
DBMeasures.Errors.M(1)
lotusdb.DBMeasures.Errors.M(1)
}

db := DB{cfg: cfg, schema: schema, hostnames: hosts} // pgx populated in AddStatsAndConnect
Expand All @@ -127,12 +128,12 @@ func (t tracer) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.Tr
return context.WithValue(context.WithValue(ctx, SQL_START, time.Now()), SQL_STRING, data.SQL)
}
func (t tracer) TraceQueryEnd(ctx context.Context, conn *pgx.Conn, data pgx.TraceQueryEndData) {
DBMeasures.Hits.M(1)
lotusdb.DBMeasures.Hits.M(1)
ms := time.Since(ctx.Value(SQL_START).(time.Time)).Milliseconds()
DBMeasures.TotalWait.M(ms)
DBMeasures.Waits.Observe(float64(ms))
lotusdb.DBMeasures.TotalWait.M(ms)
lotusdb.DBMeasures.Waits.Observe(float64(ms))
if data.Err != nil {
DBMeasures.Errors.M(1)
lotusdb.DBMeasures.Errors.M(1)
}
logger.Debugw("SQL run",
"query", ctx.Value(SQL_STRING).(string),
Expand Down Expand Up @@ -166,8 +167,8 @@ func (db *DB) addStatsAndConnect() error {
}
db.cfg.AfterConnect = func(ctx context.Context, c *pgx.Conn) error {
s := db.pgx.Stat()
DBMeasures.OpenConnections.M(int64(s.TotalConns()))
DBMeasures.WhichHost.Observe(hostnameToIndex[c.Config().Host])
lotusdb.DBMeasures.OpenConnections.M(int64(s.TotalConns()))
lotusdb.DBMeasures.WhichHost.Observe(hostnameToIndex[c.Config().Host])

//FUTURE place for any connection seasoning
return nil
Expand Down
77 changes: 0 additions & 77 deletions harmony/harmonydb/metrics.go

This file was deleted.

2 changes: 1 addition & 1 deletion harmony/harmonytask/harmonytask.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func New(
// edge-case: if old assignments are not available tasks, unlock them.
h := e.taskMap[w.Name]
if h == nil {
_, err := db.Exec(e.ctx, `UPDATE harmony_task SET owner=NULL WHERE id=$1`, w.ID)
_, err := db.Exec(e.ctx, `UPDATE harmony_task SET owner_id=NULL WHERE id=$1`, w.ID)
if err != nil {
log.Errorw("Cannot remove self from owner field", "error", err)
continue // not really fatal, but not great
Expand Down