# [FAQ] TiDB 查询 TIKV_REGION_STATUS 会报错 "RegionInfo.regions.written_bytes of type int64"

## Key Words

TiDB,Lightning,TiKV_REGION_STATUS,written_bytes,int64,int

## Description

在通过内存表查询 TIKV_REGION_STATUS 时候，会出现类似报错堆栈。场景例如 Lighting local-kend 模式导入或者直接访问内存表查询 Table 的 region 状态。

```text
[2022/11/09 17:01:33.765 +08:00] [INFO] [conn.go:793] ["command dispatched failed"] [conn=203853802] [connInfo="id:203853802, addr:10.1.68.201:41314 status:11, collation:utf8mb4_general_ci, user:root"] [command=Execute] [status="inTxn:1, autocommit:1"] [sql="SELECT REGION_ID, APPROXIMATE_SIZE FROM information_schema.TIKV_REGION_STATUS WHERE TABLE_ID = ? [arguments: 8535]"] [txn_mode=PESSIMISTIC] [err="json: cannot unmarshal number 18446744073709550099 into Go struct field RegionInfo.regions.written_bytes of type int64\ngithub.com/pingcap/errors.AddStack\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20201126102027-b0a155152ca3/errors.go:174\ngithub.com/pingcap/errors.Trace\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20201126102027-b0a155152ca3/juju_adaptor.go:15\ngithub.com/pingcap/tidb/store/helper.(*Helper).requestPD\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/store/helper/helper.go:643\ngithub.com/pingcap/tidb/store/helper.(*Helper).GetRegionsInfo\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/store/helper/helper.go:600\ngithub.com/pingcap/tidb/infoschema.dataForTiKVRegionStatus\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/infoschema/tables.go:1066\ngithub.com/pingcap/tidb/infoschema.(*infoschemaTable).getRows\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/infoschema/tables.go:1748\ngithub.com/pingcap/tidb/infoschema.(*infoschemaTable).IterRecords\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/infoschema/tables.go:1773\ngithub.com/pingcap/tidb/executor.(*TableScanExec).nextChunk4InfoSchema\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/executor/executor.go:1328\ngithub.com/pingcap/tidb/executor.(*TableScanExec).Next\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/executor/executor.go:1299\ngithub.com/pingcap/tidb/executor.Next\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/executor/executor.go:262\ngithub.com/pingcap/tidb/executor.(*SelectionExec).Next\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/executor/executor.go:1235\ngithub.com/pingcap/tidb/executor.Next\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/executor/executor.go:262\ngithub.com/pingcap/tidb/executor.(*projectionInputFetcher).run\n\t/home/jenkins/agent/workspace/tidb_v4.0.10/go/src/github.com/pingcap/tidb/executor/projection.go:373\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1357\nSELECT REGION_ID, APPROXIMATE_SIZE FROM information_schema.TIKV_REGION_STATUS WHERE TABLE_ID = ? [arguments: 8535]"]
```

## Content

v4.0.12 之前版本都有此 bug <https://github.com/pingcap/tidb/issues/25853，因为> PD 和 TiDB 设置 的 regioninfo 的 written_bytes 数据类型不统一。导致通过内存表查询 region status 会报错。所以推测如果单独在 v4.0.10 执行也会有同样的错误。所以建议确认一下 v4.0.10 线上环境是否可复现。另外 Lighting 在新版本会通过内存表检查 region 得相关信息数据，所以会触发这个问题。

## Affected Versions

<v4.0.12
