'TDengine data loss issue
The issue is as follows, there are two clients
client 1:
taos> create table stb(ts timestamp, c1 int, c2 float) tags(t1 int);
Query OK, 0 of 0 row(s) in database (0.002777s)
taos> insert into t1 using stb tags(1) values(now, 1, 1.2);
Query OK, 1 of 1 row(s) in database (0.011575s)
taos> select * from stb;
ts | c1 | c2 | t1 |
=============================================================================
2021-09-29 23:07:03.665 | 1 | 1.20000 | 1 |
Query OK, 1 row(s) in set (0.002033s)
client 2:
taos> select * from stb;
ts | c1 | c2 | t1 |
=============================================================================
2021-09-29 23:07:03.665 | 1 | 1.20000 | 1 |
Query OK, 1 row(s) in set (0.002254s)
Everything looks good for now, but after following steps
client 1:
taos> alter table stb drop column c2;
Query OK, 0 of 0 row(s) in database (0.004846s)
taos> alter table stb add column c2 double;
Query OK, 0 of 0 row(s) in database (0.003483s)
client 2:
taos> insert into t1 values(now, 2, 2.2);
Query OK, 1 of 1 row(s) in database (0.001591s)
Now execute below query in both clients:
client 1:
taos> select * from t1;
ts | c1 | c2 |
====================================================================
2021-09-29 23:07:03.665 | 1 | NULL |
2021-09-29 23:09:37.872 | 2 | NULL |
Query OK, 2 row(s) in set (0.002334s)
client 2:
taos> select * from t1;
ts | c1 | c2 |
====================================================================
2021-09-29 23:07:03.665 | 1 | 1.200000000 |
2021-09-29 23:09:37.872 | 2 | 2.200000000 |
Query OK, 2 row(s) in set (0.002121s)
Why the same query in different clients has different results? Is there a data loss issue in this scenario?
Solution 1:[1]
Quick answer for this question is yes since there is a known TDengine design issue in TDengine 2.x. So it is not recommended for user to delete a float column and add back a double column with the same name.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Xiao Ping |