-
Notifications
You must be signed in to change notification settings - Fork 97
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
[SNOW-943288] Do not skip records when we're expecting the offset to be reset #729
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8eb8036
e2e test passes
sfc-gh-rcheng 9de5460
add avro, failing though
sfc-gh-rcheng 53db470
and not or
sfc-gh-rcheng d61d160
manual formatting
sfc-gh-rcheng 6996af5
personal nit
sfc-gh-rcheng 09b2d62
fix tests to actually repro
sfc-gh-rcheng 8639534
remove drop table tests
sfc-gh-rcheng f84e0bc
delete drop table tests and revert insertrecordtobuffer
sfc-gh-rcheng fbd1df2
autoformatting
sfc-gh-rcheng 5188952
merge master
sfc-gh-rcheng 669e182
add random row count and small pr comments
sfc-gh-rcheng 5274275
merge master
sfc-gh-rcheng 8fe850a
edit comment
sfc-gh-rcheng abc3121
remove droptable from testsuites
sfc-gh-rcheng e0ea3f0
Merge branch 'master' into rcheng-offsetissue
sfc-gh-rcheng bde0233
remove sleeps
sfc-gh-rcheng 6583b55
autoformatting
sfc-gh-rcheng 645d703
merge main
sfc-gh-rcheng 604ae6b
add it
sfc-gh-rcheng 152b28a
autoformatting
sfc-gh-rcheng 9e32250
add test back disabled
sfc-gh-rcheng 14d9de3
autoformatting
sfc-gh-rcheng 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,9 @@ public class TopicPartitionChannel { | |
* <li>If channel fails to fetch offsetToken from Snowflake, we reopen the channel and try to | ||
* fetch offset from Snowflake again | ||
* <li>If channel fails to ingest a buffer(Buffer containing rows/offsets), we reopen the | ||
* channel and try to fetch offset from Snowflake again | ||
* channel and try to fetch offset from Snowflake again. Schematization purposefully fails | ||
* the first buffer insert in order to alter the table, and then expects Kafka to resend | ||
* data | ||
* </ol> | ||
* | ||
* <p>In both cases above, we ask Kafka to send back offsets, strictly from offset number after | ||
|
@@ -124,7 +126,7 @@ public class TopicPartitionChannel { | |
* <p>This boolean is used to indicate that we reset offset in kafka and we will only buffer once | ||
* we see the offset which is one more than an offset present in Snowflake. | ||
*/ | ||
private boolean isOffsetResetInKafka; | ||
private boolean isOffsetResetInKafka = false; | ||
|
||
private final SnowflakeStreamingIngestClient streamingIngestClient; | ||
|
||
|
@@ -391,14 +393,13 @@ public void insertRecordToBuffer(SinkRecord kafkaSinkRecord) { | |
* | ||
* @param kafkaSinkRecord Record to check for above condition only in case of failures | ||
* (isOffsetResetInKafka = true) | ||
* @param currentProcessedOffset The current processed offset | ||
* @return true if this record can be skipped to add into buffer, false otherwise. | ||
*/ | ||
private boolean shouldIgnoreAddingRecordToBuffer( | ||
SinkRecord kafkaSinkRecord, long currentProcessedOffset) { | ||
// Don't skip rows if there is no offset reset or there is no offset token information in the | ||
// channel | ||
if (!isOffsetResetInKafka | ||
|| currentProcessedOffset == NO_OFFSET_TOKEN_REGISTERED_IN_SNOWFLAKE) { | ||
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. crux of the change is removing this OR |
||
SinkRecord kafkaSinkRecord, final long currentProcessedOffset) { | ||
// Don't skip rows if there is no offset reset | ||
if (!isOffsetResetInKafka) { | ||
return false; | ||
} | ||
|
||
|
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
28 changes: 28 additions & 0 deletions
28
test/rest_request_template/test_schema_evolution_w_random_row_count.json
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,28 @@ | ||
{ | ||
"name": "SNOWFLAKE_CONNECTOR_NAME", | ||
"config": { | ||
"connector.class": "com.snowflake.kafka.connector.SnowflakeSinkConnector", | ||
"topics": "SNOWFLAKE_TEST_TOPIC0,SNOWFLAKE_TEST_TOPIC1", | ||
"snowflake.topic2table.map": "SNOWFLAKE_TEST_TOPIC0:SNOWFLAKE_CONNECTOR_NAME,SNOWFLAKE_TEST_TOPIC1:SNOWFLAKE_CONNECTOR_NAME", | ||
"tasks.max": "1", | ||
"buffer.flush.time": "60", | ||
"buffer.count.records": "300", | ||
"buffer.size.bytes": "5000000", | ||
"snowflake.url.name": "SNOWFLAKE_HOST", | ||
"snowflake.user.name": "SNOWFLAKE_USER", | ||
"snowflake.private.key": "SNOWFLAKE_PRIVATE_KEY", | ||
"snowflake.database.name": "SNOWFLAKE_DATABASE", | ||
"snowflake.schema.name": "SNOWFLAKE_SCHEMA", | ||
"snowflake.role.name": "SNOWFLAKE_ROLE", | ||
"snowflake.ingestion.method": "SNOWPIPE_STREAMING", | ||
"key.converter": "org.apache.kafka.connect.storage.StringConverter", | ||
"value.converter": "org.apache.kafka.connect.json.JsonConverter", | ||
"value.converter.schemas.enable": "false", | ||
"jmx": "true", | ||
"errors.tolerance": "all", | ||
"errors.log.enable": true, | ||
"errors.deadletterqueue.topic.name": "DLQ_TOPIC", | ||
"errors.deadletterqueue.topic.replication.factor": 1, | ||
"snowflake.enable.schematization": true | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,11 @@ def __init__(self, driver, nameSalt): | |
self.fileName = "travis_correct_schema_evolution_w_auto_table_creation_avro_sr" | ||
self.topics = [] | ||
self.table = self.fileName + nameSalt | ||
self.recordNum = 100 | ||
|
||
# records | ||
self.initialRecordCount = 12 | ||
self.flushRecordCount = 300 | ||
self.recordNum = self.initialRecordCount + self.flushRecordCount | ||
|
||
for i in range(2): | ||
self.topics.append(self.table + str(i)) | ||
|
@@ -78,8 +82,15 @@ def getConfigFileName(self): | |
|
||
def send(self): | ||
for i, topic in enumerate(self.topics): | ||
# send initial batch | ||
value = [] | ||
for _ in range(self.initialRecordCount): | ||
value.append(self.records[i]) | ||
self.driver.sendAvroSRData(topic, value, self.valueSchema[i], key=[], key_schema="", partition=0) | ||
|
||
# send second batch that should flush | ||
value = [] | ||
for _ in range(self.recordNum): | ||
for _ in range(self.flushRecordCount): | ||
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. confirmed that these tests repro the issue without the changes |
||
value.append(self.records[i]) | ||
self.driver.sendAvroSRData(topic, value, self.valueSchema[i], key=[], key_schema="", partition=0) | ||
|
||
|
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.
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.
required for formatter to pass for some reason. not relevant to this PR, just a small format change