-
Notifications
You must be signed in to change notification settings - Fork 829
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
Split history tree insert from history node append #4147
Conversation
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.
To confirm, this is just for refactoring to make things cleaner, and there are no intended behavioral changes?
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.
Correct, the logical behavior should be identical. Also, I took your suggestion to break the serializeXXX helpers up and therefore the comment about moving the if-statement is moot.
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = m.persistence.AppendHistoryNodes(ctx, req) | ||
err = m.persistence.AppendHistoryNodes(ctx, nodeReq) |
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.
Append and Insert used to be in the same batch. Are you sure this won't cause any problems with them being in separate batches? For example, what happens if we crash after 536 and before 542?
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.
This failure condition (with nodes being written first with tree possibly not) is well known. The periodic scavenger task cleans these up.
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = m.persistence.AppendHistoryNodes(ctx, req) | ||
err = m.persistence.AppendHistoryNodes(ctx, nodeReq) | ||
if err == nil && request.IsNewBranch { |
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.
Why aren't we using the if err != nil { return err }
pattern 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.
And below
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.
It did strike me as a bit odd why the size
is returned regardless of error or not. But I believe that's why the original code also had this slight anti-pattern for error handling. I tracked this entire callstack chain and as far as I can tell, the size is expected. Hence, I'm following suit.
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 don't think we should repeat this pattern here because it sticks out like a sore thumb.
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 a nit. LGTM otherwise
What changed?
Why?
How did you test it?
Potential risks
Is hotfix candidate?