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

[Bug]: panic in on duplicate key update for partition table #20879

Open
1 task done
ouyuanning opened this issue Dec 23, 2024 · 1 comment
Open
1 task done

[Bug]: panic in on duplicate key update for partition table #20879

ouyuanning opened this issue Dec 23, 2024 · 1 comment
Assignees
Labels
kind/bug Something isn't working severity/s0 Extreme impact: Cause the application to break down and seriously affect the use
Milestone

Comments

@ouyuanning
Copy link
Contributor

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main, 2.0-dev

Commit ID

main, 2.0-dev

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

mysql> drop database if exists db1;
Query OK, 1 row affected (0.01 sec)

mysql> create database db1;
Query OK, 1 row affected (0.01 sec)

mysql> use db1;
Database changed
mysql> create table t1(a int primary key, b int) partition by key(a) partitions 2;
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t1 values (1,1),(2,2);
Query OK, 2 rows affected (0.02 sec)

mysql> insert into t1 values (1,1) on duplicate key update b = 10;
ERROR 20101 (HY000): internal error: panic runtime error: index out of range [-1]: 
runtime.goPanicIndex
        /usr/local/go/src/runtime/panic.go:115
github.com/matrixorigin/matrixone/pkg/sql/colexec/multi_update.(*MultiUpdate).delete_table
        /Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/colexec/multi_update/delete.go:50
github.com/matrixorigin/matrixone/pkg/sql/colexec/multi_update.(*MultiUpdate).updateOneBatch
        /Users/ouyuanning/workspace/go/src/matrixone/pkg/sql/colexec/multi_update/multi_update.go:326
github.com/matrixori

Expected Behavior

No response

Steps to Reproduce

...

Additional information

No response

@ouyuanning ouyuanning added kind/bug Something isn't working needs-triage severity/s0 Extreme impact: Cause the application to break down and seriously affect the use labels Dec 23, 2024
@ouyuanning ouyuanning added this to the 2.0.2 milestone Dec 23, 2024
@ouyuanning ouyuanning self-assigned this Dec 23, 2024
@ouyuanning
Copy link
Contributor Author

ouyuanning commented Dec 23, 2024

根本原因是plan是根据Insert来处理的,所以没有旧 partition index 这个列的值。
这里因为不会更改pk,uk。所以partition index不会变化(新partition index等于旧partition index),我特殊处理一下吧。

不过目前的plan是完全基于不会修改unique key,pk以及 复合unique key和复合pk的某个列来做的。
如果后面要支持这些情况的话,这个plan会要做调整。要把lock放到dedup后面,并且要把新、旧partition的列给分开。

create table t1(a int primary key, b int) partition by key(a) partitions 2;
explain verbose insert into t1 values (1,1) on duplicate key update b = 10;
+-------------------------------------------------------------------------------------------------------------------------------------+
| TP QUERY PLAN                                                                                                                       |
+-------------------------------------------------------------------------------------------------------------------------------------+
| Multi Update[8] (cost=1.00 outcnt=1.00 selectivity=1.0000 blockNum=2)                                                               |
|   Output: #[0,0]                                                                                                                    |
|   Table: t1 Insert Columns: #[0,0], #[0,1] Delete Columns: #[0,3], #[0,0]                                                           |
|   ->  Project[7] (cost=1.00 outcnt=1.00 selectivity=1.0000 blockNum=2)                                                              |
|         Output: #[0,1], #[0,2], #[0,3], t1.__mo_rowid                                                                               |
|         ->  Join[6] (cost=3.00 outcnt=1.00 selectivity=1.0000 blockNum=2)                                                           |
|               Output: t1.__mo_rowid, #[1,0], #[1,1], #[1,2]                                                                         |
|               Old columns: t1.a, t1.b, t1.__mo_rowid Update index list: 1 Update expr list: cast(10 AS INT)                         |
|               Join Type: DEDUP (UPDATE)                                                                                             |
|               Join Cond: (t1.a = #[1,0])                                                                                            |
|               ->  Table Scan[5] on db1.t1 [ForceOneCN] (cost=2.00 outcnt=2.00 selectivity=1.0000 blockNum=2)                        |
|                     Output: t1.a, t1.b, t1.__mo_rowid                                                                               |
|                     Table: 't1' (0:'a', 1:'b', 2:'__mo_rowid')                                                                      |
|                     Hit Partition: all partitions                                                                                   |
|               ->  Lock[4] (cost=1.00 outcnt=1.00 selectivity=1.0000 blockNum=1)                                                     |
|                     Output: #[0,0], #[0,1], #[0,2]                                                                                  |
|                     Lock level: Row level lock                                                                                      |
|                     ->  Project[3] (cost=1.00 outcnt=1.00 selectivity=1.0000 blockNum=1)                                            |
|                           Output: _valuescan.column_0, _valuescan.column_1, cast((abs(hash_value(_valuescan.column_0)) % 2) AS INT) |
|                           ->  Values Scan[0] "*VALUES*"  (cost=1.00 outcnt=1.00 selectivity=1.0000 blockNum=1)                      |
|                                 Output: column_0, column_1                                                                          |
|                                 Value:"*VALUES*".column1, "*VALUES*".column2                                                        |
+-------------------------------------------------------------------------------------------------------------------------------------+
22 rows in set (0.01 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working severity/s0 Extreme impact: Cause the application to break down and seriously affect the use
Projects
None yet
Development

No branches or pull requests

4 participants