-
Notifications
You must be signed in to change notification settings - Fork 12
feat: error handling in sink connector #142
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
Changes from all commits
d4a6105
ac2844e
b602638
6c314e1
8fdcdaf
5ca3cc5
ed332d7
286f095
98c246d
0fb4321
6e8cea6
113b92d
b9b9ffc
0984c7b
65300e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ package org.neo4j.connectors.kafka.sink.strategy | |
|
|
||
| import org.neo4j.cdc.client.model.NodeEvent | ||
| import org.neo4j.cdc.client.model.RelationshipEvent | ||
| import org.neo4j.connectors.kafka.exceptions.InvalidDataException | ||
| import org.neo4j.connectors.kafka.sink.SinkStrategy | ||
| import org.neo4j.cypherdsl.core.Cypher | ||
| import org.neo4j.cypherdsl.core.Node | ||
|
|
@@ -30,6 +31,10 @@ class CdcSchemaHandler(val topic: String, private val renderer: Renderer) : CdcH | |
| override fun strategy() = SinkStrategy.CDC_SCHEMA | ||
|
|
||
| override fun transformCreate(event: NodeEvent): Query { | ||
| if (event.after == null) { | ||
| throw InvalidDataException("create operation requires 'after' field in the event object") | ||
| } | ||
|
|
||
| val node = buildNode(event.keys, "n") | ||
| val stmt = | ||
| Cypher.merge(node) | ||
|
|
@@ -48,6 +53,13 @@ class CdcSchemaHandler(val topic: String, private val renderer: Renderer) : CdcH | |
| } | ||
|
|
||
| override fun transformUpdate(event: NodeEvent): Query { | ||
| if (event.before == null) { | ||
|
Contributor
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. should we also have a similar validation for create and delete events, maybe in a follow-up PR. wdyt?
Contributor
Author
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. yes, I think we should, since they can also fail if before or after is null |
||
| throw InvalidDataException("update operation requires 'before' field in the event object") | ||
| } | ||
| if (event.after == null) { | ||
| throw InvalidDataException("update operation requires 'after' field in the event object") | ||
| } | ||
|
|
||
| val node = buildNode(event.keys, "n") | ||
| val stmt = | ||
| Cypher.merge(node) | ||
|
|
@@ -81,6 +93,10 @@ class CdcSchemaHandler(val topic: String, private val renderer: Renderer) : CdcH | |
| } | ||
|
|
||
| override fun transformCreate(event: RelationshipEvent): Query { | ||
| if (event.after == null) { | ||
| throw InvalidDataException("create operation requires 'after' field in the event object") | ||
| } | ||
|
|
||
| val (start, end, rel) = buildRelationship(event, "r") | ||
| val stmt = | ||
| Cypher.merge(start) | ||
|
|
@@ -93,6 +109,13 @@ class CdcSchemaHandler(val topic: String, private val renderer: Renderer) : CdcH | |
| } | ||
|
|
||
| override fun transformUpdate(event: RelationshipEvent): Query { | ||
| if (event.before == null) { | ||
| throw InvalidDataException("update operation requires 'before' field in the event object") | ||
| } | ||
| if (event.after == null) { | ||
| throw InvalidDataException("update operation requires 'after' field in the event object") | ||
| } | ||
|
|
||
| val (start, end, rel) = buildRelationship(event, "r") | ||
| val stmt = | ||
| Cypher.merge(start) | ||
|
|
||
This file was deleted.
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.
what was the reason for this particular threshold again? I forgot :|
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.
also, shouldn't we limit the number of retries here? or even not retry at all, since the driver has retries built in
writeTransactionThere 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.
This check is to find the specific sink record which makes connector throw the exception
If I didn't misunderstand the question, yeah same with the first question actually, the retry here is to find problematic message and report only that message, not to get the message work by retying it