Skip to content

Commit 5f6022a

Browse files
authored
M1 mac fix, document doNotCompleteOnReturn's behavioral gap explicitly (#776)
* Fix gradle for M1 OSX machines * Document doNotCompleteOnReturn's behavioral gap explicitly Java counterpart to cadence-workflow/cadence-go-client#1229 Resolving this "two kinds of finished-timeouts / heartbeat-timeouts, but only one config" issue with Activity.doNotCompleteOnReturn will need some new semantics on the server side... but at least there's a workaround until then. The general concept of a "pending activity" does seem worth supporting, particularly because it can respond with an "already completed" error when a second "complete" request is received. It just has unfortunate quirks at the moment. * sometimes
1 parent 8fddf99 commit 5f6022a

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

build.gradle

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,19 @@ sourceSets {
119119

120120
protobuf {
121121
protoc {
122-
artifact = 'com.google.protobuf:protoc:3.11.0'
122+
if (osdetector.os == "osx") {
123+
artifact = 'com.google.protobuf:protoc:3.11.0:osx-x86_64' // no arm version available
124+
} else {
125+
artifact = 'com.google.protobuf:protoc:3.11.0'
126+
}
123127
}
124128
plugins {
125129
grpc {
126-
artifact = 'io.grpc:protoc-gen-grpc-java:1.28.0'
130+
if (osdetector.os == "osx") {
131+
artifact = 'io.grpc:protoc-gen-grpc-java:1.28.0:osx-x86_64' // no arm version available
132+
} else {
133+
artifact = 'io.grpc:protoc-gen-grpc-java:1.28.0'
134+
}
127135
}
128136
}
129137
generateProtoTasks {

src/main/java/com/uber/cadence/activity/Activity.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@
163163
* }
164164
* </code></pre>
165165
*
166+
* <p>Caution: since using this sometimes implies "long" timeouts, activity-worker losses prior to recording the
167+
* {@link Activity#getTaskToken()} in an external system (or prior to another thread calling it) may not be noticed
168+
* until the "long" timeout occurs. This can be resolved by having another system call
169+
* {@link com.uber.cadence.client.ActivityCompletionClient#heartbeat(byte[], Object)} while that external action is
170+
* running, but there is currently no way to mitigate this issue without these heartbeats. For in-process-only async
171+
* completion, relying on heartbeating is safe and reliable because these heartbeats should occur as long as the
172+
* process / background thread is still running.
173+
*
174+
* <p>If you cannot heartbeat and cannot tolerate this kind of delayed-activity-loss detection, consider emulating a
175+
* long activity via a signal channel instead: you can start a short-lived activity and wait for a "saved to external
176+
* system" signal, retrying as necessary, and then wait for an "external system finished" signal containing the final
177+
* result.
178+
*
166179
* <h3>Activity Heartbeating</h3>
167180
*
168181
* <p>Some activities are long running. To react to their crashes quickly, use a heartbeat
@@ -201,9 +214,23 @@
201214
public final class Activity {
202215

203216
/**
204-
* If this method is called during an activity execution then activity is not going to complete
217+
* If this method is called during an activity execution then activity will not complete
205218
* when its method returns. It is expected to be completed asynchronously using {@link
206219
* com.uber.cadence.client.ActivityCompletionClient}.
220+
*
221+
* <p>Caution: since using this sometimes implies "long" timeouts, activity-worker losses prior to recording the
222+
* {@link Activity#getTaskToken()} in an external system (or prior to another thread calling it) may not be noticed
223+
* until the "long" timeout occurs.
224+
* This can be resolved by having another system call
225+
* {@link com.uber.cadence.client.ActivityCompletionClient#heartbeat(byte[], Object)} while that external action is
226+
* running, but there is currently no way to mitigate this issue without these heartbeats. For in-process-only async
227+
* completion, relying on heartbeating is safe and reliable because these heartbeats should occur as long as the
228+
* process / background thread is still running.
229+
*
230+
* <p>If you cannot heartbeat and cannot tolerate this kind of delayed-activity-loss detection, consider emulating a
231+
* long activity via a signal channel instead: you can start a short-lived activity and wait for a "saved to external
232+
* system" signal, retrying as necessary, and then wait for an "external system finished" signal containing the final
233+
* result.
207234
*/
208235
public static void doNotCompleteOnReturn() {
209236
ActivityInternal.doNotCompleteOnReturn();

0 commit comments

Comments
 (0)