From 74a6febb3750b854635d9c5731cb632feab49551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 26 Jan 2024 20:12:49 -0500 Subject: [PATCH] DEBUG --- internal/server/db/query/transaction.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/server/db/query/transaction.go b/internal/server/db/query/transaction.go index 483a39d1465..7549329b78b 100644 --- a/internal/server/db/query/transaction.go +++ b/internal/server/db/query/transaction.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "fmt" + "runtime" "strings" "time" @@ -12,6 +13,17 @@ import ( // Transaction executes the given function within a database transaction with a 10s context timeout. func Transaction(ctx context.Context, db *sql.DB, f func(context.Context, *sql.Tx) error) error { + _, file, no, ok := runtime.Caller(2) + if ok && strings.HasSuffix(file, "retry.go") { + _, file, no, ok = runtime.Caller(5) + } + var caller string + if ok { + caller = fmt.Sprintf("%s:%d", file, no) + } + start := time.Now() + defer func() { logger.Errorf("DBTRANS: took %dms (from %s)", time.Now().Sub(start).Milliseconds(), caller) }() + ctx, cancel := context.WithTimeout(ctx, time.Second*10) defer cancel()