From 1e7b7aefa2111053a471791b9605f64a7881ec83 Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Tue, 13 Feb 2024 20:03:18 +0000 Subject: [PATCH] More logging Signed-off-by: Peter Broadhurst --- internal/persistence/postgres/transaction_writer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/persistence/postgres/transaction_writer.go b/internal/persistence/postgres/transaction_writer.go index 72f1151..0099671 100644 --- a/internal/persistence/postgres/transaction_writer.go +++ b/internal/persistence/postgres/transaction_writer.go @@ -78,6 +78,7 @@ type transactionWriter struct { type transactionWriterBatch struct { id string + opened time.Time ops []*transactionOperation timeoutContext context.Context timeoutCancel func() @@ -207,7 +208,8 @@ func (tw *transactionWriter) worker(i int) { } if batch == nil { batch = &transactionWriterBatch{ - id: fmt.Sprintf("%.4d_%.9d", i, batchCount), + id: fmt.Sprintf("%.4d_%.9d", i, batchCount), + opened: time.Now(), } batch.timeoutContext, batch.timeoutCancel = context.WithTimeout(ctx, tw.batchTimeout) batchCount++ @@ -226,7 +228,7 @@ func (tw *transactionWriter) worker(i int) { if batch != nil && (timedOut || (len(batch.ops) >= tw.batchMaxSize)) { batch.timeoutCancel() - l.Debugf("Running batch %s (len=%d)", batch.id, len(batch.ops)) + l.Debugf("Running batch %s (len=%d,timeout=%t,age=%dms)", batch.id, len(batch.ops), timedOut, time.Since(batch.opened).Milliseconds()) tw.runBatch(ctx, batch) batch = nil }