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

Send raw history events from history to frontend service #7342

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

prathyushpv
Copy link
Contributor

What changed?

Change to send raw history blobs from history service to frontend service. History service returns a new proto message that has a repeated bytes history field.
This response is wire compatible with the original response which has temporal.api.history.v1.History type for this field. This allows history service to not deserialize events from this data blob. This considerably reduces CPU usage.

History service still needs event_id and version decoded from history events. For this we use a new proto message StrippedHistoryEvent which has these two fields only. It takes considerably less CPU to decode events to this struct.

Why?

We have seen incidents of high history CPU usage when large number of GetWorkflowExecutionHistory calls are made to workflows which has large history. With this change we can reduce the CPU burden on history service during this API call.

How did you test it?

Existing unit and functional tests.

Potential risks

Documentation

Is hotfix candidate?

// This message must be wire compatible with GetWorkflowExecutionHistoryResponse.
message GetWorkflowExecutionHistoryResponseWithRaw {
temporal.api.workflowservice.v1.GetWorkflowExecutionHistoryResponse response = 1;
repeated bytes history = 2;
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 the change from the previous PR. History service will send raw history bytes to this field if config history.sendRawHistoryBetweenInternalService is set to true. Frontend service can check this field and do the modifications like process search attributes, fix the last failed events, filter close events etc and move this history to the correct temporal.api.workflowservice.v1.GetWorkflowExecutionHistoryResponse.History field.

This way it is safe during upgrades and downgrades. We can enable temporal.api.workflowservice.v1.GetWorkflowExecutionHistoryResponse after upgrade has finished. And disable it before downgrading.

@@ -2376,6 +2376,11 @@ that task will be sent to DLQ.`,
0.90,
"History service health check on persistence error ratio",
)
SendRawHistoryBetweenInternalServices = NewGlobalBoolSetting(
"history.sendRawHistoryBetweenInternalServices",
true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting this to true to verify all functional tests and integration tests passes for this PR. I will set it back to false before merging.

@prathyushpv prathyushpv marked this pull request as ready for review February 14, 2025 19:47
@prathyushpv prathyushpv requested a review from a team as a code owner February 14, 2025 19:47
@prathyushpv prathyushpv requested review from dnr and yycptt February 14, 2025 19:47
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.

1 participant