Skip to content

Commit c30e07d

Browse files
author
Matt McShane
authored
Do not add accepted/rejected request to messages (#1787)
Avoids including the full initial request in the Acceptance and Rejection messages from the update protocol. Server has been updated to not expect these fields.
1 parent c215a78 commit c30e07d

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

temporal-sdk/src/main/java/io/temporal/internal/statemachines/UpdateProtocolStateMachine.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.temporal.api.failure.v1.Failure;
3131
import io.temporal.api.protocol.v1.Message;
3232
import io.temporal.api.update.v1.Acceptance;
33+
import io.temporal.api.update.v1.Meta;
3334
import io.temporal.api.update.v1.Outcome;
3435
import io.temporal.api.update.v1.Rejection;
3536
import io.temporal.api.update.v1.Request;
@@ -77,7 +78,7 @@ enum State {
7778
private String protoInstanceID;
7879
private String requestMsgId;
7980
private long requestSeqID;
80-
private Request initialRequest;
81+
private Meta meta;
8182
private String messageId;
8283

8384
public static final StateMachineDefinition<State, ExplicitEvent, UpdateProtocolStateMachine>
@@ -174,7 +175,7 @@ void triggerUpdate() {
174175
requestMsgId = this.currentMessage.getId();
175176
requestSeqID = this.currentMessage.getEventId();
176177
try {
177-
initialRequest = this.currentMessage.getBody().unpack(Request.class);
178+
meta = this.currentMessage.getBody().unpack(Request.class).getMeta();
178179
} catch (InvalidProtocolBufferException e) {
179180
throw new IllegalArgumentException("Current message not an update:" + this.currentMessage);
180181
}
@@ -198,7 +199,6 @@ public void accept() {
198199
Acceptance.newBuilder()
199200
.setAcceptedRequestMessageId(requestMsgId)
200201
.setAcceptedRequestSequencingEventId(requestSeqID)
201-
.setAcceptedRequest(initialRequest)
202202
.build();
203203

204204
messageId = requestMsgId + "/accept";
@@ -216,7 +216,6 @@ public void reject(Failure failure) {
216216
Rejection.newBuilder()
217217
.setRejectedRequestMessageId(requestMsgId)
218218
.setRejectedRequestSequencingEventId(requestSeqID)
219-
.setRejectedRequest(initialRequest)
220219
.setFailure(failure)
221220
.build();
222221

@@ -238,8 +237,7 @@ public void complete(Optional<Payloads> payload, Failure failure) {
238237
outcome = outcome.setSuccess(payload.isPresent() ? payload.get() : null);
239238
}
240239

241-
Response outcomeResponse =
242-
Response.newBuilder().setOutcome(outcome).setMeta(initialRequest.getMeta()).build();
240+
Response outcomeResponse = Response.newBuilder().setOutcome(outcome).setMeta(meta).build();
243241

244242
messageId = requestMsgId + "/complete";
245243
sendHandle.apply(

temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachines.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,15 @@ static final class UpdateWorkflowExecutionData {
430430
final String id;
431431
final CompletableFuture<UpdateWorkflowExecutionResponse> acceptance;
432432
final CompletableFuture<UpdateWorkflowExecutionResponse> complete;
433+
final Request initialRequest;
433434

434435
public UpdateWorkflowExecutionData(
435436
String id,
437+
Request initialRequest,
436438
CompletableFuture<UpdateWorkflowExecutionResponse> acceptance,
437439
CompletableFuture<UpdateWorkflowExecutionResponse> complete) {
438440
this.id = id;
441+
this.initialRequest = initialRequest;
439442
this.acceptance = acceptance;
440443
this.complete = complete;
441444
}
@@ -561,9 +564,11 @@ public static StateMachine<ChildWorkflowData> newChildWorkflowStateMachine(
561564

562565
public static StateMachine<UpdateWorkflowExecutionData> newUpdateWorkflowExecution(
563566
String updateId,
567+
Request initialRequest,
564568
CompletableFuture<UpdateWorkflowExecutionResponse> acceptance,
565569
CompletableFuture<UpdateWorkflowExecutionResponse> complete) {
566-
return new StateMachine<>(new UpdateWorkflowExecutionData(updateId, acceptance, complete))
570+
return new StateMachine<>(
571+
new UpdateWorkflowExecutionData(updateId, initialRequest, acceptance, complete))
567572
.add(NONE, START, STARTED, StateMachines::acceptUpdate)
568573
.add(STARTED, COMPLETE, COMPLETED, StateMachines::completeUpdate);
569574
}
@@ -1771,7 +1776,7 @@ private static void acceptUpdate(
17711776
.setAcceptedRequestSequencingEventId(workflowTaskCompletedEventId - 1)
17721777
.setProtocolInstanceId(msg.getProtocolInstanceId())
17731778
.setAcceptedRequestMessageId(acceptance.getAcceptedRequestMessageId())
1774-
.setAcceptedRequest(acceptance.getAcceptedRequest())
1779+
.setAcceptedRequest(data.initialRequest)
17751780
.build();
17761781

17771782
HistoryEvent event =

temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ private void processAcceptanceMessage(
15951595

15961596
update =
15971597
StateMachines.newUpdateWorkflowExecution(
1598-
protocolInstanceId, u.getAcceptance(), u.getCompletion());
1598+
protocolInstanceId, u.getRequest().getRequest(), u.getAcceptance(), u.getCompletion());
15991599
updates.put(protocolInstanceId, update);
16001600
update.action(StateMachines.Action.START, ctx, msg, workflowTaskCompletedId);
16011601
}

0 commit comments

Comments
 (0)