TiDB在查询SQL时有现如下异常:
select o.account_id,sum(o.amount),sum(if(c.open_type = 1,o.amount,0)),sum(if(c.open_type = 1,1,0)),sum(if(c.open_type != 1,o.amount,0)),sum(if(c.open_type != 1,1,0)) from `order` o left join invoice i on i.order_id = o.id left join product p on i.product_id = p.id
left join channel c on c.id = o.channel_id where o.account_id = 134139663 and i.end_time >= '2019-06-07' and i.delivered_at >= '2019-05-05 13:01:48' and i.delivered_at < '2019-06-07' and p.cate =1 and i.status =1 and c.open_type in (1,2,3)
user_auto_charge_rate_all (1105, "inconsistent index order_93025c2f handle count 31 isn't equal to value count 30")
Traceback (most recent call last):
File "/data/www/audit_3a/app/renew/union/user_auto_charge_rate_all.py", line 342, in <module>
system_main(sys.argv)
File "/data/www/audit_3a/app/renew/union/user_auto_charge_rate_all.py", line 331, in system_main
cts.user_charge_rate(date_now,day_type)
File "/data/www/audit_3a/app/renew/union/user_auto_charge_rate_all.py", line 152, in user_charge_rate
cursor.execute(raw_sql_limit)
File "/opt/python/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "/opt/python/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1105, "inconsistent index order_93025c2f handle count 31 isn't equal to value count 30")
目前TiDB版本已经在上一个问题:[查询结果集少数据](http://www.itopers.com/article/230) 已经升级到最新版本3.0-rc2
TiDB写是从上游MySQL集群通过DM同步,其它操作TiDB集群的都为读操作。
提交issue地址:[https://github.com/pingcap/tidb/issues/10674](https://github.com/pingcap/tidb/issues/10674)后,PingCap团队很力,快速联系并收集相关信息,期间由于TiDB的日志不够全面,单独升级了TiDB-server。
最后确认为一个bug:[gc_worker: fix bug of saving gc safe point to pd before do distributed gc #10927](https://github.com/pingcap/tidb/pull/10927),触发原因是sql执行时间超了GC的时间(默认10分钟),导致读到索引数据后再去读数据行时,被GC掉了。临时解决,将gc周期时间改大,问题不再发生。
# GC的周期运行时间要大于最大事务的执行时间
update mysql.tidb set VARIABLE_VALUE = '3h' where VARIABLE_NAME = 'tikv_gc_run_interval';
如下是PingCAP开发的分析结论:
![PingCAP开发的分析结论](http://imgs.itopers.com/tidb_insis.png "PingCAP开发的分析结论")
文章最后更新时间:
2019年06月26日 15:27:02