Skip to content

Conversation

@bbakerman
Copy link
Member

@bbakerman bbakerman commented Apr 4, 2025

This is related to #3879

This is the second attempt at operation cancellation.

This now uses the new graphql.EngineRunningState as the place to hold the ExecutionInput an check if its cancelled.

The execution engine code now calls into to check

There are some helpers on execution context as well for

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2025

Test Results

  318 files    318 suites   2m 39s ⏱️
4 694 tests 4 685 ✅ 9 💤 0 ❌
4 783 runs  4 774 ✅ 9 💤 0 ❌

Results for commit 9cb1c71.

♻️ This comment has been updated with latest results.

@bbakerman

This comment was marked as outdated.

…mpt-2

# Conflicts:
#	src/main/java/graphql/execution/AbstractAsyncExecutionStrategy.java
#	src/main/java/graphql/execution/AsyncExecutionStrategy.java
#	src/main/java/graphql/execution/AsyncSerialExecutionStrategy.java
#	src/main/java/graphql/execution/ExecutionContext.java
#	src/main/java/graphql/execution/ExecutionStrategy.java
#	src/main/java/graphql/execution/SubscriptionExecutionStrategy.java
#	src/test/groovy/graphql/execution/ExecutionContextBuilderTest.groovy
@bbakerman bbakerman changed the title WIP Cancel support attempt 2 Cancel support of operations Apr 9, 2025
@Nullable
private volatile ExecutionId executionId;

private final AtomicInteger isRunning = new AtomicInteger(0);
Copy link
Member Author

Choose a reason for hiding this comment

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

no longer nullable.


private final AtomicInteger isRunning = new AtomicInteger(0);

@VisibleForTesting
Copy link
Member Author

Choose a reason for hiding this comment

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

killed this - tests now create a valid one

}
//noinspection DataFlowIssue
return fn.apply(t, throwable);
});
Copy link
Member Author

Choose a reason for hiding this comment

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

idea was giving it a yellow line

this.executionId = executionId;
public void updateExecutionInput(ExecutionInput executionInput) {
this.executionInput = executionInput;
this.executionId = executionInput.getExecutionId();
Copy link
Member Author

Choose a reason for hiding this comment

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

we now can change the execution input

void throwIfCancelled() throws AbortExecutionException {
engineRunningState.throwIfCancelled();
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

These are just helper methods to make it nicer inside the ExecutionStrategies


private BiConsumer<List<Object>, Throwable> buildFieldValueMap(List<String> fieldNames, CompletableFuture<Map<String, Object>> overallResult, ExecutionContext executionContext) {
return (List<Object> results, Throwable exception) -> {
exception = executionContext.possibleCancellation(exception);
Copy link
Member Author

Choose a reason for hiding this comment

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

This does a trick - if the Throwable is already set - leave it set - otherwise check if we are cancelled and make the throwable be that

.engineRunningState(new EngineRunningState())
.engineRunningState(new EngineRunningState(ei))
.build()
ExecutionStrategyParameters executionStrategyParameters = ExecutionStrategyParameters
Copy link
Member Author

Choose a reason for hiding this comment

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

Made it a valid EngineRunningState not a test one

@bbakerman bbakerman requested a review from andimarek May 6, 2025 23:31
bbakerman added 3 commits June 5, 2025 17:54
…mpt-2

# Conflicts:
#	src/main/java/graphql/execution/ExecutionContext.java
…mpt-2

# Conflicts:
#	src/test/groovy/graphql/execution/SubscriptionExecutionStrategyTest.groovy
@bbakerman bbakerman merged commit 2e4f56e into master Jul 4, 2025
2 of 3 checks passed
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.

3 participants