# [Know Issue] auto analyze 持续失败

## Key Words

TiDB, auto analyze

## Description

TiDB server 日志显示有一张表的 auto analyze 失败，并且报错内容包含 "[tikv:9006]GC life time is shorter than transaction duration"，详细的日志信息：

```log
[2022/09/27 06:13:59.587 +00:00] [ERROR] [update.go:1191] ["[stats] auto analyze failed"] [sql="analyze table `message`.`Message`"] [cost_time=19m59.855372293s] [error="[tikv:9006]GC life time is shorter than transaction duration, transaction starts at 2022-09-27 05:53:59.686 +0000 UTC, GC safe point is 2022-09-27 06:03:43.686 +0000 UTC"] @timestamp:Sep 27, 2022 @ 14:13:59.587 container_name:tidb kubernetes.namespace:tidbxxxxxxxxxx user_cluster_id:xxxxxxxxxxxxxx user_cluster_env:shoot/aws/us-east-1/shoot--prod--xxxxx level:ERROR log_file:tidb.log host_name:ip-xxx-xxx-xxx-xxx.ec2.internal stream:stdout instance:db-tidb-1 component:tidb _id:xxxxxxxxxxx _type:_doc _index:xxxxxx-tidb-2022.09.27 _score: -
```

## Root Cause

TiDB 在处理内部事务时，不会 block gc safepoint 的推进。这就会产生一个问题，如果 auto analyze （属于内部事务）持续时间较长超过 tidb_gc_life_time，那么 auto analyze 就会失败。

## Diagnostic Steps

N/A

## Resolution

升级到 v6.2.0 及以上版本（v6.1.0 的 fix 会引入新的 bug）

## Workaround

1. 手工执行在业务低峰期执行 analyze;
2. 添加合适的索引加速 analyze;
3. 使用 INCREMENTAL analyze;
4. 使用 fast analyze（实验特性不推荐）;

## Affected Versions

v5.2.0 ~ v6.1.0
