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

Chain elements should always pass Close down the chain #1468

Open
d-uzlov opened this issue Jun 16, 2023 · 1 comment
Open

Chain elements should always pass Close down the chain #1468

d-uzlov opened this issue Jun 16, 2023 · 1 comment

Comments

@d-uzlov
Copy link
Contributor

d-uzlov commented Jun 16, 2023

Overview

Close calls must clear all resources in one go.

Unlike Request, Close can not rely on retries.
It is possible that Close will never succeed because some app has died or restarter.
If Close reaches begin, if removes the connection event factory object, and all consequent Close calls will do nothing.

If some element mid-chain returned an error, then all elements down the chain will never get a Close call, and resources will leak.

Example

Imagine we have a chain like following: discover -> setupDataPlane
discover returns an error if there is something wrong with next app in path.
If the endpoint died and healClient issued reselect-close, then discover can't find the endpoint in registry and returns an error, and the data plane is never disposed of.

I found and fixed this example when working on the reselect state implementation:

Additional considerations

  • retry.Close method is pointless.
  • We must be extremely cautious with the following pattern:
    • err = next.Close()
      if err != nil {
        return
      }
      additionalClenup()
    • additionalClenup() here may never be called
  • We may want to also check registry.Unregister method. It seems like it also will never be repeated for a selected entry.
@d-uzlov
Copy link
Contributor Author

d-uzlov commented Jun 16, 2023

List of elements that could cancel Close

This is the list of elements in sdk repo.
I haven't checked other repos.

Open me

Some of these elements are fine.
For example, it is reasonable to expect begin to drop closes for unknown connections.
I'm not sure about authorize, updatepath, updatetoken elements, maybe they are also fine.

discover and discoverForwarder will be fixed in #1454.

mechanisms/client and mechanisms/server look semi-fine, because they will only fail if we try to Close with connection with invalid Connection.Mechanism.

recvfd/server and sendfd/client look concerning to me.

@d-uzlov d-uzlov changed the title Chain elements should never return an error in Close call Chain elements should always pass Close down the chain Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant