-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[feature](txn insert) txn insert support insert into select #31666
Conversation
Thank you for your contribution to Apache Doris. |
3becfa8
to
e40a1ab
Compare
run buildall |
1 similar comment
run buildall |
TPC-H: Total hot run time: 32116 ms
|
TPC-DS: Total hot run time: 187669 ms
|
ClickBench: Total hot run time: 27.03 s
|
f18dccc
to
659ca52
Compare
run buildall |
@@ -531,7 +531,8 @@ public LogicalPlan visitInsertTable(InsertTableContext ctx) { | |||
if (isOverwrite) { | |||
command = new InsertOverwriteTableCommand(sink, labelName); | |||
} else { | |||
if (ConnectContext.get() != null && ConnectContext.get().isTxnModel()) { | |||
if (ConnectContext.get() != null && ConnectContext.get().isTxnModel() | |||
&& sink.child() instanceof LogicalInlineTable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In legacy planner, we support insert into t select 1
. So if we only support LogicalInlineTable
here means we have diff with legacy planner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nereids does not support insert into t select 1
? It fallback to legacy
|
||
if (physicalSink instanceof PhysicalOlapTableSink) { | ||
if (GroupCommitInserter.groupCommit(ctx, sink, physicalSink)) { | ||
return; | ||
} | ||
OlapTable olapTable = (OlapTable) targetTableIf; | ||
String label = this.labelName.orElse( | ||
ctx.isTxnModel() ? null : String.format("label_%x_%x", ctx.queryId().hi, ctx.queryId().lo)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could u add some comment to explain why lable should be null when we in txn model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -162,6 +162,10 @@ private static InternalService.PDataRow getRowStringValue(List<NamedExpression> | |||
private static void beginBatchInsertTransaction(ConnectContext ctx, | |||
String dbName, String tblName, List<Column> columns) { | |||
TransactionEntry txnEntry = ctx.getTxnEntry(); | |||
if (txnEntry.isTransactionBegan()) { | |||
throw new AnalysisException( | |||
"Transaction insert can not insert into values and insert into select at the same time"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isTransactionBegan
means use insert into values with insert into select at same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isTransactionBegan
means the insert into select
already began a txn.
This function will begin a txn for insert into values
.
Currently we forbid it, maybe support it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a TODO coment here, we'll support mix usage of insert into values and insert into select in future.
boolean isGroupCommit = (parsedStmt != null | ||
&& parsedStmt instanceof LogicalPlanAdapter | ||
&& ((LogicalPlanAdapter) parsedStmt).getLogicalPlan() instanceof InsertIntoTableCommand) | ||
&& !context.isTxnModel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so all insert into without txn model is group commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic should be
boolean isGroupCommit = (Config.wait_internal_group_commit_finish
|| context.sessionVariable.isEnableInsertGroupCommit()) && parsedStmt != null
&& parsedStmt instanceof LogicalPlanAdapter
&& ((LogicalPlanAdapter) parsedStmt).getLogicalPlan() instanceof InsertIntoTableCommand;
but some nereids case can not pass.
I add !context.isTxnModel()
here becase the regression cases expect txn insert does not force fallback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the variable name now should not be isGroupCommit
? please use a better variable name, and add comments to explain it here
fe/fe-core/src/main/java/org/apache/doris/transaction/TransactionEntry.java
Show resolved
Hide resolved
659ca52
to
96f04b2
Compare
run buildall |
TPC-H: Total hot run time: 37666 ms
|
TPC-DS: Total hot run time: 178038 ms
|
ClickBench: Total hot run time: 30.64 s
|
Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
96f04b2
to
2bf8bd0
Compare
run buildall |
run p0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
## Proposed changes ### Purpose The user doc: https://doris.apache.org/zh-CN/docs/dev/data-operate/import/transaction-load-manual We have supported insert into select(#31666), update(#33034) and delete(#33100) in transaction load. #32980 implements one txn write to one partition more than one rowsets. This pr implements to cloud mode of #32980 ### Implementation #### sub_txn_id see #32980 #### Meta service supports commit txn This process is generally the same as commit_txn, the difference is that he partitions version will plus 1 in multi sub txns. One example: Suppose the table, partition, tablet and version info is: ``` -------------------------------------------- | table | partition | tablet | version | -------------------------------------------- | t1 | t1_p1 | t1_p1.1 | 1 | | t1 | t1_p1 | t1_p1.2 | 1 | | t1 | t1_p2 | t1_p2.1 | 2 | | t2 | t2_p3 | t2_p3.1 | 3 | | t2 | t2_p4 | t2_p4.1 | 4 | -------------------------------------------- ``` Now we commit a txn with 3 sub txns and the tablets are: * sub_txn1: t1_p1.1, t1_p1.2, t1_p2.1 * sub_txn2: t2_p3.1 * sub_txn3: t1_p1.1, t1_p1.2 When commit, the partitions version will be: * sub_txn1: t1_p1(1 -> 2), t1_p2(2 -> 3) * sub_txn2: t2_p3(3 -> 4) * sub_txn3: t1_p1(2 -> 3) After commit, the partitions version will be: * t1: t1_p1(3), t1_p2(3) * t2: t2_p3(4), t2_p4(4) #### Meta service support generate sub_txn_id by `begin_sub_txn`
## Proposed changes ### Purpose The user doc: https://doris.apache.org/zh-CN/docs/dev/data-operate/import/transaction-load-manual We have supported insert into select(#31666), update(#33034) and delete(#33100) in transaction load. #32980 implements one txn write to one partition more than one rowsets. This pr implements to cloud mode of #32980 ### Implementation #### sub_txn_id see #32980 #### Meta service supports commit txn This process is generally the same as commit_txn, the difference is that he partitions version will plus 1 in multi sub txns. One example: Suppose the table, partition, tablet and version info is: ``` -------------------------------------------- | table | partition | tablet | version | -------------------------------------------- | t1 | t1_p1 | t1_p1.1 | 1 | | t1 | t1_p1 | t1_p1.2 | 1 | | t1 | t1_p2 | t1_p2.1 | 2 | | t2 | t2_p3 | t2_p3.1 | 3 | | t2 | t2_p4 | t2_p4.1 | 4 | -------------------------------------------- ``` Now we commit a txn with 3 sub txns and the tablets are: * sub_txn1: t1_p1.1, t1_p1.2, t1_p2.1 * sub_txn2: t2_p3.1 * sub_txn3: t1_p1.1, t1_p1.2 When commit, the partitions version will be: * sub_txn1: t1_p1(1 -> 2), t1_p2(2 -> 3) * sub_txn2: t2_p3(3 -> 4) * sub_txn3: t1_p1(2 -> 3) After commit, the partitions version will be: * t1: t1_p1(3), t1_p2(3) * t2: t2_p3(4), t2_p4(4) #### Meta service support generate sub_txn_id by `begin_sub_txn`
Proposed changes
Transaction insert support:
Limit:
insert into select
andinsert into values
can be used at one transaction.Will support in later pr.
Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...