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

namespace didn't remove experiments from segmentAllocations after invoking RemoveExperiment() #4

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

panjf2000
Copy link

namespace didn't remove experiments from segmentAllocations after invoking RemoveExperiment() and it caused "panic: runtime error: invalid memory address or nil pointer dereference" in
image
image

timwu and others added 4 commits October 12, 2015 11:34
Hitting a nil value previously would cause a crash in the experiment run. This happens in both the
case of the value being in a map, and in the case where the value is part of a struct. This fix causes
the code to instead return a nil.
Unfortunately this is not quite ideal in the case of maps to numerical values.  In a normal go map,
maps with numerical values apparently return a 0 when the requested key is not present. There
doesn't seem to be any simple way to maintain parity with that behavior (though it does seem kind
of odd, looking at it from Java colored glasses), so a concession is made to just return a nil in that
case.
namespace.go Outdated
@@ -94,6 +94,10 @@ func (n *SimpleNamespace) RemoveExperiment(name string) error {
}
}

for _, val := range segmentsToFree {
delete(n.segmentAllocations, uint64(val))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could delete be done inside the loop where values are added tosegmentsToFree? (instead of iterating segmentsToFree outside separately)
https://github.com/biased-unit/planout-golang/blob/master/namespace.go#L98

@tsujeeth
Copy link
Collaborator

Thanks @panjf2000 for this change. Could you please add unit tests?

@panjf2000
Copy link
Author

@tsujeeth sure, i will add unit tests later.

@panjf2000
Copy link
Author

@tsujeeth already added unit tests, please review that.

@tsujeeth
Copy link
Collaborator

tsujeeth commented Aug 4, 2018

@panjf2000 sorry it has taken me a while to get back.

Some comments:

  • It would be helpful if the scope of your change is focused only on the issue: namespace didn't remove experiments from segmentAllocations. Could you please remove the other commits? Perhaps file a separate PR for them?

  • Please resolve merge conflicts. Note that biased-unit/planout-golang was recently updated

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

Successfully merging this pull request may close these issues.

3 participants