-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
index out of range [1] with length 1 in executor.(*PipelinedWindowExec).getRow
#53600
Comments
Never mind.
+---------------------------------------------------------------+---------------------+--------------+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+---------------------------------------------------------------+---------------------+--------------+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_234 | 50.00 | root | | -862238766->Column#196, test1.t_tjov.c_irfjyds3, test1.t_tjov.c_kq8lwb, <nil>->Column#201 |
| └─TopN_237 | 50.00 | root | | test1.t_tjov.c_irfjyds3, test1.t_tjov.c_kq8lwb, offset:0, count:50 |
| └─Apply_243 | 10000.00 | root | | CARTESIAN inner join |
| ├─TableReader_248(Build) | 10000.00 | root | | MppVersion: 2, data:ExchangeSender_247 |
| │ └─ExchangeSender_247 | 10000.00 | mpp[tiflash] | | ExchangeType: PassThrough |
| │ └─TableFullScan_246 | 10000.00 | mpp[tiflash] | table:ref_7 | keep order:false, stats:pseudo |
| └─Selection_249(Probe) | 8000.00 | root | | lt(NULL, Column#195) |
| └─Projection_250 | 10000.00 | root | | test1.t_tjov.c_tutmh1->Column#195 |
| └─Limit_253 | 10000.00 | root | | offset:0, count:1 |
| └─Selection_254 | 10000.00 | root | | or(not(like(test1.t_tjov.c_mzh, "%gw", 92)), 0) |
| └─Projection_255 | 10000.00 | root | | 1->Column#202 |
| └─Shuffle_278 | 10000.00 | root | | execution info: concurrency:5, data sources:[Projection_258] |
| └─Window_256 | 10000.00 | root | | nth_value(Column#185, 32)->Column#186 over(partition by test1.t_n.c_tf_us39fv, test1.t_n.c_tf_us39fv, test1.t_db8a.c_jr2kq78hqt, test1.t_n.c_v order by test1.t_db8a.c_t9, test1.t_db8a.c_d, test1.t_db8a.c_jr2kq78hqt, test1.t_db8a.c_yh_3, test1.t_n.c_tf_us39fv, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_v, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6, test1.t_n.c_tf_us39fv, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_v, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6, test1.t_n.c_tf_us39fv, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_v, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6 range between unbounded preceding and current row) |
| └─Sort_277 | 9990000000000000.00 | root | | test1.t_n.c_tf_us39fv, test1.t_n.c_tf_us39fv, test1.t_db8a.c_jr2kq78hqt, test1.t_n.c_v, test1.t_db8a.c_t9, test1.t_db8a.c_d, test1.t_db8a.c_jr2kq78hqt, test1.t_db8a.c_yh_3, test1.t_n.c_tf_us39fv, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_v, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6, test1.t_n.c_tf_us39fv, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_v, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6, test1.t_n.c_tf_us39fv, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_v, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6 |
| └─ShuffleReceiver_281 | 999000000000.00 | root | | |
| └─Projection_258 | 9990000000000000.00 | root | | test1.t_n.c_pf6z4p, test1.t_n.c__57bl_eu6, test1.t_n.c_fr3uo, test1.t_db8a.c_yh_3, test1.t_n.c_v, test1.t_n.c_tf_us39fv, test1.t_n.c_tf_us39fv, test1.t_n.c_tf_us39fv, test1.t_db8a.c_jr2kq78hqt, test1.t_n.c_v, test1.t_db8a.c_t9, test1.t_db8a.c_d, test1.t_n.c_v13rl, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_v, test1.t_n.c_mm8jnf, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6, cast(test1.t_n.c_tf_us39fv, bigint(22) BINARY)->Column#185 |
| └─HashJoin_259 | 9990000000000000.00 | root | | CARTESIAN left outer join |
| ├─TableReader_276(Build) | 80000000.00 | root | | data:Selection_275 |
| │ └─Selection_275 | 80000000.00 | cop[tikv] | | istrue_with_null(cast(lt(cast(test1.t_n.c_v, double BINARY), cast(cast(test1.t_n.c_tf_us39fv, bigint(22) BINARY), double BINARY)), bigint(22) UNSIGNED BINARY)) |
| │ └─TableFullScan_274 | 100000000.00 | cop[tikv] | table:ref_6 | keep order:false, stats:pseudo |
| └─Projection_261(Probe) | 1248750000000.00 | root | | test1.t_db8a.c_t9, test1.t_db8a.c_d, test1.t_db8a.c_jr2kq78hqt, test1.t_db8a.c_yh_3, test1.t_n.c_tf_us39fv, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_v, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6, test1.t_n.c_tf_us39fv, test1.t_n.c_pf6z4p, test1.t_n.c_v13rl, test1.t_n.c_fr3uo, test1.t_n.c_v, test1.t_n.c_mm8jnf, test1.t_n.c__57bl_eu6 |
| └─HashJoin_262 | 1248750000000.00 | root | | CARTESIAN inner join |
| ├─TableReader_273(Build) | 100000000.00 | root | | data:TableFullScan_272 |
| │ └─TableFullScan_272 | 100000000.00 | cop[tikv] | table:ref_3 | keep order:false, stats:pseudo |
| └─HashJoin_264(Probe) | 124875000.00 | root | | inner join, equal:[eq(test1.t_n.c_v, test1.t_n.c_v13rl)] |
| ├─TableReader_271(Build) | 99900000.00 | root | | data:Selection_270 |
| │ └─Selection_270 | 99900000.00 | cop[tikv] | | not(isnull(test1.t_n.c_v13rl)) |
| │ └─TableFullScan_269 | 100000000.00 | cop[tikv] | table:ref_5 | keep order:false, stats:pseudo |
| └─TableReader_268(Probe) | 99900000.00 | root | | data:Selection_267 |
| └─Selection_267 | 99900000.00 | cop[tikv] | | not(isnull(test1.t_n.c_v)) |
| └─TableFullScan_266 | 100000000.00 | cop[tikv] | table:ref_4 | keep order:false, stats:pseudo |
+---------------------------------------------------------------+---------------------+--------------+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
A minor case that can reproduce this issue: select
1
from
t_tjov
where
(
select
t_tjov.c_tutmh1 as c0
from
(
select nth_value(t_n.c_tf_us39fv, 1) over (partition by t_db8a.c_jr2kq78hqt order by t_n.c_mm8jnf) as c5 from t_db8a
join
t_n
) as tbl
limit
1
); tidb:4000 [test1]> desc select 1 from t_tjov where ( select t_tjov.c_tutmh1 as c0 from ( select nth_value(t_n.c_tf_us39fv, 1) over (partition by t_db8a.c_jr2kq78hqt orde
r by t_n.c_mm8jnf) as c5 from t_db8a join t_n ) as tbl limit 1 );
+-----------------------------------------------+---------+-----------+---------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+-----------------------------------------------+---------+-----------+---------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_20 | 8.00 | root | | 1->Column#22 |
| └─Apply_22 | 8.00 | root | | CARTESIAN inner join |
| ├─IndexReader_29(Build) | 8.00 | root | | index:IndexFullScan_28 |
| │ └─IndexFullScan_28 | 8.00 | cop[tikv] | table:t_tjov, index:t_xs_idx_1(c_irfjyds3, c_k4duc4l, c_tutmh1, c_kq8lwb) | keep order:false, stats:pseudo |
| └─Selection_30(Probe) | 6.40 | root | | Column#21 |
| └─Projection_31 | 8.00 | root | | test1.t_tjov.c_tutmh1->Column#21 |
| └─Limit_34 | 8.00 | root | | offset:0, count:1 |
| └─Shuffle_48 | 8.00 | root | | execution info: concurrency:3, data sources:[HashJoin_37] |
| └─Window_35 | 8.00 | root | | nth_value(test1.t_n.c_tf_us39fv, 1)->Column#19 over(partition by test1.t_db8a.c_jr2kq78hqt order by test1.t_n.c_mm8jnf range between unbounded preceding and current row) |
| └─Sort_47 | 7168.00 | root | | test1.t_db8a.c_jr2kq78hqt, test1.t_n.c_mm8jnf |
| └─ShuffleReceiver_49 | 896.00 | root | | |
| └─HashJoin_37 | 7168.00 | root | | CARTESIAN inner join |
| ├─IndexReader_41(Build) | 32.00 | root | | index:IndexFullScan_40 |
| │ └─IndexFullScan_40 | 32.00 | cop[tikv] | table:t_db8a, index:c_jr2kq78hqt(c_jr2kq78hqt) | keep order:false, stats:pseudo |
| └─TableReader_45(Probe) | 1792.00 | root | | data:TableFullScan_44 |
| └─TableFullScan_44 | 1792.00 | cop[tikv] | table:t_n | keep order:false, stats:pseudo |
+-----------------------------------------------+---------+-----------+---------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
16 rows in set (0.00 sec)
|
The issue if fixed after the following modification. diff --git a/pkg/executor/pipelined_window.go b/pkg/executor/pipelined_window.go
index 9bd7ea5256..78dabceac3 100644
--- a/pkg/executor/pipelined_window.go
+++ b/pkg/executor/pipelined_window.go
@@ -90,6 +90,17 @@ func (e *PipelinedWindowExec) Open(ctx context.Context) (err error) {
e.dropped = 0
e.data = make([]dataInfo, 0)
e.dataIdx = 0
+ e.curRowIdx = 0
+ e.newPartition = false
+ e.lastStartRow = 0
+ e.lastEndRow = 0
+ e.stagedStartRow = 0
+ e.stagedEndRow = 0
+ e.rowCnt = 0
+ e.whole = false
+ e.rowStart = 0
+ e.rowCnt = 0
+ e.initializedSlidingWindow = false
e.slidingWindowFuncs = make([]aggfuncs.SlidingWindowAggFunc, len(e.windowFuncs))
for i, windowFunc := range e.windowFuncs {
if slidingWindowAggFunc, ok := windowFunc.(aggfuncs.SlidingWindowAggFunc); ok { tidb:4001 [test1]> select 1 from t_tjov where ( select t_tjov.c_tutmh1 as c0 from ( select nth_value(t_n.c_tf_us39fv, 1) over (partition by t_db8a.c_jr2kq78hqt order by t_n.c_mm8jnf) as c5 from t_db8a join t_n ) as tbl limit 1 );
+---+
| 1 |
+---+
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
+---+
7 rows in set (0.00 sec) |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
First execute the following valid.sql
valid.txt
Then a crash occurs when executing the error.sql below
error.txt
2. What did you expect to see? (Required)
Expect no crashes
3. What did you see instead (Required)
tidb.log:
4. What is your TiDB version? (Required)
We are the BASS team from the School of Cyber Science and Technology at Beihang University. Our main focus is on system software security, operating systems, and program analysis research, as well as the development of automated program testing frameworks for detecting software defects. Using our self-developed database vulnerability testing tool, we have identified the above-mentioned vulnerabilities in TiDB that may lead to database crashes.
The text was updated successfully, but these errors were encountered: