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

Don't remove subscriptions while iterating them #2157

Merged
merged 4 commits into from
Apr 4, 2022

Conversation

niloc132
Copy link
Member

Fixes #2070

@niloc132 niloc132 added bug Something isn't working grpc application mode labels Mar 30, 2022
@niloc132 niloc132 added this to the Mar 2022 milestone Mar 30, 2022
@niloc132 niloc132 self-assigned this Mar 30, 2022
nbauernfeind
nbauernfeind previously approved these changes Mar 30, 2022
@@ -209,7 +210,7 @@ private synchronized void propagateUpdates() {
updatedFields.clear();
final FieldsChangeUpdate update = builder.build();

subscriptions.forEach(sub -> sub.send(update));
subscriptions.removeIf(subscription -> !subscription.send(update));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need any of the side-effects that onClose previously provided? (We aren't calling onClose now.)

  • session.removeOnCloseCallback(subscription)
  • subscription.notifyObserverAborted()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you're right, though the broken behavior won't be visible externally

  • the leaked callback will just leak until the session cleans it up, which isnt ideal
  • the observer notification doesnt matter, since the observer is already by definition failed

I really dont care for this close-is-remove-but-not-cancel pattern we have used here and elsewhere. I am also not sure that what we seem to have here makes sense at all (why does a close() call necessarily mean sending the aborted message, but doesnt do the cleanup from the session?), but I think that cleanup is outside the scope for this set of changes.

// must be sync wrt parent
/**
* Sends an update to the subscribed client. Returns true if successful - if false, the client is no longer
* listening and this subscription should be canceled after iteration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at callers of send - do we also need to do an onCancel call in listFields?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, though a) it is a weak ref anyway, and b) the subscription won't be in the list so doesnt need to be removed. I'll make the change in this patch, though it probably should be incorporated into a bigger change that generally cleans up these patterns, rather than fixing each piecemeal as we've been doing.

@niloc132 niloc132 merged commit c7f79cc into deephaven:main Apr 4, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

propagateUpdates CME
3 participants