Repository navigation
Conversation
|
I'd like help with getting this included in the release of Pulsar 2.8.0. |
|
I am not sure I understand if this fix is resolving your problem or it is only a mitigation. |
It's only a mitigation for now, but it's still a useful feature for anyone who wants to disable function message batching for any other reason. |
| category = CATEGORY_FUNCTIONS, | ||
| doc = "Enables message batching between functions" | ||
| ) | ||
| private boolean isFunctionBatchingEnabledDefault = true; |
There was a problem hiding this comment.
This seems like a one-off config as in the there are no other configs in worker configs that define defaults for certain function configs. If we are going to let cluster admin set defaults for function configs at a cluster level, we should do it in a more comprehensive manner and not just have one-off configs like this.
jerrypeng
left a comment
There was a problem hiding this comment.
Will I am in favor of allowing users to configure whether functions should enable batching or not. I am not in favor of creating a "default" config for the enabling batching in worker config. This seems like a one-off thing as worker config currently does not define defaults for other function configs. I am in favor of creating a way for cluster admins to be able to define defaults for certain function configs at a cluster level, but it needs to be a more comprehensive mechanism and not just one-off configs.
Thanks for the feedback. I appreciate your review. What would that more comprehensive mechanism look like to you? Would the defaults still go into WorkerConfig? |
|
One of the challenges is that protobuf doesn't support null primitives, so it's not as simple as just checking the function config for a null and then using the corresponding WorkerConfig default if the function config property is null. If we just rely on the function config's default value for the default behavior, then there's no way for a cluster admin to change all the functions' behavior with one config change. (Instead, every function would need to be re-deployed.) I suppose I could create a new kind of ProducerBuilder (such as ProducerBuilderWithDefaults) that would be passed an object with the Function defaults and the WorkerConfig's function defaults, and it would provide the logic for each builder method to check the Function default, and if it's set to the protobuf default value, then it assumes the Function default was equivalent to "null" and then uses the corresponding property on the object with the WorkerConfig's function defaults. With that said, it doesn't look like each producer implementation uses pulsar.getProducerBuilder()... some of them use client.newProducer(..) (such as in PulsarSink, https://github.com/apache/pulsar/blob/master/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/sink/PulsarSink.java#L110), but I'm not sure we want to also expose all that to the client by creating a new client builder method like newProducerWithDefaults because I don't think the client should need to know those details. |
|
It looks like I can use the loadConf method on ProducerBuilderImpl (https://github.com/apache/pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerBuilderImpl.java#L121), so that might be cleaner than needing to decorate the ProducerBuilder with one that has builder methods that set defaults. |
|
@devinbost in WorkerConfig, we can add a new field call defaultFunctionConfig/defaultSourceConfig/defaultSinkConfig or defaultFunctionConfigFile/defaultSourceConfigFile/defaultSinkConfigFile if we just want to point to a separate file. In the worker config could look something like On registering the function, we merge the user provided function config with the default function config. |
|
/pulsarbot run-failure-checks |
2 similar comments
|
/pulsarbot run-failure-checks |
|
/pulsarbot run-failure-checks |
|
I have not been able to reproduce these test failures locally. Additional eyes would be helpful. |
|
/pulsarbot run-failure-checks |
1 similar comment
|
/pulsarbot run-failure-checks |
…efault function producer values.
c7fb1b5 to
5bce7c1
Compare
…nd got tests to pass in PulsarSinkTest
…s after fixing how YAML file is loaded
…vior is properly handled with defaults
…ome tests to pass in FunctionsImplTest
…ConfigUtils and got all tests to pass in FunctionConfigUtilsTest
…nApiV2ResourceTest tests to all pass
… source code to use FunctionDefaultsMediator as well. Got more tests to pass
… module to pass
New Feature of Pulsar
This feature introduces the ability to modify default producer behavior of Pulsar functions at two levels of granularity:
When a cluster-admin modifies function producer defaults in functions_worker.yml, they are able to change the behavior of ALL functions through a single config change. This enables widespread changes to be easily implemented in function producer behavior. This PR introduces the ability to modify these defaults:
If specific functions require default settings that deviate from the cluster-wide defaults, functions can override the cluster defaults via their configuration.
Motivation
Pulsar currently provides no way to allow users or operators to change the producing behavior of Pulsar functions. For organizations that are making heavy use of functions, the ability to tune behavior is greatly desired. Moreover, current defaults appear to be causing issues for certain workloads. Enabling operators to modify these defaults to workaround issues will enable those operators to upgrade legacy versions of Pulsar to more recent versions by using changes to function defaults to temporarily workaround bugs (such as with batching, as mentioned in #6054.)
Modifications
WorkerConfig was modified to support an additional set of parameters (for cluster-wide defaults.)
I introduced a mechanism to validate the configurations when they are set, and any problems with the configurations will throw a new exception type to ensure the cluster-admin notices the exact problem on broker startup. I also added some basic string processing when loading the configurations to ensure that differences in casing or use of hyphens/underscores won't break configurations (since that's a common source of very annoying configuration bugs.)
Adding function-specific defaults required modifying the protobuf function definition. I introduced several enums to allow "UNKNOWN" to be provided as an option (since protobuf doesn't support null primitives.)
I introduced a new class that handles the logic of determining whether to use cluster-wide defaults or function-specific defaults. In case the function-specific defaults are invalid, the error is logged to inform the user that there was a problem with their function configuration. In a separate PR, exceptions could be thrown during function deployment when invalid configurations are provided, but that seemed potentially out of scope for this PR. (I'm open to adding that if it seems very important though.)
Additional functionality could easily be added to make the cluster configuration startup validation even more robust, and a similar approach could be taken to validate other Pulsar configurations to simplify use for new cluster operators and for existing cluster operators who are experimenting with new cluster configurations. (Nobody likes to try starting Pulsar only to discover that it won't start due to a configuration error.)
Because FunctionDetails are available in different code paths than the WorkerConfig for many locations, I created a second class that behaves like a proxy to simplify implementation instead of requiring every code path to have both class objects available.
I also ensured that this change will apply to all runtimes (process mode, thread mode, kubernetes mode, localrun.)
I have not yet added the function-specific overrides to Go or Python functions, but those would be easy changes to make in separate PRs.
Fixes #9986
This PR will also help us determine if disabling function batching prevents the freezing topic issue on high-velocity production topics (#6054). If disabling function batching doesn't actually stop freezing topics, that information will help in root cause analysis of what's causing those freezing topics (or unresponsive subscriptions.)
Verifying this change
I created a new test class with selective mocking that verifies the behavior of the new functionality. It also verifies that the new configurations can be correctly loaded and that function configurations correctly override cluster-wide defaults when (and only when) they are provided. Unfortunately, I was unable to mock the protobuf classes because they are
final, so I had to work around that in my tests.This change is covered by existing tests:
This change added tests and can be verified as follows:
TestClusterFunctionProducerDefaultsDoes this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesbatchingMaxPublishDelay)Documentation