Skip to content
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

Remove redundant delaySubscription from FunctionConfiguration #2978

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

artembilan
Copy link
Member

Related to: spring-projects/spring-integration#9362

After the fix in Spring Integration: spring-projects/spring-integration@bdcb856 we ended up in a deadlock situation with a beginPublishingTrigger in the FunctionConfiguration used for the delaySubscription() on an original Publisher. The FluxMessageChannel uses its own delaySubscription() until the channel has its subscribers. Apparently the logic before was with errors, so the FluxMessageChannel was marked as active even if its subscriber is not ready yet, leading to famous Dispatcher does not have subscribers error. So, looks like this beginPublishingTrigger was introduced back in days in Spring Cloud Stream to mitigate that situation until we really emit a BindingCreatedEvent.

The deadlock (and the flaw, respectively) is with the setupBindingTrigger() method implementation where FluxMessageChannel now "really" delays a subscription to the provided Publisher, therefore not triggering that Mono.create() fulfilment immediately. The BindingCreatedEvent arrives earlier, than we have a subscriber on the channel, but triggerRef.get() is null, so we don't success() it and in the end don't subscribe to an original Publisher since delaySubscription() on it is never completed.

Since FunctionConfiguration fully relies on IntegrationFlow.from(Publisher), which ends up with the mentioned FluxMessageChannel.subscribeTo() and its own delaySubscription() (which, in turn, apparently fixed now), we don't need our own delaySubscription() any more. Therefore the fix in this PR is to propose to remove beginPublishingTrigger logic altogether.

Related to: spring-projects/spring-integration#9362

After the fix in Spring Integration: spring-projects/spring-integration@bdcb856
we ended up in a deadlock situation with a `beginPublishingTrigger` in the `FunctionConfiguration`
used for the `delaySubscription()` on an original `Publisher`.
The `FluxMessageChannel` uses its own `delaySubscription()` until the channel has its subscribers.
Apparently the logic before was with errors, so the `FluxMessageChannel` was marked as active
even if its subscriber is not ready yet, leading to famous `Dispatcher does not have subscribers` error.
So, looks like this `beginPublishingTrigger` was introduced back in days in Spring Cloud Stream
to mitigate that situation until we really emit a `BindingCreatedEvent`.

The deadlock (and the flaw, respectively) is with the `setupBindingTrigger()` method implementation
where `FluxMessageChannel` now "really" delays a subscription to the provided `Publisher`,
therefore not triggering that `Mono.create()` fulfilment immediately.
The `BindingCreatedEvent` arrives earlier, than we have a subscriber on the channel,
but `triggerRef.get()` is `null`, so we don't `success()` it and in the end don't subscribe
to an original `Publisher` since `delaySubscription()` on it is never completed.

Since `FunctionConfiguration` fully relies on `IntegrationFlow.from(Publisher)`,
which ends up with the mentioned  `FluxMessageChannel.subscribeTo()` and its own `delaySubscription()`
(which, in turn, apparently fixed now), we don't need our own `delaySubscription()` any more.
Therefore the fix in this PR is to propose to remove `beginPublishingTrigger` logic altogether.
@sobychacko sobychacko merged commit 3b5bb2e into spring-cloud:main Aug 1, 2024
1 check passed
@sobychacko
Copy link
Contributor

Merged via 3b5bb2e.

@olegz We need to discuss this when you are back. I merged it to address some CI test failures.

@wrwksexahatvani
Copy link

@artembilan @sobychacko Any update on the release date?

@sobychacko
Copy link
Contributor

Hi, this will be part of the 2024.0.0-M2 release of spring-cloud scheduled for 10/03/24.

https://calendar.spring.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants