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
Bug 1533425 - protect against simultaneous updates #898
Conversation
Simultaneous calls to SetState or SetBindingInstance would fail with an already exists error instead of graciously updating the existing instances. Also, the broker.Bind was incorrectly trying to set the state of a binding job using the instance id as the key, vs use bindingid for state in bindings
1382691
to
8f2840b
Compare
pkg/dao/crd/dao.go
Outdated
| // looks like we already have this state, probably created by | ||
| // another goroutine. Let's try to update the existing one instead. | ||
| if js, err := d.client.JobStates(d.namespace).Get(state.Token, metav1.GetOptions{}); err == nil { | ||
| js.Spec = j |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in a helper function?
pkg/broker/broker.go
Outdated
| }); err != nil { | ||
| log.Errorf("failed to set initial jobstate for %v, %v", token, err.Error()) | ||
| } | ||
| // if _, err := a.dao.SetState(bindInstance.ID.String(), apb.JobState{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just my opinion but if the code is not running can we delete it?
We can also go back in history with git and re-add it back?
|
@shawn-hurley refactored update code into a method. Let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
protect against simultaneous updates
Simultaneous calls to SetState or SetBindingInstance would fail with an already exists error instead of graciously updating the existing instances.
Also, the broker.Bind was incorrectly trying to set the state of a binding job using the instance id as the key, vs use bindingid for state in bindings