Repository navigation
[Fix-18644][Master] Fix serial command races and restart identity reuse #18645
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
07d04a9
[Fix-18644][Registry] Reconcile HA roles using instance ownership
michaellx1057 5fc5a12
[Fix-18644][Registry] Simplify instance identity following review
michaellx1057 90043b1
[Fix-18644][Master] Prevent overlapping coordinator runs during restart
michaellx1057 72222ba
[Fix-18644][Registry] Narrow HA repair to ownership and coordinator h…
michaellx1057 f10095c
[Fix-18644][Registry] Serialize HA transitions and coordinator shutdown
michaellx1057 62900da
[Fix-18644][Registry] Guard HA promotion against selector removal
michaellx1057 f040003
[Fix-18644][Registry] Serialize HA handoff and coordinator shutdown
michaellx1057 6a3266c
[Fix-18644][Master] Guard serial commands against concurrent handling
michaellx1057 925747f
[Fix-18644][Master] Rename serial launch and log skipped transitions
michaellx1057 2cbf6ab
[Fix-18644][Master] Use sequential coordinator shutdown
michaellx1057 106b9af
[Fix-18644][Registry] Separate HA role events from Registry I/O
michaellx1057 9cc6383
[Fix-18644][Registry] Use EventBus for HA role handling
michaellx1057 c7480c8
[Fix-18644][Master] Narrow fix to identity and serial transactions
michaellx1057 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...c/test/java/org/apache/dolphinscheduler/dao/repository/impl/SerialCommandDaoImplTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /* | ||
| * 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.dolphinscheduler.dao.repository.impl; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import org.apache.dolphinscheduler.dao.BaseDaoTest; | ||
| import org.apache.dolphinscheduler.dao.entity.SerialCommand; | ||
| import org.apache.dolphinscheduler.dao.model.SerialCommandDto; | ||
| import org.apache.dolphinscheduler.dao.repository.SerialCommandDao; | ||
|
|
||
| import java.util.Date; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
|
|
||
| class SerialCommandDaoImplTest extends BaseDaoTest { | ||
|
|
||
| @Autowired | ||
| private SerialCommandDao serialCommandDao; | ||
|
|
||
| @Test | ||
| void testWaitingCommandCanOnlyBeAcquiredOnce() { | ||
| SerialCommand command = insertWaitingCommand(); | ||
| Date updateTime = new Date(System.currentTimeMillis() + 1000); | ||
| assertTrue(serialCommandDao.launchSerialCommand(command.getId(), updateTime)); | ||
| assertFalse(serialCommandDao.launchSerialCommand(command.getId(), new Date())); | ||
| SerialCommand acquired = serialCommandDao.queryById(command.getId()); | ||
| assertEquals(SerialCommandDto.State.LAUNCHED.getValue(), acquired.getState()); | ||
| assertEquals(updateTime, acquired.getUpdateTime()); | ||
| } | ||
|
|
||
| @Test | ||
| void testStaleWaitingSnapshotCannotDeleteLaunchedCommand() { | ||
| SerialCommand command = insertWaitingCommand(); | ||
| assertTrue(serialCommandDao.launchSerialCommand(command.getId(), new Date())); | ||
| assertFalse(serialCommandDao.deleteByIdAndState(command.getId(), SerialCommandDto.State.WAITING)); | ||
| assertNotNull(serialCommandDao.queryById(command.getId())); | ||
| } | ||
|
|
||
| @Test | ||
| void testWaitingCommandCanOnlyBeDiscardedOnce() { | ||
| SerialCommand command = insertWaitingCommand(); | ||
| assertTrue(serialCommandDao.deleteByIdAndState(command.getId(), SerialCommandDto.State.WAITING)); | ||
| assertFalse(serialCommandDao.deleteByIdAndState(command.getId(), SerialCommandDto.State.WAITING)); | ||
| assertNull(serialCommandDao.queryById(command.getId())); | ||
| } | ||
|
|
||
| @Test | ||
| void testDiscardedCommandCannotBeAcquired() { | ||
| SerialCommand command = insertWaitingCommand(); | ||
| assertTrue(serialCommandDao.deleteByIdAndState(command.getId(), SerialCommandDto.State.WAITING)); | ||
| assertFalse(serialCommandDao.launchSerialCommand(command.getId(), new Date())); | ||
| } | ||
|
|
||
| private SerialCommand insertWaitingCommand() { | ||
| SerialCommand command = SerialCommand.builder() | ||
| .workflowInstanceId(1) | ||
| .workflowDefinitionCode(1L) | ||
| .workflowDefinitionVersion(1) | ||
| .command("{}") | ||
| .state(SerialCommandDto.State.WAITING.getValue()) | ||
| .createTime(new Date()) | ||
| .updateTime(new Date()) | ||
| .build(); | ||
| assertEquals(1, serialCommandDao.insert(command)); | ||
| return command; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.