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

[topo] Refactor ExpandCells to not error on valid aliases #8291

Merged
merged 2 commits into from
Jun 9, 2021

Conversation

ajm188
Copy link
Contributor

@ajm188 ajm188 commented Jun 9, 2021

Description

A couple other changes here, in addition to the title:

  • Store the output cells in a set to dedupe the final slice. This covers
    the case where a caller passes "alias,cell1" where cell1 is in the
    cell list for alias. Without a set, it would appear twice in the final
    result.
  • Add an inner function to correct defer semantics on the cancel
    funcs. Defering within the scope of a for loop is generally not what we
    want, since all of the deferred functions will pile up until the total
    function is done.

Related Issue(s)

Fixes #8290

Checklist

  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

ajm188 added 2 commits June 8, 2021 21:29
Signed-off-by: Andrew Mason <[email protected]>
A couple other changes here:
- Store the output cells in a set to dedupe the final slice. This covers
the case where a caller passes `"alias,cell1"` where `cell1` is in the
cell list for `alias`. Without a set, it would appear twice in the final
result.
- Add an inner function to correct `defer` semantics on the cancel
funcs. Defering within the scope of a for loop is generally not what we
want, since all of the deferred functions will pile up until the total
function is done.

Fixes vitessio#8290.

Signed-off-by: Andrew Mason <[email protected]>
Copy link
Member

@rafael rafael left a comment

Choose a reason for hiding this comment

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

LGTM

if err2 == nil {
outputCells = append(outputCells, alias.Cells...)
}
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

For my understanding, here is the bug in the current code. Per conversation with @ajm188

we don't nil out err if err2 is nil, so even if there's a valid alias, we still return the error from trying to look up the alias as pure cell

@ajm188 ajm188 merged commit d9fa9f2 into vitessio:main Jun 9, 2021
@ajm188 ajm188 deleted the am_expandcells_handle_aliases branch June 9, 2021 19:23
ajm188 added a commit to tinyspeck/vitess that referenced this pull request Jul 23, 2021
…_aliases

[topo] Refactor `ExpandCells` to not error on valid aliases

Signed-off-by: Andrew Mason <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[topo] ExpandCells does not correctly expand aliases
2 participants