Skip to content
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

panic when virtual columns evaluated in index merge reader #17045

Closed
eurekaka opened this issue May 8, 2020 · 1 comment · Fixed by #17065
Closed

panic when virtual columns evaluated in index merge reader #17045

eurekaka opened this issue May 8, 2020 · 1 comment · Fixed by #17065
Assignees
Labels
severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@eurekaka
Copy link
Contributor

eurekaka commented May 8, 2020

Development Task

Run the following test in UTF:

class IndexMergeComplicate(SimpleCase):
    name = "TICASE-1849"

    def run(self):
        self.execute_sql(
            "create table t(a int,b varchar(20),c datetime,d double,e int,f int as(a+b),key(a),key(b),key(c),key(d),key(e),key(f))")
        for i in range(20):
            if i < 5:
                self.execute_sql('''insert into t(a,b,e) values(null,"%d",null)''' % i)
            else:
                self.execute_sql('''insert into t(a,b,e) values(%d,null,%d)''' % (i, 20 - i))
        res = self.execute_sql("select /*+ use_index_merge(t)*/ e,f from t where t.e=3 or t.a=10")

panic would occur like:

[2020/05/08 19:28:45.550 +08:00] [ERROR] [index_merge_reader.go:662] ["panic in IndexMergeReaderExecutor indexMergeTableWorker: runtime error: index out of range [0] with length 0"] [conn=2]
panic: runtime error: index out of range [0] with length 0 [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x325fc3b]

goroutine 1642 [running]:
github.com/pingcap/tidb/executor.(*indexMergeTableScanWorker).handlePickAndExecTaskPanic.func1(0x3920580, 0xc001e4f140)
	/root/go/src/github.com/pingcap/tidb/executor/index_merge_reader.go:663 +0x19b
github.com/pingcap/tidb/util.WithRecovery.func1(0xc0015e2c60)
	/root/go/src/github.com/pingcap/tidb/util/misc.go:85 +0x7d
panic(0x3920580, 0xc001e4f140)
	/usr/local/go/src/runtime/panic.go:679 +0x1e0
github.com/pingcap/tidb/util/chunk.(*Column).GetString(0xc0011d3110, 0x0, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/util/chunk/column.go:528 +0x11b
github.com/pingcap/tidb/util/chunk.Row.GetString(0xc0015e6d20, 0x0, 0x0, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/util/chunk/row.go:70 +0x5c
github.com/pingcap/tidb/expression.(*Column).EvalString(0xc0015c2d20, 0x42db640, 0xc0019fed00, 0xc0015e6d20, 0x0, 0x0, 0x0, 0x4280000, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/expression/column.go:386 +0x2b0
github.com/pingcap/tidb/expression.(*builtinCastStringAsRealSig).evalReal(0xc0015c4e70, 0xc0015e6d20, 0x0, 0x0, 0x1a2dc00, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/expression/builtin_cast.go:1182 +0x260
github.com/pingcap/tidb/expression.(*ScalarFunction).EvalReal(0xc0015e05a0, 0x42db640, 0xc0019fed00, 0xc0015e6d20, 0x0, 0x0, 0x1142f00, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/expression/scalar_function.go:354 +0x83
github.com/pingcap/tidb/expression.(*builtinArithmeticPlusRealSig).evalReal(0xc0015c4d10, 0xc0015e6d20, 0x0, 0x0, 0x0, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/expression/builtin_arithmetic.go:289 +0x20c
github.com/pingcap/tidb/expression.(*ScalarFunction).EvalReal(0xc0015e05f0, 0x42db640, 0xc0019fed00, 0xc0015e6d20, 0x0, 0x0, 0x1142f00, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/expression/scalar_function.go:354 +0x83
github.com/pingcap/tidb/expression.(*ScalarFunction).Eval(0xc0015e05f0, 0xc0015e6d20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/root/go/src/github.com/pingcap/tidb/expression/scalar_function.go:323 +0x3b5
github.com/pingcap/tidb/expression.(*Column).EvalVirtualColumn(0xc0015c3180, 0xc0015e6d20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/root/go/src/github.com/pingcap/tidb/expression/column.go:580 +0xc1
github.com/pingcap/tidb/executor.FillVirtualColumnValue(0xc002975dd8, 0x1, 0x1, 0xc001e4ef40, 0x1, 0x3, 0xc002a727b0, 0xc001fd31a0, 0x3, 0xc, ...)
	/root/go/src/github.com/pingcap/tidb/executor/executor.go:1728 +0x26e
github.com/pingcap/tidb/executor.(*TableReaderExecutor).Next(0xc000bd0840, 0x42a8b00, 0xc002f2d980, 0xc0015e6d20, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/executor/table_reader.go:171 +0x473
github.com/pingcap/tidb/executor.Next(0x42a8b00, 0xc002f2d980, 0x42b1400, 0xc000bd0840, 0xc0015e6d20, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/executor/executor.go:249 +0x5c7
github.com/pingcap/tidb/executor.(*indexMergeTableScanWorker).executeTask(0xc002f2d940, 0x42a8b00, 0xc002f2d980, 0xc0015f6480, 0x0, 0x0)
	/root/go/src/github.com/pingcap/tidb/executor/index_merge_reader.go:682 +0x51c
github.com/pingcap/tidb/executor.(*indexMergeTableScanWorker).pickAndExecTask(0xc002f2d940, 0x42a8b00, 0xc002f2d980, 0xc0015f6480)
	/root/go/src/github.com/pingcap/tidb/executor/index_merge_reader.go:650 +0x195
github.com/pingcap/tidb/executor.(*IndexMergeReaderExecutor).startIndexMergeTableScanWorker.func2.1()
	/root/go/src/github.com/pingcap/tidb/executor/index_merge_reader.go:398 +0x63
github.com/pingcap/tidb/util.WithRecovery(0xc0005b6780, 0xc0015e2c60)
	/root/go/src/github.com/pingcap/tidb/util/misc.go:93 +0x59
github.com/pingcap/tidb/executor.(*IndexMergeReaderExecutor).startIndexMergeTableScanWorker.func2(0xc002f2d940, 0x42a8b00, 0xc002f2d980, 0xc0015a5580, 0xc0022a3680)
	/root/go/src/github.com/pingcap/tidb/executor/index_merge_reader.go:397 +0xfd
created by github.com/pingcap/tidb/executor.(*IndexMergeReaderExecutor).startIndexMergeTableScanWorker
	/root/go/src/github.com/pingcap/tidb/executor/index_merge_reader.go:395 +0x377
@ChenPeng2013
Copy link
Contributor

verified on
master: v4.0.0-beta.2-524-g73fe3ca4d
release-4.0: v4.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
5 participants