pingcap / pingcap/tidb

Check the duration of the database transaction.

Open
#62,692 0 comments 0 reactions 0 assignees View on GitHub
contribution type/feature-request
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Feature Request

**Is your feature request related to a problem? Please describe:**

Some customers have database tasks that take a long time to execute, which may involve long transactions. They may need to adjust max-txn-ttl, but the lack of precise transaction execution time makes it difficult to reference empirical values.

**Describe the feature you'd like:**

Inquire about the specific execution time of the transaction.

**Describe alternatives you've considered:**

The simplest way is to print debug logs when the transaction is successfully committed, just like this.

```go

if !isInternalTxn {
logutil.Logger(ctx).Debug("commit success",
zap.Uint64("txnStartTS", s.GetSessionVars().TxnCtx.StartTS),
zap.Int("statementCount", counter),
zap.Duration("duration", time.Since(s.GetSessionVars().TxnCtx.CreateTime)))
}

```

**Teachability, Documentation, Adoption, Migration Strategy:**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.