Skip to content

Commit 44cb00e

Browse files
biniona-mongodbnlarew
authored andcommitted
Docsp 15803 sink error handling (#147)
Co-authored-by: Nick Larew <[email protected]>
1 parent 726f969 commit 44cb00e

File tree

3 files changed

+202
-7
lines changed

3 files changed

+202
-7
lines changed

source/sink-connector/fundamentals.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ Fundamentals
99
Write Strategies </sink-connector/fundamentals/write-strategies>
1010
Post-processors </sink-connector/fundamentals/post-processors>
1111
Data Transformations </sink-connector/fundamentals/data-transformations>
12-
Configuration for Handling Errors </sink-connector/fundamentals/handling-errors>
12+
Error Handling Strategies </sink-connector/fundamentals/error-handling-strategies>
1313
Change Data Capture </sink-connector/fundamentals/change-data-capture>
1414

1515
asdf
16-
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
=========================
2+
Error Handling Strategies
3+
=========================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
Overview
14+
--------
15+
16+
In this guide, you can learn how to handle errors in your sink connector.
17+
The following list shows some common scenarios that cause your sink
18+
connector to experience an error:
19+
20+
- You write to a topic using Avro serialization and try to decode your messages from
21+
that topic using Protobuf deserialization
22+
- You use a change data capture handler on a message that does not contain change
23+
event documents
24+
- You apply an invalid single message transform to incoming documents
25+
26+
When your sink connector encounters an error it does two actions:
27+
28+
- :ref:`Handles the Error <kafka-sink-handle-errors>`
29+
- :ref:`Logs the Error <kafka-sink-log-errors>`
30+
31+
For a tutorial on error handling in the {+mkc+}, see our
32+
tutorials section <TODO: link to configure errors tutorials>
33+
34+
.. _kafka-sink-handle-errors:
35+
36+
Handle Errors
37+
-------------
38+
39+
When your connector encounters an error, it needs to handle it in some way.
40+
Your sink connector can do the following in response to an error:
41+
42+
- :ref:`Stop <kafka-sink-errors-stop>` *default*
43+
- :ref:`Tolerate Errors <kafka-sink-tolerate-errors>`
44+
- :ref:`Write Errant Messages to a Topic (Dead Letter Queue) <kafka-sink-errors-dlq>`
45+
46+
.. _kafka-sink-errors-stop:
47+
48+
Stop
49+
~~~~
50+
51+
By default, your sink connector terminates and stops processing messages
52+
when it encounters an error. This is a good option for you if any error in
53+
your sink connector indicates a serious problem.
54+
55+
When your sink connector crashes, you must do one of the
56+
following actions and then restart your connector to resume processing messages:
57+
58+
- Allow your sink connector to temporarily :ref:`tolerate errors <kafka-sink-tolerate-errors>`
59+
- Update your sink connector's configuration to allow it to process the message
60+
- Remove the errant message from your topic
61+
62+
You can have your sink connector stop when it encounters an error by either not
63+
specifying any value for the ``errors.tolerance`` option, or by
64+
adding the following to your connector configuration:
65+
66+
.. code-block:: properties
67+
68+
errors.tolerance=none
69+
70+
.. _kafka-sink-tolerate-errors:
71+
72+
Tolerate Errors
73+
~~~~~~~~~~~~~~~
74+
75+
You can configure your sink connector to tolerate all errors and never stop
76+
processing messages. This is a good option for getting your sink connector up and
77+
running quickly, but you run the risk of missing problems in your connector
78+
as you do not receive any feedback if something goes wrong.
79+
80+
You can have your sink connector tolerate all errors by specifying the following
81+
option:
82+
83+
.. code-block:: properties
84+
85+
errors.tolerance=all
86+
87+
.. _kafka-sink-errors-dlq:
88+
89+
Dead Letter Queue
90+
~~~~~~~~~~~~~~~~~
91+
92+
You can configure your sink connector to write errant messages to a
93+
topic, called a **dead letter queue**, for you to inspect or process further.
94+
A dead letter queue is a location in message queueing
95+
systems such as {+ak+} where the system routes errant messages instead of
96+
crashing or ignoring the error. Dead letter queues combine the feedback of
97+
stopping the program with the durability of tolerating all errors, and are a
98+
good error handling starting point for most deployments.
99+
100+
You can have your sink connector route all errant messages to a dead
101+
letter queue by specifying the following options:
102+
103+
.. code-block:: properties
104+
105+
errors.tolerance=all
106+
errors.deadletterqueue.topic.name=<name of topic to use as dead letter queue>
107+
108+
If you want to include the specific reason for the error as well as the
109+
errant message, use the following option:
110+
111+
.. code-block:: properties
112+
113+
errors.deadletterqueue.context.headers.enable=true
114+
115+
.. important:: Bulk Write Errors
116+
117+
If an error occurs while performing a bulk write to MongoDB, you must specify
118+
the following to log any information about the error to a dead letter queue:
119+
120+
.. code-block:: properties
121+
122+
errors.tolerance=all
123+
mongo.errors.tolerance=none
124+
errors.deadletterqueue.topic.name=<name of topic to use as dead letter queue>
125+
126+
We will fix this special case soon. To track the status of this issue,
127+
see :issue:`this JIRA ticket <KAFKA-223>`.
128+
129+
For more information on the ``mongo.errors.tolerance`` option, see our
130+
section on :ref:`connector level options <kakfa-sink-connector-level>`.
131+
132+
For more information, see Confluent's guide on
133+
`Dead Letter Queues <https://docs.confluent.io/cloud/current/connectors/dead-letter-queue.html#dead-letter-queue>`__.
134+
135+
.. _kafka-sink-log-errors:
136+
137+
Log Errors
138+
----------
139+
140+
You can record tolerated and untolerated errors to a log file. Click on the tabs
141+
to see how to log errors:
142+
143+
.. tabs::
144+
145+
.. tab:: Untolerated Errors
146+
:tabid: untolerated-errors
147+
148+
The following default option makes {+kc+} write only untolerated errors to its application log:
149+
150+
.. code-block:: properties
151+
152+
errors.log.enable=false
153+
154+
.. tab:: Tolerated and Untolerated Errors
155+
:tabid: tolerated-errors
156+
157+
The following option makes {+kc+} write both tolerated and untolerated errors to its
158+
application log:
159+
160+
.. code-block:: properties
161+
162+
errors.log.enable=true
163+
164+
If you would like to log metadata about your message, such as your message's
165+
topic and offset, use the following option:
166+
167+
.. code-block:: properties
168+
169+
errors.log.include.messages=true
170+
171+
For more information, see Confluent's guide on
172+
`logging with Kafka Connect <https://docs.confluent.io/platform/current/connect/logging.html>`__.
173+
174+
.. _kakfa-sink-connector-level:
175+
176+
Connector Level Options
177+
-----------------------
178+
179+
The {+mkc+} provides options that allow you to configure error
180+
handling at the connector level. The options are as follows:
181+
182+
.. list-table::
183+
:header-rows: 1
184+
:widths: 50 50
185+
186+
* - Kafka Connect Option
187+
- {+mkc+} Option
188+
189+
* - ``errors.tolerance``
190+
- ``mongo.errors.tolerance``
191+
192+
* - ``errors.log.enable``
193+
- ``mongo.errors.log.enable``
194+
195+
You want to use these options if you want your connector to respond differently
196+
to errors related to MongoDB than to errors related to the {+kc+} framework.
197+
198+
For more information, see the following resources:
199+
200+
- Guide on Sink Connector Configuration Properties <TODO: link to correct location of guide>
201+
- :issue:`New Names for Error Tolerance Options JIRA Ticket <KAFKA-215>`

source/sink-connector/fundamentals/handling-errors.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)