TiFlash Handling ROUND Function Error

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tiflash 处理ROUND函数报错

| username: TiDBer_Ok0TdPp0

[TiDB Usage Environment] Testing
[TiDB Version] v7.1.1
[Reproduction Path] Error occurs when performing ROUND on Decimal type data query results. Using tiflash.
[Problem Encountered: Phenomenon and Impact] As long as there is a ROUND operation on Decimal type data query results in the query SQL, an error occurs when using tiflash. No error occurs when using tikv. How to solve this?
[Resource Configuration] Compatibility issue unrelated to resource configuration
[Attachment: Screenshot/Log/Monitoring]

| username: Billmay表妹 | Original post link

Is it this BUG?

| username: 江湖故人 | Original post link

How about rebuilding the TiFlash replica of the related table:
ALTER TABLE t1 SET TIFLASH REPLICA 0;
ALTER TABLE t1 SET TIFLASH REPLICA 1;

| username: xfworld | Original post link

It must be a bug.

| username: zhanggame1 | Original post link

Is the bug still not fixed?

| username: TiDBer_Ok0TdPp0 | Original post link

I haven’t tried rebuilding yet. Is there a bug where precision is lost when TiKV synchronizes to TiFlash? There’s an issue with the round function in the select statement:

| username: TiDBer_Ok0TdPp0 | Original post link

How did you handle it?

| username: TiDBer_Ok0TdPp0 | Original post link

It still doesn’t work. Rebuilt the synchronization. There’s a bug involving Decimal and double type operations.

| username: oceanzhang | Original post link

This is definitely a bug, upgrade the version.

| username: zhaokede | Original post link

Upgrading is a major operation, everyone is thinking about not upgrading to see if there is a way to solve it.

| username: TiDBer_Ok0TdPp0 | Original post link

Brother, I’m currently using 7.1. Will upgrading to 7.5 solve the problem?

| username: Kongdom | Original post link

First round, then wrap it with a layer of sum, or directly use TiKV?

| username: TiDBer_Ok0TdPp0 | Original post link

There is no problem with using KV, but the speed is not as fast as TFlash.

| username: TIDB-Learner | Original post link

I encountered the same issue. Has it been fixed in v7.5.0?

| username: TiDBer_Ok0TdPp0 | Original post link

I don’t know, I also used it in production. It’s hard to upgrade. And I don’t know if it has been fixed.

| username: heiwandou | Original post link

It’s a product bug, upgrade it.

| username: TiDBer_Ok0TdPp0 | Original post link

Has the latest version been fixed?

| username: TiDBer_yyy | Original post link

It seems that version 7.1.0 works, you can give it a try. Our company encountered this error when testing version 7.1.1 before upgrading.

| username: 连连看db | Original post link

Replace the round function with another function.

| username: Billmay表妹 | Original post link

This issue is being tracked:

https://github.com/pingcap/tidb/issues/45805

Related post: select single table error SQL error [1105] [HY000]: runtime error: index out of range [0] with length 0

This bug has been fixed in version 7.1.2. Minor version upgrades are generally not problematic, you can try upgrading to 7.1.3.