-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
mssql-source:upgrade debezium version to 1.9.6 #18732
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
edc1985
mssql-source:upgrade debezium version to 1.9.6
subodh1810 8e2cd5a
more improvements
subodh1810 29e87d7
Merge branch 'master' into upgrade-debezium-version-mssql-source
subodh1810 f435717
Merge branch 'master' into upgrade-debezium-version-mssql-source
subodh1810 b5e596a
upgrade version
subodh1810 6168130
auto-bump connector version
octavia-squidington-iii 311cd36
fix test
subodh1810 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 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 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 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
71 changes: 71 additions & 0 deletions
71
...9-6/src/main/java/io/airbyte/integrations/debezium/internals/FirstRecordWaitTimeUtil.java
This file contains 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,71 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.debezium.internals; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import java.time.Duration; | ||
import java.util.Optional; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class FirstRecordWaitTimeUtil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a brief class comment here? |
||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(FirstRecordWaitTimeUtil.class); | ||
|
||
public static final Duration MIN_FIRST_RECORD_WAIT_TIME = Duration.ofMinutes(2); | ||
public static final Duration MAX_FIRST_RECORD_WAIT_TIME = Duration.ofMinutes(20); | ||
public static final Duration DEFAULT_FIRST_RECORD_WAIT_TIME = Duration.ofMinutes(5); | ||
|
||
public static void checkFirstRecordWaitTime(final JsonNode config) { | ||
// we need to skip the check because in tests, we set initial_waiting_seconds | ||
// to 5 seconds for performance reasons, which is shorter than the minimum | ||
// value allowed in production | ||
if (config.has("is_test") && config.get("is_test").asBoolean()) { | ||
return; | ||
} | ||
|
||
final Optional<Integer> firstRecordWaitSeconds = getFirstRecordWaitSeconds(config); | ||
if (firstRecordWaitSeconds.isPresent()) { | ||
final int seconds = firstRecordWaitSeconds.get(); | ||
if (seconds < MIN_FIRST_RECORD_WAIT_TIME.getSeconds() || seconds > MAX_FIRST_RECORD_WAIT_TIME.getSeconds()) { | ||
throw new IllegalArgumentException( | ||
String.format("initial_waiting_seconds must be between %d and %d seconds", | ||
MIN_FIRST_RECORD_WAIT_TIME.getSeconds(), MAX_FIRST_RECORD_WAIT_TIME.getSeconds())); | ||
} | ||
} | ||
} | ||
|
||
public static Duration getFirstRecordWaitTime(final JsonNode config) { | ||
final boolean isTest = config.has("is_test") && config.get("is_test").asBoolean(); | ||
Duration firstRecordWaitTime = DEFAULT_FIRST_RECORD_WAIT_TIME; | ||
|
||
final Optional<Integer> firstRecordWaitSeconds = getFirstRecordWaitSeconds(config); | ||
if (firstRecordWaitSeconds.isPresent()) { | ||
firstRecordWaitTime = Duration.ofSeconds(firstRecordWaitSeconds.get()); | ||
if (!isTest && firstRecordWaitTime.compareTo(MIN_FIRST_RECORD_WAIT_TIME) < 0) { | ||
LOGGER.warn("First record waiting time is overridden to {} minutes, which is the min time allowed for safety.", | ||
MIN_FIRST_RECORD_WAIT_TIME.toMinutes()); | ||
firstRecordWaitTime = MIN_FIRST_RECORD_WAIT_TIME; | ||
} else if (!isTest && firstRecordWaitTime.compareTo(MAX_FIRST_RECORD_WAIT_TIME) > 0) { | ||
LOGGER.warn("First record waiting time is overridden to {} minutes, which is the max time allowed for safety.", | ||
MAX_FIRST_RECORD_WAIT_TIME.toMinutes()); | ||
firstRecordWaitTime = MAX_FIRST_RECORD_WAIT_TIME; | ||
} | ||
} | ||
|
||
LOGGER.info("First record waiting time: {} seconds", firstRecordWaitTime.getSeconds()); | ||
return firstRecordWaitTime; | ||
} | ||
|
||
public static Optional<Integer> getFirstRecordWaitSeconds(final JsonNode config) { | ||
final JsonNode replicationMethod = config.get("replication_method"); | ||
if (replicationMethod != null && replicationMethod.has("initial_waiting_seconds")) { | ||
final int seconds = config.get("replication_method").get("initial_waiting_seconds").asInt(); | ||
return Optional.of(seconds); | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
} |
This file contains 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
51 changes: 51 additions & 0 deletions
51
...src/test/java/io/airbyte/integrations/debezium/internals/FirstRecordWaitTimeUtilTest.java
This file contains 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,51 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.debezium.internals; | ||
|
||
import static io.airbyte.integrations.debezium.internals.FirstRecordWaitTimeUtil.MAX_FIRST_RECORD_WAIT_TIME; | ||
import static io.airbyte.integrations.debezium.internals.FirstRecordWaitTimeUtil.MIN_FIRST_RECORD_WAIT_TIME; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.airbyte.commons.json.Jsons; | ||
import java.time.Duration; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class FirstRecordWaitTimeUtilTest { | ||
|
||
@Test | ||
void testGetFirstRecordWaitTime() { | ||
final JsonNode emptyConfig = Jsons.jsonNode(Collections.emptyMap()); | ||
assertDoesNotThrow(() -> FirstRecordWaitTimeUtil.checkFirstRecordWaitTime(emptyConfig)); | ||
assertEquals(Optional.empty(), FirstRecordWaitTimeUtil.getFirstRecordWaitSeconds(emptyConfig)); | ||
assertEquals(FirstRecordWaitTimeUtil.DEFAULT_FIRST_RECORD_WAIT_TIME, FirstRecordWaitTimeUtil.getFirstRecordWaitTime(emptyConfig)); | ||
|
||
final JsonNode normalConfig = Jsons.jsonNode(Map.of("replication_method", | ||
Map.of("method", "CDC", "initial_waiting_seconds", 500))); | ||
assertDoesNotThrow(() -> FirstRecordWaitTimeUtil.checkFirstRecordWaitTime(normalConfig)); | ||
assertEquals(Optional.of(500), FirstRecordWaitTimeUtil.getFirstRecordWaitSeconds(normalConfig)); | ||
assertEquals(Duration.ofSeconds(500), FirstRecordWaitTimeUtil.getFirstRecordWaitTime(normalConfig)); | ||
|
||
final int tooShortTimeout = (int) MIN_FIRST_RECORD_WAIT_TIME.getSeconds() - 1; | ||
final JsonNode tooShortConfig = Jsons.jsonNode(Map.of("replication_method", | ||
Map.of("method", "CDC", "initial_waiting_seconds", tooShortTimeout))); | ||
assertThrows(IllegalArgumentException.class, () -> FirstRecordWaitTimeUtil.checkFirstRecordWaitTime(tooShortConfig)); | ||
assertEquals(Optional.of(tooShortTimeout), FirstRecordWaitTimeUtil.getFirstRecordWaitSeconds(tooShortConfig)); | ||
assertEquals(MIN_FIRST_RECORD_WAIT_TIME, FirstRecordWaitTimeUtil.getFirstRecordWaitTime(tooShortConfig)); | ||
|
||
final int tooLongTimeout = (int) MAX_FIRST_RECORD_WAIT_TIME.getSeconds() + 1; | ||
final JsonNode tooLongConfig = Jsons.jsonNode(Map.of("replication_method", | ||
Map.of("method", "CDC", "initial_waiting_seconds", tooLongTimeout))); | ||
assertThrows(IllegalArgumentException.class, () -> FirstRecordWaitTimeUtil.checkFirstRecordWaitTime(tooLongConfig)); | ||
assertEquals(Optional.of(tooLongTimeout), FirstRecordWaitTimeUtil.getFirstRecordWaitSeconds(tooLongConfig)); | ||
assertEquals(MAX_FIRST_RECORD_WAIT_TIME, FirstRecordWaitTimeUtil.getFirstRecordWaitTime(tooLongConfig)); | ||
} | ||
|
||
} |
This file contains 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 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 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 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 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.
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.
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.
I just wanted to make sure that what was forgotten in Postgres (
TINYINT(1)
?) is taken care of here.