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

IWF-364: Fix conditional complete on messages of internalChannels from state APIs #490

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

longquanzheng
Copy link
Contributor

@longquanzheng longquanzheng commented Nov 22, 2024

Description

Checklist

  • Code compiles correctly
  • Tests for the changes have been added
  • All tests passing
  • This PR change is backwards-compatible
  • This PR CONTAINS a (planned) breaking change (it is not backwards compatible)

Related Issue

Closes #issue_number

Comment on lines +79 to +80
if p.IsUsingGlobalVersionSearchAttribute() &&
p.workflowProvider.GetBackendType() != service.BackendTypeCadence {
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 just some minor cleanup that is not related to this ticket

// There are two cases this is needed:
// 1. ContinueAsNew:
// retrieve signals that after signal handler threads are stopped,
// so that the signals can be carried over to next run by continueAsNew.
// This includes both regular user signals and system signals
// 2. Conditional close/complete workflow on signal/internal channel:
// retrieve all signal/internal channel messages before checking the signal/internal channels
func (sr *SignalReceiver) DrainAllUnreceivedSignals(ctx UnifiedContext) {
func (sr *SignalReceiver) DrainAllReceivedButUnprocessedSignals(ctx UnifiedContext) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rename the method to make it more clear(hopefully)

@longquanzheng longquanzheng requested a review from ktrops November 22, 2024 21:35
@longquanzheng longquanzheng changed the title Fix conditional complete on messages of internalChannels from state APIs IWF-364: Fix conditional complete on messages of internalChannels from state APIs Nov 22, 2024
Comment on lines +492 to +502
if versioner.IsAfterVersionOfYieldOnConditionalComplete() {
// Just yield, by waiting on an empty lambda, nothing else.
// It will let other workflow threads/coroutines to run.
// This will drain the messages published from state APIs.
// NOTE that this is extremely tricky in Cadence/Temporal programming model.
// Read more: https://stackoverflow.com/questions/71356668/how-does-multi-threading-works-in-cadence-temporal-workflow
//https://docs.temporal.io/encyclopedia/go-sdk-multithreading
return provider.Await(ctx, func() bool {
return true
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm gonna trust this works as expected. Having tests would be beneficial and make it easier to understand and verify. Hope we can cover multi-threading soon so I can get a better grasp on it.

@lwolczynski
Copy link
Contributor

Closes #289

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