Re-order listener creation logic to do concurrency protection in core - #1776
Merged
Conversation
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
EnriqueL8
approved these changes
Sep 1, 2026
EnriqueL8
left a comment
Contributor
There was a problem hiding this comment.
Thanks @peterbroadhurst - looks good and clear explanation 👍🏼
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Problem
During creation of a listener, the order in FireFly core is currently:
ff-sub-<namespace>-<listener_id>for examplebackendIdalready knownThe problem with this, is that if two API calls are racing performing (1) & (2), only one can win in (3) and the other will fail with:
This leaks a listener/subscription in the backend connection, because we generated a unique ID in (1).
Note the listener is inert, as it doesn't match a backendID of any listener in FireFly core, so the events are discarded with a line like:
Fix
Proposal is to just change the order:
If (2) fails we haven't started creating the backend connector listener/subscription - so no leak.
If in the tiny edge case of a termination of the runtime between (3) and (4), it's not a leak - because the creation logic runs on startup to reconcile the two. We do a query-by-ID, then a create. We find the listener exists in the backend, and store the ID.
The only behavior change, is that the default name of a listener if one is created without a name becomes the FireFly ID, not the initial backend ID. Either is confusing... I assert that the backend ID which can actually change over time, is the more confusing. So I propose this is inert to end users, and positive change.
Types of changes
Please make sure to follow these points