Skip to content

Commit

Permalink
Switch from opaque branch token to branch info (temporalio#4168)
Browse files Browse the repository at this point in the history
  • Loading branch information
norberthu authored and samanbarghi committed Apr 17, 2023
1 parent c064bf6 commit b76d5c7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
10 changes: 3 additions & 7 deletions common/persistence/cassandra/history_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,16 @@ func (h *HistoryStore) DeleteHistoryBranch(
ctx context.Context,
request *p.InternalDeleteHistoryBranchRequest,
) error {
branch, err := h.GetHistoryBranchUtil().ParseHistoryBranchInfo(request.BranchToken)
if err != nil {
return err
}

batch := h.Session.NewBatch(gocql.LoggedBatch).WithContext(ctx)
batch.Query(v2templateDeleteBranch, branch.TreeId, branch.BranchId)
batch.Query(v2templateDeleteBranch, request.BranchInfo.TreeId, request.BranchInfo.BranchId)

// delete each branch range
for _, br := range request.BranchRanges {
h.deleteBranchRangeNodes(batch, branch.TreeId, br.BranchId, br.BeginNodeId)
h.deleteBranchRangeNodes(batch, request.BranchInfo.TreeId, br.BranchId, br.BeginNodeId)
}

err = h.Session.ExecuteBatch(batch)
err := h.Session.ExecuteBatch(batch)
if err != nil {
return gocql.ConvertError("DeleteHistoryBranch", err)
}
Expand Down
3 changes: 1 addition & 2 deletions common/persistence/history_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func (m *executionManagerImpl) ForkHistoryBranch(
}

req := &InternalForkHistoryBranchRequest{
BranchToken: request.ForkBranchToken,
ForkBranchInfo: forkBranch,
TreeInfo: treeInfoBlob,
ForkNodeID: request.ForkNodeID,
Expand Down Expand Up @@ -214,7 +213,7 @@ findDeleteRanges:
}

req := &InternalDeleteHistoryBranchRequest{
BranchToken: request.BranchToken,
BranchInfo: branch,
ShardID: request.ShardID,
BranchRanges: deleteRanges,
}
Expand Down
6 changes: 2 additions & 4 deletions common/persistence/persistenceInterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,6 @@ type (

// InternalForkHistoryBranchRequest is used to fork a history branch
InternalForkHistoryBranchRequest struct {
// The raw branch token
BranchToken []byte
// The base branch to fork from
ForkBranchInfo *persistencespb.HistoryBranch
// Serialized TreeInfo
Expand Down Expand Up @@ -539,8 +537,8 @@ type (

// InternalDeleteHistoryBranchRequest is used to remove a history branch
InternalDeleteHistoryBranchRequest struct {
// The raw branch token
BranchToken []byte
// The branch
BranchInfo *persistencespb.HistoryBranch
// Used in sharded data stores to identify which shard to use
ShardID int32
// branch ranges is used to delete range of history nodes from target branch and it ancestors.
Expand Down
9 changes: 2 additions & 7 deletions common/persistence/sql/history_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,11 @@ func (m *sqlExecutionStore) DeleteHistoryBranch(
ctx context.Context,
request *p.InternalDeleteHistoryBranchRequest,
) error {
branch, err := m.GetHistoryBranchUtil().ParseHistoryBranchInfo(request.BranchToken)
if err != nil {
return err
}

branchIDBytes, err := primitives.ParseUUID(branch.BranchId)
branchIDBytes, err := primitives.ParseUUID(request.BranchInfo.BranchId)
if err != nil {
return err
}
treeIDBytes, err := primitives.ParseUUID(branch.TreeId)
treeIDBytes, err := primitives.ParseUUID(request.BranchInfo.TreeId)
if err != nil {
return err
}
Expand Down

0 comments on commit b76d5c7

Please sign in to comment.