-
Notifications
You must be signed in to change notification settings - Fork 212
Wait for MARKER_RECORDED to fire version callback on replay #2821
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
Open
eamsden
wants to merge
16
commits into
master
Choose a base branch
from
eamsden/interleaved-UpdateCompleted-getversion
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6d47983
Add interleaved update replay reproducer
eamsden 56ebbbf
Add replay ordering reproducer for interleaved updates
eamsden b924732
Delay flagged version replay callback to marker match
eamsden a9d773f
Delay version replay callback until marker match
eamsden 9b1f93c
Doc comments for new regression tests.
eamsden d6750ea
Gate VersionStateMachine behavior correction behind new sdk flag
eamsden 3f9b1a7
Disable recorded-history replay test for interleaved histories, since we
eamsden 11f817b
Add flag introduction history on `VERSION_WAIT_FOR_MARKER` SDK flag
eamsden 9152350
Make reproducer for original issue check that it still throws the same
eamsden 745adbf
Add test replaying history with `VERSION_WAIT_FOR_MARKER` set in
eamsden bfcad3b
[visibility] attempt to produce interleaved replay behavior with
eamsden 648d583
Revert change to SKIP_YIELD_ON_VERSION that was in place for testing.
eamsden ccf3d82
Fix stale test
eamsden 89c6e05
Make Docker build more reliable against transient network failures in CI
eamsden 55f38ac
Fix zlib download URL
eamsden ff8f61a
Fix flake caused by tests assuming immediate v2 routing after setting
eamsden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| name: Continuous Integration | ||
| permissions: | ||
| checks: write | ||
| contents: read | ||
| on: | ||
| pull_request: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,35 @@ | ||
| # Specify an installation directory for musl: | ||
| export MUSL_HOME=$PWD/musl-toolchain | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Download musl and zlib sources: | ||
| curl -O https://musl.libc.org/releases/musl-1.2.5.tar.gz | ||
| curl -O https://zlib.net/fossils/zlib-1.2.13.tar.gz | ||
| readonly MUSL_VERSION=1.2.5 | ||
| readonly ZLIB_VERSION=1.2.13 | ||
|
|
||
| # Build musl from source | ||
| tar -xzvf musl-1.2.5.tar.gz | ||
| cd musl-1.2.5 || exit | ||
| export MUSL_HOME="$PWD/musl-toolchain" | ||
|
|
||
| curl --fail --location --retry 5 --retry-all-errors --output "musl-${MUSL_VERSION}.tar.gz" \ | ||
| "https://musl.libc.org/releases/musl-${MUSL_VERSION}.tar.gz" | ||
| curl --fail --location --retry 5 --retry-all-errors --output "zlib-${ZLIB_VERSION}.tar.gz" \ | ||
| "https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz" | ||
|
|
||
| # Build musl from source. | ||
| tar -xzf "musl-${MUSL_VERSION}.tar.gz" | ||
| cd "musl-${MUSL_VERSION}" | ||
| ./configure --prefix=$MUSL_HOME --static | ||
| # The next operation may require privileged access to system resources, so use sudo | ||
| make && make install | ||
| make -j"$(nproc)" | ||
| make install | ||
| cd .. | ||
|
|
||
| # Install a symlink for use by native-image | ||
| ln -s $MUSL_HOME/bin/musl-gcc $MUSL_HOME/bin/x86_64-linux-musl-gcc | ||
| # Install a symlink for use by native-image. | ||
| ln -sf "$MUSL_HOME/bin/musl-gcc" "$MUSL_HOME/bin/x86_64-linux-musl-gcc" | ||
|
|
||
| # Extend the system path and confirm that musl is available by printing its version | ||
| # Extend the system path and confirm that musl is available by printing its version. | ||
| export PATH="$MUSL_HOME/bin:$PATH" | ||
| x86_64-linux-musl-gcc --version | ||
|
|
||
| # Build zlib with musl from source and install into the MUSL_HOME directory | ||
| tar -xzvf zlib-1.2.13.tar.gz | ||
| cd zlib-1.2.13 || exit | ||
| # Build zlib with musl from source and install into the MUSL_HOME directory. | ||
| tar -xzf "zlib-${ZLIB_VERSION}.tar.gz" | ||
| cd "zlib-${ZLIB_VERSION}" | ||
| CC=musl-gcc ./configure --prefix=$MUSL_HOME --static | ||
| make && make install | ||
| make -j"$(nproc)" | ||
| make install | ||
| cd .. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...st/java/io/temporal/internal/replay/GetVersionInterleavedUpdateReplayTaskHandlerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| package io.temporal.internal.replay; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertNotNull; | ||
|
|
||
| import com.uber.m3.tally.NoopScope; | ||
| import io.temporal.api.query.v1.WorkflowQuery; | ||
| import io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse; | ||
| import io.temporal.client.WorkflowClient; | ||
| import io.temporal.common.WorkflowExecutionHistory; | ||
| import io.temporal.internal.worker.QueryReplayHelper; | ||
| import io.temporal.serviceclient.WorkflowServiceStubs; | ||
| import io.temporal.testing.TestWorkflowEnvironment; | ||
| import io.temporal.worker.Worker; | ||
| import io.temporal.workflow.versionTests.GetVersionInterleavedUpdateReplayTest; | ||
| import io.temporal.workflow.versionTests.GetVersionInterleavedUpdateReplayTest.GreetingWorkflowImpl; | ||
| import java.lang.reflect.Field; | ||
| import java.lang.reflect.Method; | ||
| import java.util.Arrays; | ||
| import org.junit.Test; | ||
|
|
||
| public class GetVersionInterleavedUpdateReplayTaskHandlerTest { | ||
| private static final String EXPECTED_FIRST_CHANGE_ID = "ChangeId1"; | ||
| private static final String EXPECTED_SECOND_CHANGE_ID = "ChangeId2"; | ||
|
|
||
| /** Regression test for the lower-level replay path behind the public replayer API. */ | ||
| @Test | ||
| public void testReplayDirectQueryWorkflowTaskSucceeds() throws Throwable { | ||
| WorkflowExecutionHistory history = | ||
| GetVersionInterleavedUpdateReplayTest.captureReplayableHistory(); | ||
| assertEquals( | ||
| Arrays.asList(EXPECTED_FIRST_CHANGE_ID, EXPECTED_SECOND_CHANGE_ID), | ||
| GetVersionInterleavedUpdateReplayTest.extractVersionChangeIds(history.getEvents())); | ||
|
|
||
| TestWorkflowEnvironment testEnvironment = TestWorkflowEnvironment.newInstance(); | ||
| ReplayWorkflowRunTaskHandler runTaskHandler = null; | ||
| try { | ||
| Worker worker = testEnvironment.newWorker(GetVersionInterleavedUpdateReplayTest.TASK_QUEUE); | ||
| worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); | ||
|
|
||
| ReplayWorkflowTaskHandler replayTaskHandler = getNonStickyReplayTaskHandler(worker); | ||
| PollWorkflowTaskQueueResponse.Builder replayTask = newReplayTask(history); | ||
| runTaskHandler = createStatefulHandler(replayTaskHandler, replayTask); | ||
|
|
||
| WorkflowServiceStubs service = | ||
| getField(replayTaskHandler, "service", WorkflowServiceStubs.class); | ||
| String namespace = getField(replayTaskHandler, "namespace", String.class); | ||
| ServiceWorkflowHistoryIterator historyIterator = | ||
| new ServiceWorkflowHistoryIterator(service, namespace, replayTask, new NoopScope()); | ||
|
|
||
| QueryResult result = | ||
| runTaskHandler.handleDirectQueryWorkflowTask(replayTask, historyIterator); | ||
| assertNotNull(result); | ||
| assertFalse(result.isWorkflowMethodCompleted()); | ||
| assertFalse(result.getResponsePayloads().isPresent()); | ||
| } finally { | ||
| if (runTaskHandler != null) { | ||
| runTaskHandler.close(); | ||
| } | ||
| testEnvironment.close(); | ||
| } | ||
| } | ||
|
|
||
| private static PollWorkflowTaskQueueResponse.Builder newReplayTask( | ||
| WorkflowExecutionHistory history) { | ||
| return PollWorkflowTaskQueueResponse.newBuilder() | ||
| .setWorkflowExecution(history.getWorkflowExecution()) | ||
| .setWorkflowType( | ||
| history | ||
| .getHistory() | ||
| .getEvents(0) | ||
| .getWorkflowExecutionStartedEventAttributes() | ||
| .getWorkflowType()) | ||
| .setStartedEventId(Long.MAX_VALUE) | ||
| .setPreviousStartedEventId(Long.MAX_VALUE) | ||
| .setHistory(history.getHistory()) | ||
| .setQuery(WorkflowQuery.newBuilder().setQueryType(WorkflowClient.QUERY_TYPE_REPLAY_ONLY)); | ||
| } | ||
|
|
||
| private static ReplayWorkflowTaskHandler getNonStickyReplayTaskHandler(Worker worker) | ||
| throws Exception { | ||
| Object workflowWorker = getField(worker, "workflowWorker", Object.class); | ||
| QueryReplayHelper queryReplayHelper = | ||
| getField(workflowWorker, "queryReplayHelper", QueryReplayHelper.class); | ||
| return getField(queryReplayHelper, "handler", ReplayWorkflowTaskHandler.class); | ||
| } | ||
|
|
||
| private static ReplayWorkflowRunTaskHandler createStatefulHandler( | ||
| ReplayWorkflowTaskHandler replayTaskHandler, PollWorkflowTaskQueueResponse.Builder replayTask) | ||
| throws Exception { | ||
| Method method = | ||
| ReplayWorkflowTaskHandler.class.getDeclaredMethod( | ||
| "createStatefulHandler", | ||
| PollWorkflowTaskQueueResponse.Builder.class, | ||
| com.uber.m3.tally.Scope.class); | ||
| method.setAccessible(true); | ||
| return (ReplayWorkflowRunTaskHandler) | ||
| method.invoke(replayTaskHandler, replayTask, new NoopScope()); | ||
| } | ||
|
|
||
| private static <T> T getField(Object target, String fieldName, Class<T> expectedType) | ||
| throws Exception { | ||
| Field field = target.getClass().getDeclaredField(fieldName); | ||
| field.setAccessible(true); | ||
| return expectedType.cast(field.get(target)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting more of these. We should think ahead at how to make sure this remains maintainable in the future.
Would you mind adding some comments on this flag and others above, indicating:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done this.