Skip to content

Commit

Permalink
[Fix][Zeta] Fix CheckpointCoordinator report NPE when ack not existed…
Browse files Browse the repository at this point in the history
… pending checkpoint (apache#5909)
  • Loading branch information
Hisoka-X authored and DESKTOP-GHPCOV0\dingaolong committed Dec 19, 2023
1 parent eb528a1 commit ae0ad11
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions seatunnel-engine/seatunnel-engine-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>checkpoint-storage-local-file</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-hadoop3-3.1.4-uber</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,10 @@ protected void cleanPendingCheckpoint(CheckpointCloseReason closedReason) {
protected void acknowledgeTask(TaskAcknowledgeOperation ackOperation) {
final long checkpointId = ackOperation.getBarrier().getId();
final PendingCheckpoint pendingCheckpoint = pendingCheckpoints.get(checkpointId);
if (pendingCheckpoint == null) {
LOG.info("skip already ack checkpoint " + checkpointId);
return;
}
TaskLocation location = ackOperation.getTaskLocation();
LOG.debug(
"task[{}]({}/{}) ack. {}",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.checkpoint;

import org.apache.seatunnel.engine.checkpoint.storage.exception.CheckpointStorageException;
import org.apache.seatunnel.engine.common.config.server.CheckpointConfig;
import org.apache.seatunnel.engine.common.config.server.CheckpointStorageConfig;
import org.apache.seatunnel.engine.core.checkpoint.CheckpointType;
import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
import org.apache.seatunnel.engine.server.checkpoint.operation.TaskAcknowledgeOperation;
import org.apache.seatunnel.engine.server.execution.TaskGroupLocation;
import org.apache.seatunnel.engine.server.execution.TaskLocation;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import static org.apache.seatunnel.engine.common.Constant.IMAP_RUNNING_JOB_STATE;

public class CheckpointCoordinatorTest
extends AbstractSeaTunnelServerTest<CheckpointCoordinatorTest> {

@Test
void testACKNotExistPendingCheckpoint() throws CheckpointStorageException {
CheckpointConfig checkpointConfig = new CheckpointConfig();
checkpointConfig.setStorage(new CheckpointStorageConfig());
Map<Integer, CheckpointPlan> planMap = new HashMap<>();
planMap.put(1, CheckpointPlan.builder().pipelineId(1).build());
CheckpointManager checkpointManager =
new CheckpointManager(
1L,
false,
nodeEngine,
null,
planMap,
checkpointConfig,
instance.getExecutorService("test"),
nodeEngine.getHazelcastInstance().getMap(IMAP_RUNNING_JOB_STATE));
checkpointManager.acknowledgeTask(
new TaskAcknowledgeOperation(
new TaskLocation(new TaskGroupLocation(1L, 1, 1), 1, 1),
new CheckpointBarrier(
999, System.currentTimeMillis(), CheckpointType.CHECKPOINT_TYPE),
new ArrayList<>()));
}
}

0 comments on commit ae0ad11

Please sign in to comment.