apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.77k stars 3.29k forks source link

[Bug] Update statement throws Unexpected exception: null with unique key table when store_row_column=true and enable_unique_key_merge_on_write=true #25044

Open geoffreytran opened 1 year ago

geoffreytran commented 1 year ago

Search before asking

Version

2.0.1

What's Wrong?

When running any update statement on a unique key table with the following settings enabled, the following exception is thrown.

BE config: disable_storage_row_cache = false

Table properties

  "enable_unique_key_merge_on_write" = "true",
  "light_schema_change" = "true",
  "store_row_column" = "true"
2023-10-04 16:54:28,138 WARN (mysql-nio-pool-1|299) [StmtExecutor.analyze():982] Analyze failed. stmt[69, 2a4d2964165d48a6-a6541bd2b5323eaa]
java.lang.NullPointerException: null
    at org.apache.doris.planner.OriginalPlanner.createPlanFragments(OriginalPlanner.java:233) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.planner.OriginalPlanner.plan(OriginalPlanner.java:95) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.analyzeAndGenerateQueryPlan(StmtExecutor.java:1131) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.analyze(StmtExecutor.java:965) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.executeByLegacy(StmtExecutor.java:667) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:453) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:424) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.handleUpdateStmt(StmtExecutor.java:2176) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.executeByLegacy(StmtExecutor.java:738) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:450) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:424) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:441) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.ConnectProcessor.dispatch(ConnectProcessor.java:589) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.ConnectProcessor.processOnce(ConnectProcessor.java:829) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.mysql.ReadListener.lambda$handleEvent$0(ReadListener.java:52) ~[doris-fe.jar:1.2-SNAPSHOT]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_342]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_342]
    at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_342]
2023-10-04 16:54:28,139 WARN (mysql-nio-pool-1|299) [StmtExecutor.executeByLegacy():770] execute Exception. stmt[69, 2a4d2964165d48a6-a6541bd2b5323eaa]
org.apache.doris.common.AnalysisException: errCode = 2, detailMessage = Unexpected exception: null
    at org.apache.doris.qe.StmtExecutor.analyze(StmtExecutor.java:983) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.executeByLegacy(StmtExecutor.java:667) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:453) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:424) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.handleUpdateStmt(StmtExecutor.java:2176) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.executeByLegacy(StmtExecutor.java:738) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:450) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:424) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:441) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.ConnectProcessor.dispatch(ConnectProcessor.java:589) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.ConnectProcessor.processOnce(ConnectProcessor.java:829) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.mysql.ReadListener.lambda$handleEvent$0(ReadListener.java:52) ~[doris-fe.jar:1.2-SNAPSHOT]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_342]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_342]
    at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_342]
2023-10-04 16:54:28,144 WARN (mysql-nio-pool-1|299) [StmtExecutor.handleUpdateStmt():2178] update data error, stmt=UPDATE `default_cluster:test`.`test` p
  SET `p`.`tenant_id` = 4, `p`.`updated_at` = timestamp('2023-01-20 14:02:58.223000'), 
  WHERE `p`.`workspace_id` = 1 AND `p`.`user_id` = '9f2f9731-9dda-4667-9317-6841e00d3e43'
2023-10-04 16:54:28,145 WARN (mysql-nio-pool-1|299) [StmtExecutor.executeByLegacy():794] errors when abort txn. stmt[69, 2a4d2964165d48a6-a6541bd2b5323eaa]
org.apache.doris.transaction.TransactionNotFoundException: errCode = 2, detailMessage = transaction not found
    at org.apache.doris.transaction.DatabaseTransactionMgr.abortTransaction(DatabaseTransactionMgr.java:1297) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.transaction.GlobalTransactionMgr.abortTransaction(GlobalTransactionMgr.java:325) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.transaction.GlobalTransactionMgr.abortTransaction(GlobalTransactionMgr.java:309) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.executeByLegacy(StmtExecutor.java:790) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:450) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.StmtExecutor.execute(StmtExecutor.java:424) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:441) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.ConnectProcessor.dispatch(ConnectProcessor.java:589) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.qe.ConnectProcessor.processOnce(ConnectProcessor.java:829) ~[doris-fe.jar:1.2-SNAPSHOT]
    at org.apache.doris.mysql.ReadListener.lambda$handleEvent$0(ReadListener.java:52) ~[doris-fe.jar:1.2-SNAPSHOT]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_342]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_342]
    at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_342]

What You Expected?

Update statement does not throw exception.

How to Reproduce?

create table if not exists test (
    workspace_id int not null comment "Workspace id",
    user_id varchar(64) comment "External user id",
    tenant_id int not null comment "Tenant id",
    created_at datetime not null default current_timestamp(0) comment "Created at",
    updated_at datetime comment "Updated at"
)
engine=olap
unique key (workspace_id, user_id)
distributed by hash(workspace_id, user_id)
properties (
    "replication_num" = "2",
    "enable_unique_key_merge_on_write" = "true",
    "light_schema_change" = "true",
    "store_row_column" = "true"
);

insert into test  (workspace_id, user_id, tenant_id) values (1, 'asdfadfa', 1);
update test  set tenant_id = 5 where workspace_id = 1 and user_id = 'asdfadfa';

Anything Else?

No response

Are you willing to submit PR?

Code of Conduct

ixzc commented 1 year ago

we will fix it.

ixzc commented 1 year ago

we will fix it.

https://github.com/apache/doris/pull/25085

lipenghao1216 commented 10 months ago

2.0.2 version also got this error, which version will fix it?

eldenmoon commented 10 months ago

@lipenghao1216 2.0.3 fixed

lipenghao1216 commented 10 months ago

@lipenghao1216 2.0.3 fixed

thanks