You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/08/29 00:24:26 UTC
[GitHub] [incubator-seatunnel] ashulin opened a new pull request, #2556: [engine][checkpoint] checkpoint flow
ashulin opened a new pull request, #2556:
URL: https://github.com/apache/incubator-seatunnel/pull/2556
<!--
Thank you for contributing to SeaTunnel! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
## Contribution Checklist
- Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
- Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
- Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
-->
## Purpose of this pull request
<!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
## Check list
* [ ] Code changed are covered with tests, or it does not need tests for reason:
* [ ] If any new Jar binary package adding in your PR, please add License Notice according
[New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] ashulin commented on pull request #2556: [engine][checkpoint] checkpoint flow
Posted by GitBox <gi...@apache.org>.
ashulin commented on PR #2556:
URL: https://github.com/apache/incubator-seatunnel/pull/2556#issuecomment-1230074419
@CalvinKirs Please take a look at the code of the `seatunnel-engine-storage` module change.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] ashulin commented on a diff in pull request #2556: [engine][checkpoint] checkpoint flow
Posted by GitBox <gi...@apache.org>.
ashulin commented on code in PR #2556:
URL: https://github.com/apache/incubator-seatunnel/pull/2556#discussion_r957952156
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/operation/CheckpointFinishedOperation.java:
##########
@@ -50,21 +51,23 @@ public int getClassId() {
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
- out.writeLong(jobId);
- out.writeLong(pipelineId);
out.writeLong(checkpointId);
+ out.writeObject(taskInfo);
+ out.writeBoolean(successful);
}
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
- jobId = in.readLong();
- pipelineId = in.readLong();
checkpointId = in.readLong();
+ taskInfo = in.readObject(TaskInfo.class);
+ successful = in.readBoolean();
}
@Override
protected PassiveCompletableFuture<?> doRun() throws Exception {
- // TODO: Notifies all tasks of the pipeline about the status of the checkpoint
+ SeaTunnelServer server = getService();
+ Task task = server.getTaskExecutionService().getExecutionContext(taskInfo.getTaskGroupId())
Review Comment:
thx, done.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #2556: [engine][checkpoint] checkpoint flow
Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #2556:
URL: https://github.com/apache/incubator-seatunnel/pull/2556#discussion_r956874778
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointManager.java:
##########
@@ -28,24 +40,60 @@
*/
public class CheckpointManager {
+ private final Long jobId;
+
+ private final NodeEngine nodeEngine;
+
+ private final Map<Long, Integer> subtaskWithPipelines;
+
+ private final Map<Long, Address> subtaskWithAddresses;
+
/**
* key: the pipeline id of the job;
* <br> value: the checkpoint plan of the pipeline;
*/
- private final Map<Long, CheckpointPlan> checkpointPlanMap;
+ private final Map<Integer, CheckpointPlan> checkpointPlanMap;
/**
* key: the pipeline id of the job;
* <br> value: the checkpoint coordinator of the pipeline;
*/
- private final Map<Long, CheckpointCoordinator> coordinatorMap;
+ private final Map<Integer, CheckpointCoordinator> coordinatorMap;
+
+ private final CheckpointCoordinatorConfiguration config;
- public CheckpointManager(Map<Long, CheckpointPlan> checkpointPlanMap) {
+ public CheckpointManager(long jobId, NodeEngine nodeEngine, Map<Integer, CheckpointPlan> checkpointPlanMap, CheckpointCoordinatorConfiguration config) {
+ this.jobId = jobId;
+ this.nodeEngine = nodeEngine;
this.checkpointPlanMap = checkpointPlanMap;
+ this.config = config;
this.coordinatorMap = new HashMap<>(checkpointPlanMap.size());
+ this.subtaskWithPipelines = checkpointPlanMap.values().stream().flatMap(plan -> plan.getPipelineTaskIds().keySet().stream().map(taskId -> Tuple2.tuple2(taskId, plan.getPipelineId()))).collect(Collectors.toMap(Tuple2::f0, Tuple2::f1));
+ this.subtaskWithAddresses = new HashMap<>(subtaskWithPipelines.size());
Review Comment:
remove init capcity maybe better
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/NodeEngineUtil.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.seatunnel.engine.server;
Review Comment:
can put this util to `org.apache.seatunnel.engine.server.utils`?
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointCoordinator.java:
##########
@@ -42,11 +54,60 @@ public class CheckpointCoordinator {
private final CheckpointCoordinatorConfiguration config;
- public CheckpointCoordinator(CheckpointPlan plan,
+ public CheckpointCoordinator(CheckpointManager manager,
+ long jobId,
+ CheckpointPlan plan,
CheckpointCoordinatorConfiguration config) {
+ this.checkpointManager = manager;
+ this.jobId = jobId;
+ this.pipelineId = plan.getPipelineId();
this.plan = plan;
this.config = config;
this.pendingCheckpoints = new LinkedHashMap<>();
this.completedCheckpoints = new LinkedHashMap<>();
}
+
+ protected void acknowledgeTask(TaskAcknowledgeOperation ackOperation) {
+ final long checkpointId = ackOperation.getCheckpointId();
+ final PendingCheckpoint pendingCheckpoint = pendingCheckpoints.get(checkpointId);
+ if (pendingCheckpoint == null) {
+ LOG.debug("job: {}, pipeline: {}, the checkpoint({}) don't exist.", jobId, pipelineId, checkpointId);
+ return;
+ }
+ pendingCheckpoint.acknowledgeTask(ackOperation.getTaskInfo(), ackOperation.getStates());
+ if (pendingCheckpoint.isFullyAcknowledged()) {
+ CompletedCheckpoint completedCheckpoint = completePendingCheckpoint(pendingCheckpoint);
+ pendingCheckpoints.remove(checkpointId);
+ completedCheckpoints.put(checkpointId, completedCheckpoint);
+ }
+ }
+
+ public CompletedCheckpoint completePendingCheckpoint(PendingCheckpoint pendingCheckpoint) {
+ notifyCheckpointCompleted(pendingCheckpoint.getCheckpointId());
Review Comment:
this is a async operation, maybe you should call `InvocationFuture::join` one by one.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2556: [engine][checkpoint] checkpoint flow
Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2556:
URL: https://github.com/apache/incubator-seatunnel/pull/2556#discussion_r956874888
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointManager.java:
##########
@@ -28,24 +40,60 @@
*/
public class CheckpointManager {
+ private final Long jobId;
+
+ private final NodeEngine nodeEngine;
+
+ private final Map<Long, Integer> subtaskWithPipelines;
+
+ private final Map<Long, Address> subtaskWithAddresses;
+
/**
* key: the pipeline id of the job;
* <br> value: the checkpoint plan of the pipeline;
*/
- private final Map<Long, CheckpointPlan> checkpointPlanMap;
+ private final Map<Integer, CheckpointPlan> checkpointPlanMap;
/**
* key: the pipeline id of the job;
* <br> value: the checkpoint coordinator of the pipeline;
*/
- private final Map<Long, CheckpointCoordinator> coordinatorMap;
+ private final Map<Integer, CheckpointCoordinator> coordinatorMap;
+
+ private final CheckpointCoordinatorConfiguration config;
- public CheckpointManager(Map<Long, CheckpointPlan> checkpointPlanMap) {
+ public CheckpointManager(long jobId, NodeEngine nodeEngine, Map<Integer, CheckpointPlan> checkpointPlanMap, CheckpointCoordinatorConfiguration config) {
+ this.jobId = jobId;
+ this.nodeEngine = nodeEngine;
this.checkpointPlanMap = checkpointPlanMap;
+ this.config = config;
this.coordinatorMap = new HashMap<>(checkpointPlanMap.size());
+ this.subtaskWithPipelines = checkpointPlanMap.values().stream().flatMap(plan -> plan.getPipelineTaskIds().keySet().stream().map(taskId -> Tuple2.tuple2(taskId, plan.getPipelineId()))).collect(Collectors.toMap(Tuple2::f0, Tuple2::f1));
+ this.subtaskWithAddresses = new HashMap<>(subtaskWithPipelines.size());
+ }
+
+ private int getPipelineId(long subtaskId) {
+ return subtaskWithPipelines.get(subtaskId);
+ }
+
+ private CheckpointCoordinator getCheckpointCoordinator(TaskInfo taskInfo) {
+ return coordinatorMap.get(getPipelineId(taskInfo.getSubtaskId()));
+ }
+
+ public void acknowledgeTask(TaskAcknowledgeOperation ackOperation, Address address) {
+ getCheckpointCoordinator(ackOperation.getTaskInfo()).acknowledgeTask(ackOperation);
+ subtaskWithAddresses.putIfAbsent(ackOperation.getTaskInfo().getSubtaskId(), address);
+ }
+
+ public void taskCompleted(TaskInfo taskInfo) {
+ getCheckpointCoordinator(taskInfo).taskCompleted(taskInfo);
+ }
+
+ public InvocationFuture<?> triggerCheckpoint(CheckpointTriggerOperation operation) {
+ return NodeEngineUtil.sendOperationToMasterNode(nodeEngine, operation);
}
- public CheckpointCoordinator getCheckpointCoordinator(long pipelineId) {
- return coordinatorMap.get(pipelineId);
+ public InvocationFuture<?> notifyCheckpointFinished(CheckpointFinishedOperation operation) {
+ return NodeEngineUtil.sendOperationToMemberNode(nodeEngine, operation, subtaskWithAddresses.get(operation.getTaskInfo().getSubtaskId()));
Review Comment:
Same as above.
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/operation/CheckpointFinishedOperation.java:
##########
@@ -50,21 +51,23 @@ public int getClassId() {
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
- out.writeLong(jobId);
- out.writeLong(pipelineId);
out.writeLong(checkpointId);
+ out.writeObject(taskInfo);
+ out.writeBoolean(successful);
}
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
- jobId = in.readLong();
- pipelineId = in.readLong();
checkpointId = in.readLong();
+ taskInfo = in.readObject(TaskInfo.class);
+ successful = in.readBoolean();
}
@Override
protected PassiveCompletableFuture<?> doRun() throws Exception {
- // TODO: Notifies all tasks of the pipeline about the status of the checkpoint
+ SeaTunnelServer server = getService();
+ Task task = server.getTaskExecutionService().getExecutionContext(taskInfo.getTaskGroupId())
Review Comment:
Please note that this may cause a `NullPointException` because `server.getTaskExecutionService().getExecutionContext(taskInfo.getTaskGroupId())` may return `null`. So I suggest you add retry at the place where this operation is called.
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/operation/CheckpointTriggerOperation.java:
##########
@@ -44,16 +53,21 @@ public int getClassId() {
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
out.writeObject(checkpointBarrier);
+ out.writeObject(taskInfo);
}
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
checkpointBarrier = in.readObject(CheckpointBarrier.class);
+ taskInfo = in.readObject(TaskInfo.class);
}
@Override
- protected PassiveCompletableFuture<?> doRun() throws Exception {
- // TODO: All source Vertexes executed
- return null;
+ public void run() {
+ SeaTunnelServer server = getService();
+ SourceSplitEnumeratorTask<?> task = server.getTaskExecutionService()
Review Comment:
Same as above.
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/operation/TaskCompletedOperation.java:
##########
@@ -54,12 +59,10 @@ protected void readInternal(ObjectDataInput in) throws IOException {
}
@Override
- protected PassiveCompletableFuture<?> doRun() throws Exception {
- CheckpointCoordinator checkpointCoordinator = ((SeaTunnelServer) getService())
+ public void run() {
Review Comment:
Because `PhysicalPlan` and `CheckPointManager` all run on Coordinator Node, So you can get the taskFuture by `JobMaster.PhysicalPlan.SubPlan.PhysicalVertex.taskFuture` and add you callback function .
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointCoordinator.java:
##########
@@ -42,11 +54,60 @@ public class CheckpointCoordinator {
private final CheckpointCoordinatorConfiguration config;
- public CheckpointCoordinator(CheckpointPlan plan,
+ public CheckpointCoordinator(CheckpointManager manager,
+ long jobId,
+ CheckpointPlan plan,
CheckpointCoordinatorConfiguration config) {
+ this.checkpointManager = manager;
+ this.jobId = jobId;
+ this.pipelineId = plan.getPipelineId();
this.plan = plan;
this.config = config;
this.pendingCheckpoints = new LinkedHashMap<>();
this.completedCheckpoints = new LinkedHashMap<>();
}
+
+ protected void acknowledgeTask(TaskAcknowledgeOperation ackOperation) {
+ final long checkpointId = ackOperation.getCheckpointId();
+ final PendingCheckpoint pendingCheckpoint = pendingCheckpoints.get(checkpointId);
+ if (pendingCheckpoint == null) {
+ LOG.debug("job: {}, pipeline: {}, the checkpoint({}) don't exist.", jobId, pipelineId, checkpointId);
+ return;
+ }
+ pendingCheckpoint.acknowledgeTask(ackOperation.getTaskInfo(), ackOperation.getStates());
+ if (pendingCheckpoint.isFullyAcknowledged()) {
+ CompletedCheckpoint completedCheckpoint = completePendingCheckpoint(pendingCheckpoint);
+ pendingCheckpoints.remove(checkpointId);
+ completedCheckpoints.put(checkpointId, completedCheckpoint);
+ }
+ }
+
+ public CompletedCheckpoint completePendingCheckpoint(PendingCheckpoint pendingCheckpoint) {
+ notifyCheckpointCompleted(pendingCheckpoint.getCheckpointId());
+ return new CompletedCheckpoint(
+ jobId,
+ pipelineId,
+ pendingCheckpoint.getCheckpointId(),
+ pendingCheckpoint.getCheckpointTimestamp(),
+ System.currentTimeMillis(),
+ pendingCheckpoint.getTaskStates(),
+ pendingCheckpoint.getTaskStatistics());
+ }
+
+ public List<InvocationFuture> notifyCheckpointCompleted(long checkpointId) {
+ return plan.getPipelineTaskIds()
+ .entrySet()
+ .stream()
+ .map(entry ->
+ new CheckpointFinishedOperation(checkpointId,
+ new TaskInfo(jobId, entry.getValue(), entry.getKey()),
+ true)
+ ).map(checkpointManager::notifyCheckpointFinished)
Review Comment:
We cannot be prepared to know whether the task is running, we only know it deploy complete. So I suggest add retry here. You can use `RetryUtils.retryWithException` to do this.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] Hisoka-X merged pull request #2556: [engine][checkpoint] checkpoint flow
Posted by GitBox <gi...@apache.org>.
Hisoka-X merged PR #2556:
URL: https://github.com/apache/incubator-seatunnel/pull/2556
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] ashulin commented on a diff in pull request #2556: [engine][checkpoint] checkpoint flow
Posted by GitBox <gi...@apache.org>.
ashulin commented on code in PR #2556:
URL: https://github.com/apache/incubator-seatunnel/pull/2556#discussion_r957964856
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/operation/TaskCompletedOperation.java:
##########
@@ -54,12 +59,10 @@ protected void readInternal(ObjectDataInput in) throws IOException {
}
@Override
- protected PassiveCompletableFuture<?> doRun() throws Exception {
- CheckpointCoordinator checkpointCoordinator = ((SeaTunnelServer) getService())
+ public void run() {
Review Comment:
`PhysicalVertex.taskFuture` is a notification of task group granularity, which does not meet the requirements of checkpoint.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org