-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Check current instance status before update. #1569
base: 2.x
Are you sure you want to change the base?
Check current instance status before update. #1569
Conversation
@howardyuan could you please take a look? |
Hi @howardyuan, regarding your comments before, I still use the pre-existing method under the hood from here, so |
public synchronized InstanceStatus setStatus(InstanceStatus expected, InstanceStatus status) { | ||
InstanceStatus prev = this.status; | ||
if (expected == null || !expected.equals(prev)) { | ||
throw new IllegalArgumentException("Instance status mismatch"); |
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.
I'm a bit concerned that we throw an exception here instead of like before which is simply returning null like before? Also, we don't setIsDirty() here anymore? not sure why we introduce some discrepancy here?
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.
Hi @OlgaMaciaszek My concern was that even if we have a race condition, should we throw exceptions or we just skip this update and let eventual consistency catches up? I'm not sure if we will catch those exception at the top, but I think it's too much a disruption if we crash the app whenever we detect a race condition updating the instance status? lmk what you think? I'll take a further look at the whole thing but this is my quick thinking.
This is related to spring-cloud/spring-cloud-netflix#4094 as an attempted fix.