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

Split history tree insert from history node append #4147

Merged
merged 8 commits into from
Apr 13, 2023

Conversation

norberthu
Copy link
Contributor

What changed?

Why?

How did you test it?

Potential risks

Is hotfix candidate?

@norberthu norberthu requested a review from a team as a code owner April 6, 2023 13:09
Copy link
Contributor

@MichaelSnowden MichaelSnowden left a 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?

Copy link
Contributor Author

@norberthu norberthu left a 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.

common/persistence/history_manager.go Show resolved Hide resolved
if err != nil {
return nil, err
}

err = m.persistence.AppendHistoryNodes(ctx, req)
err = m.persistence.AppendHistoryNodes(ctx, nodeReq)
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

And below

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@MichaelSnowden MichaelSnowden left a 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

@norberthu norberthu merged commit cdd1a21 into master Apr 13, 2023
@norberthu norberthu deleted the norbert/chop-tree-node branch April 13, 2023 18:46
samanbarghi pushed a commit to samanbarghi/temporal that referenced this pull request Apr 15, 2023
samanbarghi pushed a commit to samanbarghi/temporal that referenced this pull request Apr 17, 2023
samanbarghi pushed a commit to samanbarghi/temporal that referenced this pull request May 2, 2023
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.

2 participants