Skip to content

Commit

Permalink
More logging
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Broadhurst <[email protected]>
  • Loading branch information
peterbroadhurst committed Feb 13, 2024
1 parent 58daa9d commit 1e7b7ae
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/persistence/postgres/transaction_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type transactionWriter struct {

type transactionWriterBatch struct {
id string
opened time.Time
ops []*transactionOperation
timeoutContext context.Context
timeoutCancel func()
Expand Down Expand Up @@ -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++
Expand All @@ -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
}
Expand Down

0 comments on commit 1e7b7ae

Please sign in to comment.