Skip to content

Use cancellation token in DbCommand.ExecuteReaderAsync call in DAB layer #3300

Merged
anushakolan merged 16 commits intomainfrom
naxing/canceltoken
Mar 30, 2026
Merged

Use cancellation token in DbCommand.ExecuteReaderAsync call in DAB layer #3300
anushakolan merged 16 commits intomainfrom
naxing/canceltoken

Conversation

@naxing123
Copy link
Copy Markdown
Contributor

@naxing123 naxing123 commented Mar 19, 2026

This is to address #3301

Use cancellation token in DbCommand.ExecuteReaderAsync call in DAB layer

Problem:
RequestTimeoutAttribute only works during graphql workload execution, it doesn’t take effect during query execution as the logic to use cancellation token to DAB layer is NOT implemented, even though the code to pass cancellation token to DAB is already implemented.

Fix:
Use cancellation token to DAB layer in DbCommand.ExecuteReaderAsync call

Why make this change?

What is this change?

  • Summary of how your changes work to give reviewers context of your intent.
    • Use cancellation token(if any) in DbCommand.ExecuteReaderAsync call in DAB layer

How was this tested?

  • Integration Tests
  • Unit Tests
  • Also did manual test with long running(3 minutes) SQL query from graphql and cancellation token with 30 seconds timeout, from debugger I can see code goes to DbCommand.ExecuteReaderAsync call in DAB layer and times out after 30 seconds.

…execution

https://dev.azure.com/powerbi/AppDev/_workitems/edit/2004135

RequestTimeoutAttribute won’t take effect during query execution

Problem:
RequestTimeoutAttribute only works during graphql workload execution, it doesn’t take effect during query execution due to request executor does NOT implement cancellation token logic.

Fix:
pass cancellation token to DAB layer to DbCommand.ExecuteReaderAsync call
@naxing123 naxing123 requested a review from Aniruddh25 as a code owner March 19, 2026 18:44
Copilot AI review requested due to automatic review settings March 19, 2026 18:44
@naxing123 naxing123 changed the title pass cancellation token to DAB layer in DbCommand.ExecuteReaderAsync call Use cancellation token in DbCommand.ExecuteReaderAsync call in DAB layer Mar 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR ensures GraphQL request cancellations/timeouts propagate into the DAB database execution by passing HttpContext.RequestAborted into DbCommand.ExecuteReaderAsync, and adds unit tests to validate cancellation behavior with the Polly retry policy.

Changes:

  • Pass CancellationToken into DbCommand.ExecuteReaderAsync(CommandBehavior, CancellationToken) in the DAB query execution path.
  • Add unit tests covering cancellation/timeout exceptions and ensuring retries are not attempted.
  • Add a unit test asserting DB execution time is recorded even when an exception occurs during execution.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
src/Core/Resolvers/QueryExecutor.cs Passes HttpContext.RequestAborted into ExecuteReaderAsync while consolidating CommandBehavior selection.
src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs Adds multiple unit tests around cancellation propagation and non-retry behavior.

Comment thread src/Core/Resolvers/QueryExecutor.cs Outdated
Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs Outdated
Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs
Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs Outdated
Comment thread src/Core/Resolvers/QueryExecutor.cs
Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs Outdated
Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs Outdated
Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs
Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs
Copy link
Copy Markdown
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Needs some test deduplication.

1) merged two tests
2) updated the queryExecutor contrtructor parameter after merging main
@Aniruddh25
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 6 pipeline(s).

Comment thread src/Core/Resolvers/QueryExecutor.cs Outdated
Copy link
Copy Markdown
Contributor

@anushakolan anushakolan left a comment

Choose a reason for hiding this comment

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

The one comment from copilot is valid, and it is a better way to verify that there was no retry. Please address that, rest LGTM!

@naxing123 naxing123 requested a review from anushakolan March 26, 2026 20:26
@anushakolan
Copy link
Copy Markdown
Contributor

LGTM!

@anushakolan anushakolan enabled auto-merge (squash) March 30, 2026 16:30
@anushakolan anushakolan merged commit fbe03e5 into main Mar 30, 2026
12 checks passed
@anushakolan anushakolan deleted the naxing/canceltoken branch March 30, 2026 17:04
naxing123 added a commit that referenced this pull request Apr 1, 2026
…yer (#3300)

This is to address #3301

Use cancellation token in DbCommand.ExecuteReaderAsync call in DAB layer

Problem:
RequestTimeoutAttribute only works during graphql workload execution, it
doesn’t take effect during query execution as the logic to use
cancellation token to DAB layer is NOT implemented, even though the code
to pass cancellation token to DAB is already implemented.

Fix:
Use cancellation token to DAB layer in DbCommand.ExecuteReaderAsync call

## Why make this change?

- This is the 3rd task to address multiple GraphQL timeout related
issues. Discussion:
https://microsoft.sharepoint.com/:w:/r/teams/dbsaaspillar/_layouts/15/doc2.aspx?sourcedoc=%7B230dcf09-f556-4071-877a-8294b7df7338%7D&action=edit&wdPid=62b0c291&share=IQEJzw0jVvVxQId6gpS333M4AS2c9wqqYSgUlkTBDxQSCEw

## What is this change?

- Summary of how your changes work to give reviewers context of your
intent.
- Use cancellation token(if any) in DbCommand.ExecuteReaderAsync call in
DAB layer

## How was this tested?

- [ ] Integration Tests
- [X] Unit Tests
- Also did manual test with long running(3 minutes) SQL query from
graphql and cancellation token with 30 seconds timeout, from debugger I
can see code goes to DbCommand.ExecuteReaderAsync call in DAB layer and
times out after 30 seconds.

---------

Co-authored-by: Aniruddh Munde <[email protected]>
Co-authored-by: Anusha Kolan <[email protected]>
naxing123 added a commit that referenced this pull request Apr 2, 2026
…yer (#3300)

This is to address #3301

Use cancellation token in DbCommand.ExecuteReaderAsync call in DAB layer

Problem:
RequestTimeoutAttribute only works during graphql workload execution, it
doesn’t take effect during query execution as the logic to use
cancellation token to DAB layer is NOT implemented, even though the code
to pass cancellation token to DAB is already implemented.

Fix:
Use cancellation token to DAB layer in DbCommand.ExecuteReaderAsync call

## Why make this change?

- This is the 3rd task to address multiple GraphQL timeout related
issues. Discussion:
https://microsoft.sharepoint.com/:w:/r/teams/dbsaaspillar/_layouts/15/doc2.aspx?sourcedoc=%7B230dcf09-f556-4071-877a-8294b7df7338%7D&action=edit&wdPid=62b0c291&share=IQEJzw0jVvVxQId6gpS333M4AS2c9wqqYSgUlkTBDxQSCEw

## What is this change?

- Summary of how your changes work to give reviewers context of your
intent.
- Use cancellation token(if any) in DbCommand.ExecuteReaderAsync call in
DAB layer

## How was this tested?

- [ ] Integration Tests
- [X] Unit Tests
- Also did manual test with long running(3 minutes) SQL query from
graphql and cancellation token with 30 seconds timeout, from debugger I
can see code goes to DbCommand.ExecuteReaderAsync call in DAB layer and
times out after 30 seconds.

---------

Co-authored-by: Aniruddh Munde <[email protected]>
Co-authored-by: Anusha Kolan <[email protected]>
naxing123 added a commit that referenced this pull request Apr 2, 2026
…sync call in DAB layer (#3406)

## Why make this change?
This backport fix for to address GraphQL timeout related issues. 

## What is this change?
Cherry-picked PR: 
Use cancellation token in DbCommand.ExecuteReaderAsync call in DAB layer
#3300

## How was this tested?
1. Existing and newly added tests in the source PR.
2. Also did manual test with long running(3 minutes) SQL query from
graphql and cancellation token with 30 seconds timeout, from debugger I
can see code goes to DbCommand.ExecuteReaderAsync call in DAB layer and
times out after 30 seconds.

## Sample Request(s)
N/A

---------

Co-authored-by: Aniruddh Munde <[email protected]>
Co-authored-by: Anusha Kolan <[email protected]>
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.

5 participants