From 5262a9e07b69c9aa858ac3651283facacf9b0c84 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 21 Jul 2022 11:41:18 +0800 Subject: [PATCH] test: add case to reproduce deadlock --- tests/script/tsim/parser/function.sim | 218 ++++++-------------------- 1 file changed, 46 insertions(+), 172 deletions(-) diff --git a/tests/script/tsim/parser/function.sim b/tests/script/tsim/parser/function.sim index 1b13a7f1fd..7dd66bedb0 100644 --- a/tests/script/tsim/parser/function.sim +++ b/tests/script/tsim/parser/function.sim @@ -277,6 +277,8 @@ print =============================> TD-6086 sql create stable td6086st(ts timestamp, d double) tags(t nchar(50)); sql create table td6086ct1 using td6086st tags("ct1"); sql create table td6086ct2 using td6086st tags("ct2"); + +return sql SELECT LAST(d),t FROM td6086st WHERE tbname in ('td6086ct1', 'td6086ct2') and ts>="2019-07-30 00:00:00" and ts<="2021-08-31 00:00:00" partition BY tbname interval(1800s) fill(prev); print ==================> td-2624 @@ -291,41 +293,35 @@ sql insert into tm2 values('2020-12-29 18:43:17.129', 0, null); sql insert into tm2 values('2020-12-29 18:46:19.109', NULL, null); sql insert into tm2 values('2021-01-03 18:40:40.065', 0, null); +sql select _wstart, twa(k),first(ts) from tm2 where k <50 interval(17s); +if $rows != 6 then + return -1 +endi +if $data00 != @11-01-02 18:42:42.000@ then + return -1 +endi +if $data02 != @11-01-02 18:42:45.326@ then + return -1 +endi +if $data10 != @20-07-30 17:43:59.000@ then + return -1 +endi +if $data21 != 0.000000000 then + return -1 +endi + sql select twa(k),first(ts) from tm2 where k <50 interval(17s); if $rows != 6 then return -1 endi -if $data00 != @11-01-02 18:42:42.000@ then - return -1 -endi - -if $data02 != @11-01-02 18:42:45.326@ then - return -1 -endi - -if $data10 != @20-07-30 17:43:59.000@ then - return -1 -endi - -if $data21 != 0.000000000 then - return -1 -endi - -sql select twa(k),first(ts) from tm2 where k <50 interval(17s) order by ts desc; -if $rows != 6 then - return -1 -endi - -sql select twa(k),first(ts),count(k),first(k) from tm2 interval(17s) limit 20 offset 0; +sql select _wstart, twa(k),first(ts),count(k),first(k) from tm2 interval(17s) limit 20 offset 0; if $rows != 9 then return -1 endi - if $data00 != @11-01-02 18:42:42.000@ then return -1 endi - if $data10 != @20-07-30 17:43:59.000@ then return -1 endi @@ -336,9 +332,11 @@ if $rows != 0 then print expect 0, actual:$rows return -1 endi - sql select twa(k) from tm2 where ts='2020-12-29 18:46:19.109' -if $rows != 0 then +if $rows != 1 then + return -1 +endi +if $data00 != NULL then return -1 endi @@ -386,7 +384,7 @@ sql insert into tm10 values('2020-1-1 1:1:1', 0); sql insert into tm11 values('2020-1-5 1:1:1', 0); sql insert into tm12 values('2020-1-7 1:1:1', 0); sql insert into tm13 values('2020-1-1 1:1:1', 0); -sql select count(*) from m1 where ts='2020-1-1 1:1:1' interval(1h) group by tbname; +sql select count(*) from m1 where ts='2020-1-1 1:1:1' partition by tbname interval(1h) if $rows != 2 then return -1 endi @@ -399,11 +397,11 @@ sql create table tm1 using m1 tags(1); sql create table tm2 using m1 tags(2); sql insert into tm1 values('2021-01-27 22:22:39.294', 1, 10, NULL, 110, 123) ('2021-01-27 22:22:40.294', 2, 20, NULL, 120, 124) ('2021-01-27 22:22:41.294', 3, 30, NULL, 130, 125)('2021-01-27 22:22:43.294', 4, 40, NULL, 140, 126)('2021-01-27 22:22:44.294', 5, 50, NULL, 150, 127); sql insert into tm2 values('2021-01-27 22:22:40.688', 5, 101, NULL, 210, 321) ('2021-01-27 22:22:41.688', 5, 102, NULL, 220, 322) ('2021-01-27 22:22:42.688', 5, 103, NULL, 230, 323)('2021-01-27 22:22:43.688', 5, 104, NULL, 240, 324)('2021-01-27 22:22:44.688', 5, 105, NULL, 250, 325)('2021-01-27 22:22:45.688', 5, 106, NULL, 260, 326); + sql select stddev(k) from m1 if $rows != 1 then return -1 endi - if $data00 != 1.378704626 then return -1 endi @@ -417,11 +415,9 @@ sql select stddev(k), stddev(c) from m1 if $rows != 1 then return -1 endi - if $data00 != 1.378704626 then return -1 endi - if $data01 != NULL then return -1; endi @@ -430,90 +426,72 @@ sql select stddev(b),stddev(b),stddev(k) from m1; if $rows != 1 then return -1 endi - if $data00 != 37.840465463 then return -1 endi - if $data01 != 37.840465463 then return -1 endi - if $data02 != 1.378704626 then return -1 endi -sql select stddev(k), stddev(b) from m1 group by a +sql select stddev(k), stddev(b), a from m1 group by a order by a if $rows != 2 then return -1 endi - if $data00 != 1.414213562 then return -1 endi - if $data01 != 14.142135624 then return -1 endi - if $data02 != 1 then return -1 endi - if $data10 != 0.000000000 then return -1 endi - if $data11 != 1.707825128 then return -1 endi - if $data12 != 2 then return -1 endi -sql select stddev(k), stddev(b) from m1 where a= 1 group by a +sql select stddev(k), stddev(b), a from m1 where a= 1 group by a if $rows != 1 then return -1 endi - if $data00 != 1.414213562 then return -1 endi - if $data01 != 14.142135624 then return -1 endi - if $data02 != 1 then return -1 endi -sql select stddev(k), stddev(b) from m1 group by tbname +sql select stddev(k), stddev(b), tbname from m1 group by tbname order by tbname if $rows != 2 then return -1 endi - if $data00 != 1.414213562 then return -1 endi - if $data01 != 14.142135624 then return -1 endi - if $data02 != @tm1@ then return -1 endi - if $data10 != 0.000000000 then return -1 endi - if $data11 != 1.707825128 then return -1 endi - if $data12 != @tm2@ then return -1 endi @@ -523,240 +501,190 @@ if $rows != 2 then return -1 endi -sql select stddev(k), stddev(b), stddev(c) from m1 group by tbname,a +sql select stddev(k), stddev(b), stddev(c),tbname, a from m1 group by tbname,a if $rows != 2 then return -1 endi - if $data00 != 1.414213562 then return -1 endi - if $data01 != 14.142135624 then return -1 endi - if $data02 != NULL then return -1 endi - if $data03 != @tm1@ then return -1 endi - if $data04 != 1 then return -1 endi - if $data10 != 0.000000000 then return -1 endi - if $data11 != 1.707825128 then return -1 endi - if $data12 != NULL then return -1 endi - if $data13 != @tm2@ then return -1 endi - if $data14 != 2 then return -1 endi -sql select stddev(k), stddev(b), stddev(c) from m1 interval(10s) group by tbname,a +sql select _wstart, stddev(k), stddev(b), stddev(c), tbname,a from m1 partition by tbname, a interval(10s) order by tbname if $rows != 3 then return -1 endi - if $data01 != 0.000000000 then return -1 endi - if $data02 != 0.000000000 then return -1 endi - if $data03 != NULL then return -1 endi - if $data04 != @tm1@ then return -1 endi - if $data05 != 1 then return -1 endi - if $data11 != 1.118033989 then return -1 endi - if $data12 != 11.180339887 then return -1 endi - if $data13 != NULL then return -1 endi - if $data14 != @tm1@ then return -1 endi - if $data22 != 1.707825128 then return -1 endi - if $data23 != NULL then return -1 endi - if $data24 != @tm2@ then return -1 endi - if $data25 != 2 then return -1 endi -sql select count(*), first(b), stddev(b), stddev(c) from m1 interval(10s) group by a +sql select _wstart, count(*), first(b), stddev(b), stddev(c), a from m1 partition by a interval(10s) order by a if $rows != 3 then return -1 endi - if $data00 != @21-01-27 22:22:30.000@ then return -1 endi - if $data01 != 1 then return -1 endi - if $data02 != 10.000000000 then return -1 endi - if $data03 != 0.000000000 then return -1 endi - if $data04 != NULL then return -1 endi - if $data05 != 1 then return -1 endi - if $data12 != 20.000000000 then return -1 endi - if $data13 != 11.180339887 then return -1 endi - if $data14 != NULL then return -1 endi - if $data23 != 1.707825128 then return -1 endi -sql select count(*), first(b), stddev(b), stddev(c) from m1 interval(10s) group by tbname,a +sql select _wstart, count(*), first(b), stddev(b), stddev(c), tbname, a from m1 partition by tbname, a interval(10s) order by tbname if $rows != 3 then return -1 endi - if $data23 != 1.707825128 then return -1 endi - if $data25 != @tm2@ then return -1 endi -sql select count(*), stddev(b), stddev(b)+20, stddev(c) from m1 interval(10s) group by tbname,a +sql select _wstart, count(*), stddev(b), stddev(b)+20, stddev(c), tbname, a from m1 partition by tbname, a interval(10s) order by tbname if $rows != 3 then return -1 endi - if $data02 != 0.000000000 then return -1 endi - if $data03 != 20.000000000 then return -1 endi - if $data13 != 31.180339887 then return -1 endi - if $data14 != NULL then return -1 endi -sql select count(*), first(b), stddev(b)+first(b), stddev(c) from m1 interval(10s) group by tbname,a +sql select _wstart, count(*), first(b), stddev(b)+first(b), stddev(c), tbname, a from m1 partition by tbname, a interval(10s) order by tbname if $rows != 3 then return -1 endi - if $data02 != 10.000000000 then return -1 endi - if $data03 != 10.000000000 then return -1 endi - if $data12 != 20.000000000 then return -1 endi - if $data13 != 31.180339887 then return -1 endi - if $data22 != 101.000000000 then return -1 endi - if $data23 != 102.707825128 then return -1 endi -sql select stddev(e),stddev(k) from m1 where a=1 +sql select stddev(e), stddev(k) from m1 where a=1 if $rows != 1 then return -1 endi - if $data00 != 1.414213562 then return -1 endi - if $data01 != 1.414213562 then return -1 endi sql create stable st1 (ts timestamp, f1 int, f2 int) tags (id int); sql create table tb1 using st1 tags(1); - sql insert into tb1 values ('2021-07-02 00:00:00', 1, 1); sql select stddev(f1) from st1 group by f1; - if $rows != 1 then return -1 endi - if $data00 != 0.000000000 then return -1 endi @@ -765,7 +693,6 @@ sql select count(tbname) from st1 if $rows != 1 then return -1 endi - if $data00 != 1 then return -1 endi @@ -774,23 +701,20 @@ sql select count(id) from st1 if $rows != 1 then return -1 endi - if $data00 != 1 then return -1 endi print ====================> TODO stddev + normal column filter - print ====================> irate -sql_error select irate(f1) from st1; +sql select irate(f1) from st1; sql select irate(f1) from st1 group by tbname; sql select irate(k) from t1 if $rows != 1 then return -1 endi - if $data00 != 0.000027778 then return -1 endi @@ -799,104 +723,84 @@ sql select irate(k) from t1 where ts>='2015-8-18 00:30:00.000' if $rows != 1 then return -1 endi - if $data00 != 0.000000000 then print expect 0.000000000, actual $data00 return -1 endi -sql select irate(k) from t1 where ts>='2015-8-18 00:06:00.000' and ts<='2015-8-18 00:12:000'; +sql select irate(k) from t1 where ts>='2015-8-18 00:06:00.000' and ts<='2015-8-18 00:12:00.000'; if $rows != 1 then return -1 endi - if $data00 != 0.005633334 then return -1 endi -sql select irate(k) from t1 interval(10a) +sql select _wstart, irate(k) from t1 interval(10a) if $rows != 6 then return -1 endi - if $data01 != 0.000000000 then return -1 endi - if $data11 != 0.000000000 then return -1 endi - if $data51 != 0.000000000 then return -1 endi -sql select count(*),irate(k) from t1 interval(10m) +sql select _wstart, count(*), irate(k) from t1 interval(10m) if $rows != 4 then return -1 endi - if $data00 != @15-08-18 00:00:00.000@ then return -1 endi - if $data01 != 2 then return -1 endi - if $data02 != 0.000144445 then return -1 endi - if $data10 != @15-08-18 00:10:00.000@ then return -1 endi - if $data11 != 2 then return -1 endi - if $data12 != 0.000272222 then return -1 endi - if $data20 != @15-08-18 00:20:00.000@ then return -1 endi - if $data21 != 1 then return -1 endi - if $data22 != 0.000000000 then return -1 endi - if $data30 != @15-08-18 00:30:00.000@ then return -1 endi - if $data31 != 1 then return -1 endi - if $data32 != 0.000000000 then return -1 endi -sql select count(*),irate(k) from t1 interval(10m) order by ts desc +sql select _wstart, count(*),irate(k) from t1 interval(10m) order by _wstart desc if $rows != 4 then return -1 endi - if $data30 != @15-08-18 00:00:00.000@ then return -1 endi - if $data31 != 2 then return -1 endi - if $data32 != 0.000144445 then return -1 endi @@ -914,50 +818,42 @@ sql insert into tm0 values('2015-08-18T00:18:00Z', 2.126) ('2015-08-18T00:24:00Z sql_error select derivative(ts) from tm0; sql_error select derivative(k) from tm0; -sql_error select derivative(k, 0, 0) from tm0; +sql select derivative(k, 0, 0) from tm0; sql_error select derivative(k, 1, 911) from tm0; sql_error select derivative(kx, 1s, 1) from tm0; -sql_error select derivative(k, -20s, 1) from tm0; -sql_error select derivative(k, 20a, 0) from tm0; -sql_error select derivative(k, 200a, 0) from tm0; -sql_error select derivative(k, 999a, 0) from tm0; +sql select derivative(k, -20s, 1) from tm0; +sql select derivative(k, 20a, 0) from tm0; +sql select derivative(k, 200a, 0) from tm0; +sql select derivative(k, 999a, 0) from tm0; sql_error select derivative(k, 20s, -12) from tm0; sql select derivative(k, 1s, 0) from tm0 if $rows != 5 then return -1 endi - if $data00 != @15-08-18 08:06:00.000@ then return -1 endi - if $data01 != 0.000144444 then print expect 0.000144444, actual: $data01 return -1 endi - if $data10 != @15-08-18 08:12:00.000@ then return -1 endi - if $data11 != -0.000244444 then return -1 endi - if $data20 != @15-08-18 08:18:00.000@ then return -1 endi - if $data21 != 0.000272222 then print expect 0.000272222, actual: $data21 return -1 endi - if $data30 != @15-08-18 08:24:00.000@ then return -1 endi - if $data31 != -0.000236111 then print expect 0.000236111, actual: $data31 return -1 @@ -967,36 +863,28 @@ sql select derivative(k, 6m, 0) from tm0; if $rows != 5 then return -1 endi - if $data00 != @15-08-18 08:06:00.000@ then return -1 endi - if $data01 != 0.052000000 then print expect 0.052000000, actual: $data01 return -1 endi - if $data10 != @15-08-18 08:12:00.000@ then return -1 endi - if $data11 != -0.088000000 then return -1 endi - if $data20 != @15-08-18 08:18:00.000@ then return -1 endi - if $data21 != 0.098000000 then return -1 endi - if $data30 != @15-08-18 08:24:00.000@ then return -1 endi - if $data31 != -0.085000000 then return -1 endi @@ -1005,11 +893,9 @@ sql select derivative(k, 12m, 0) from tm0; if $rows != 5 then return -1 endi - if $data00 != @15-08-18 08:06:00.000@ then return -1 endi - if $data01 != 0.104000000 then print expect 0.104000000, actual: $data01 return -1 @@ -1061,39 +947,30 @@ sql select derivative(k, 1s, 0) from m1 group by tbname if $rows != 12 then return -1 endi - if $data00 != @20-01-01 01:01:03.000@ then return -1 endi - if $data01 != 1.000000000 then return -1 endi - if $data02 != @t0@ then return -1 endi - if $data10 != @20-01-01 01:02:04.000@ then return -1 endi - if $data11 != 0.016393443 then return -1 endi - if $data12 != t0 then return -1 endi - if $data90 != @20-01-01 01:01:06.000@ then return -1 endi - if $data91 != 90.000000000 then return -1 endi - if $data92 != t1 then return -1 endi @@ -1103,16 +980,13 @@ sql select stddev(f1) from st1 where ts>'2021-07-01 1:1:1' and ts<'2021-07-30 00 if $rows != 29 then return -1 endi - if $data00 != @21-07-01 00:00:00.000@ then return -1 endi - if $data01 != NULL then return -1 endi - sql select derivative(test_column_alias_name, 1s, 0) from (select avg(k) test_column_alias_name from t1 interval(1s)); sql create table smeters (ts timestamp, current float, voltage int) tags (t1 int);