Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix tdbg unable to dump all workflow raw history issue #4681

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions tools/tdbg/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func AdminShowWorkflow(c *cli.Context) error {
client := cFactory.AdminClient(c)

serializer := serialization.NewSerializer()
var history []*commonpb.DataBlob

ctx, cancel := newContext(c)
defer cancel()
Expand All @@ -78,26 +77,32 @@ func AdminShowWorkflow(c *cli.Context) error {
return err
}

resp, err := client.GetWorkflowExecutionRawHistoryV2(ctx, &adminservice.GetWorkflowExecutionRawHistoryV2Request{
NamespaceId: nsID.String(),
Execution: &commonpb.WorkflowExecution{
WorkflowId: wid,
RunId: rid,
},
StartEventId: startEventId,
EndEventId: endEventId,
StartEventVersion: startEventVerion,
EndEventVersion: endEventVersion,
MaximumPageSize: 100,
NextPageToken: nil,
})
if err != nil {
return fmt.Errorf("unable to read History Branch: %s", err)
var histories []*commonpb.DataBlob
var token []byte
for doContinue := true; doContinue; doContinue = len(token) != 0 {
resp, err := client.GetWorkflowExecutionRawHistoryV2(ctx, &adminservice.GetWorkflowExecutionRawHistoryV2Request{
NamespaceId: nsID.String(),
Execution: &commonpb.WorkflowExecution{
WorkflowId: wid,
RunId: rid,
},
StartEventId: startEventId,
EndEventId: endEventId,
StartEventVersion: startEventVerion,
EndEventVersion: endEventVersion,
MaximumPageSize: 10000,
Copy link
Member

Choose a reason for hiding this comment

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

😮
will this timeout?

NextPageToken: token,
})
if err != nil {
return fmt.Errorf("unable to read History Branch: %s", err)
}
histories = append(histories, resp.HistoryBatches...)
token = resp.NextPageToken
}

allEvents := &historypb.History{}
totalSize := 0
for idx, b := range resp.HistoryBatches {
for idx, b := range histories {
totalSize += len(b.Data)
fmt.Printf("======== batch %v, blob len: %v ======\n", idx+1, len(b.Data))
historyBatch, err := serializer.DeserializeEvents(b)
Expand All @@ -112,7 +117,7 @@ func AdminShowWorkflow(c *cli.Context) error {
}
fmt.Println(string(data))
}
fmt.Printf("======== total batches %v, total blob len: %v ======\n", len(history), totalSize)
fmt.Printf("======== total batches %v, total blob len: %v ======\n", len(histories), totalSize)

if outputFileName != "" {
encoder := codec.NewJSONPBEncoder()
Expand Down