You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: Prevent ElasticSearch from Skipping Records After Tombstone (#172)
* Fix: Prevent ElasticSearch from Skipping Records After Tombstone
Overview
This pull request addresses a critical bug in ElasticSearch versions 6 (ES6) and 7 (ES7) where records following a tombstone are inadvertently skipped during the insertion process. The issue stemmed from an erroneous return statement that halted the processing of subsequent records.
Background
In the current implementation, when a tombstone record is encountered within a sequence of records to be written to ElasticSearch, the insertion process prematurely exits due to a return instruction. This results in all records following the tombstone being ignored, leading to incomplete data ingestion and potential inconsistencies within the ElasticSearch indices.
Changes Made
Refactored Insert Method:
Modularization: The original insert method has been decomposed into smaller, more focused functions. This enhances code readability, maintainability, and facilitates easier testing.
Detailed Log Entries: Added log statements at key points within the insertion workflow
ES Error not handled: Previously the response from ElasticSearch ignored failures. With this change, if any of the batch fail, the sink will raise an exception.
* Avoid sending empty requests
* Fix the unit tests
---------
Co-authored-by: stheppi <[email protected]>
Copy file name to clipboardexpand all lines: kafka-connect-elastic6/src/test/scala/io/lenses/streamreactor/connect/elastic6/ElasticJsonWriterTest.scala
+3-2
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,8 @@ class ElasticJsonWriterTest extends TestBase with MockitoSugar {
86
86
87
87
valsourceTopic="SOURCE"
88
88
valtargetShard="SHARD"
89
-
valkcql=Kcql.parse(s"INSERT INTO $targetShard SELECT * FROM $sourceTopic")
89
+
valkcql=
90
+
Kcql.parse(s"INSERT INTO $targetShard SELECT * FROM $sourceTopic PROPERTIES('behavior.on.null.values'='IGNORE')")
90
91
91
92
valrecordKey="KEY"
92
93
valtombstoneValue:Null=null
@@ -161,7 +162,7 @@ class ElasticJsonWriterTest extends TestBase with MockitoSugar {
0 commit comments