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

Assign LastFirstTransactionID correctly #2438

Merged
merged 2 commits into from
Feb 3, 2022

Conversation

Ardagan
Copy link
Contributor

@Ardagan Ardagan commented Jan 31, 2022

What changed?
Assign LastFirstTxnID correctly for multiple branch case (reset workflow operation).

Why?
Establish expected behavior.

How did you test it?
unit tests

Potential risks
Reset workflow doesn't perform correctly

Is hotfix candidate?
No

@Ardagan Ardagan requested a review from yiminc January 31, 2022 18:15
@Ardagan Ardagan force-pushed the LastFirstTransactionId branch from 4fb9373 to 9dd2ff6 Compare January 31, 2022 18:53
@Ardagan Ardagan marked this pull request as ready for review January 31, 2022 20:18
@Ardagan Ardagan requested a review from a team January 31, 2022 20:18
@Ardagan Ardagan requested a review from wxing1292 February 1, 2022 17:42
@@ -446,7 +446,7 @@ func (m *executionManagerImpl) ReadHistoryBranchByBatch(

resp := &ReadHistoryBranchByBatchResponse{}
var err error
_, resp.History, resp.NextPageToken, resp.Size, err = m.readHistoryBranch(true, request)
_, resp.History, resp.TransactionIDs, resp.NextPageToken, resp.Size, err = m.readHistoryBranch(true, request)
Copy link
Member

Choose a reason for hiding this comment

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

This is getting out of hand. I think we need a struct for the results

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 is internal method used in two places only. I think looking at signature is faster for reading atm. My another concern would be that we create another "ReadHistoryBranch..." structure in code that will add even more ambiguity in naming than we have now.

@@ -180,6 +187,8 @@ func (r *nDCStateRebuilderImpl) rebuild(
return nil, 0, err
}

rebuiltMutableState.GetExecutionInfo().LastFirstEventTxnId = lastTxnId
Copy link
Member

Choose a reason for hiding this comment

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

we need a setter method on mutable state to set this

Copy link
Contributor

Choose a reason for hiding this comment

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

the last txn ID should be managed by history builder, not here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Synced with Wenquan:

  • use current approach overall for this PR for quick fix and unblocking of GetWorkflowExecutionHistoryReverse feature
  • followup with change to move managing of transaction ids to history_builder. Which would effectively include:
    • Pass in event batch metadata to history_builder/rebuilder/etc when we apply/replay events
    • Move transaction id generation out of mutable stage
    • Make history_builder responsible for managing transaction ids

service/history/nDCStateRebuilder.go Outdated Show resolved Hide resolved
@Ardagan Ardagan requested a review from yycptt February 1, 2022 18:52
@Ardagan Ardagan requested a review from a team as a code owner February 2, 2022 19:00
Comment on lines 892 to +895
// History events by batch
History []*historypb.History
// TransactionID for relevant History batch
TransactionIDs []int64
Copy link
Contributor

Choose a reason for hiding this comment

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

how about changing

History []*historypb.History
TransactionIDs []int64

to something like

History []History

where

History struct {
  TransactionID int64
  PrevTransactionID int64
  Events *historypb.History
}

Copy link
Contributor

Choose a reason for hiding this comment

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

basically do not use 2 slices with equal length, but one slice of structs containing all data to be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would suggest to make it a separate PR. It blows up into too big of a change.

@Ardagan Ardagan merged commit 0447a17 into temporalio:master Feb 3, 2022
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