github-actions[bot] commented on code in PR #62453:
URL: https://github.com/apache/doris/pull/62453#discussion_r3085660023
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java:
##########
@@ -285,6 +296,44 @@ public AbstractInsertExecutor initPlan(ConnectContext ctx,
StmtExecutor stmtExec
return insertExecutor;
}
+ List<ScanNode> tableStreamScanNodes =
+ buildResult.planner.getScanNodes().stream()
+ .filter(s -> s.getTableIf() instanceof
OlapTableStreamWrapper).collect(Collectors.toList());
+
+ if (!tableStreamScanNodes.isEmpty()) {
+ // stream id -> <partition id, offset>
+ Map<Pair<Long, Long>, AbstractTableStreamUpdate>
distinctUpdate =
+ new HashMap<>(tableStreamScanNodes.size());
+ for (ScanNode scanNode : tableStreamScanNodes) {
+ // only support OlapScanNode currently
+ Preconditions.checkArgument(scanNode instanceof
OlapScanNode);
+ OlapScanNode olapScanNode = (OlapScanNode) scanNode;
+ OlapTableStreamWrapper wrapper = (OlapTableStreamWrapper)
scanNode.getTableIf();
+ if (!distinctUpdate.containsKey(
+ Pair.of(wrapper.getStreamDbId(),
wrapper.getStreamId()))) {
+ distinctUpdate.put(Pair.of(wrapper.getStreamDbId(),
wrapper.getStreamId()),
+ new OlapTableStreamUpdate());
+ }
+ distinctUpdate.get(Pair.of(wrapper.getStreamDbId(),
wrapper.getStreamId()))
+ .merge(olapScanNode.getStreamUpdate());
+ }
+ List<TableStreamUpdateInfo> infos = new
ArrayList<>(distinctUpdate.size());
+ distinctUpdate.forEach((key, value) -> infos.add(new
TableStreamUpdateInfo(key.first,
+ key.second, value)));
+ // put offset into executor
+ insertExecutor.setStreamUpdateInfos(infos);
+ insertExecutor.registerListener(new InsertExecutorListener() {
+ @Override
+ public void beforeComplete(AbstractInsertExecutor
insertExecutor, StmtExecutor executor,
Review Comment:
Blocking: this stores stream offsets on `TransactionState`, but only the
shared-nothing transaction path consumes them
(`GlobalTransactionMgr`/`DatabaseTransactionMgr` build extra lock lists, call
`checkStreamOffset`, and update offsets). The cloud path was not updated:
`CloudGlobalTransactionMgr.commitAndPublishTransaction(...)` still locks only
`tableList` and never checks/applies `streamUpdateInfos`. That means the same
statement can bypass stream-offset validation in cloud mode. Please wire cloud
commit through the same stream-update locking/validation/update flow, or reject
this feature in cloud mode for now.
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/stream/TableStreamUpdateInfo.java:
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.catalog.stream;
+
+import org.apache.doris.common.io.Text;
+import org.apache.doris.common.io.Writable;
+import org.apache.doris.persist.gson.GsonPostProcessable;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Getter;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+public class TableStreamUpdateInfo implements Writable, GsonPostProcessable {
+ @Getter
+ @SerializedName("di")
+ private final long dbId;
+ @Getter
+ @SerializedName(value = "sid")
+ private final long streamId;
+ @Getter
+ @SerializedName(value = "o")
+ private final AbstractTableStreamUpdate update;
Review Comment:
Blocking: `TransactionState` now persists `List<TableStreamUpdateInfo>`
through `OP_UPSERT_TRANSACTION_STATE`, but `update` is declared as the abstract
type `AbstractTableStreamUpdate`. `GsonUtils` does not register a runtime
adapter for this hierarchy, so replay/checkpoint deserialization has no way to
reconstruct `OlapTableStreamUpdate` and will fail as soon as a committed txn
with stream updates is journaled. This breaks the EditLog read/write invariant.
Please either make the field concrete for the only supported type, or add a
proper `RuntimeTypeAdapterFactory` for `AbstractTableStreamUpdate` and cover
replay.`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]