PIP-166: Function add MANUAL
delivery semantics
#15560
Labels
release/important-notice
The changes which are important should be mentioned in the release note
Stale
type/PIP
Discussion thread: https://lists.apache.org/thread/4f2w1mqvhhs3mvccbcg2sk19b60xwkgf
Vote thread: https://lists.apache.org/thread/1ojcc12sxd87nz49yrflk8jv2nk98hvr (Pass)
Motivation
Currently, Function supports three delivery semantics and also provides autoAck to control whether to automatically ack.
Because autoAck affects the delivery semantics of Function, it can be confusing for users to understand the relationship between these two parameters.
For example, when the user configures
Guarantees == ATMOST_ONCE
andautoAck == false
, then the framework will not help the user to ack messages, and the processing semantics may becomeATLEAST_ONCE
.The delivery semantics provided by Function should be clear. When the user sets the guarantees, the framework should ensure point-to-point semantic processing and cannot be affected by other parameters.
Goal
Add
MANUAL
delivery semantics and deleteautoAck
config.The original intention of
autoAck
semantics is that users want to control the timing of ack by themselves. When autoAck == false, the processing semantics provided by the framework should be invalid. Then we can addMANUAL
processing semantics to replace the autoAck == false scenario.When the user configuration
ProcessingGuarantees == MANUAL
, the framework does not help the user to do any ack operations, and the ack is left to the user to handle. In other cases, the framework guarantees processing semantics.The processing logic of all semantics is:
ATMOST_ONCE
: When the message is read by the client, it is immediately acknowledged, and only then the function is executed, thus guaranteeing it will not run more than once.ATLEAST_ONCE
: The message is acknowledged after the function finished execution, thus it will be run at least once.EFFECTIVELY_ONCE
: The message is acknowledged after the function finished execution. Depends on pulsar deduplication, and provides end-to-end effectively once processing.MANUAL
: The function framework does not do the ack operation, it is handled by the user inside the function.API Changes
MANUAL
type to ProcessingGuarantees.(and also Function.proto)
(and also Function.proto)
I would issue a WARN when reading configuring the function (thus emitted once) when the user actively configured
autoAck=false
and warn them that this configuration is deprecated and they should switch to the MANUAL ProcessingGuarantee configuration option.PulsarSinkProcessor
implements:PulsarSinkManualProcessor
.PulsarSinkManualProcessor
do not do any ack operation.Implementation
ATMOST_ONCE
, add verifyautoAck
must betrue
. If the validation fails, let the function fail to start (This temporarily resolves the configuration ambiguity). When autoAck is subsequently removed, the message will be acked immediately after receiving the message.pulsar/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
Lines 271 to 276 in c49a977
When user call
record.ack()
in function, justProcessingGuarantees == MANUAL
can be work. In turn, whenProcessingGuarantees != MANUAL
, user callrecord.ack()
is invalid(print warn log once).Add documentation that autoAck will be deprecated, and explain the
MANUAL
semantics and whenrecord.ack()
takes effect.For the windows function, the implementation of the currently delivery guarantee is problematic. Currently only support
ATMOST_ONCE
andEFFECTIVELY_ONCE
guarantees. Because the message has been asked before sending output topic.As follows code,
onExpiry
precedesonActivation
.pulsar/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/windowing/WindowFunctionExecutor.java
Lines 205 to 222 in eeb22ba
So, treat windows function as special function. Override delivery semantics in
FunctionConfig
asMANUAL
, add guarantee configuration in Windows, then handle the ack timing according to this configuration insideFunction Windows
.FunctionConfigUtils#convert
Plan test
Compatibility
Incompatible case
Guarantees == ATMOST_ONCE
andautoAck == false
.ATLEAST_ONCE
.autoAck == true
and callrecord.ack()
in function.Guarantees == MANUAL
take effect, In other cases, the warning log will be printed.An additional explanation is required, these incompatible cases can all be considered bugs of the current implementation.
The text was updated successfully, but these errors were encountered: