Skip to content
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

Fix | TDS RPC error on large queries in SqlCommand.ExecuteReaderAsync #1936

Merged
merged 8 commits into from Mar 21, 2023

Conversation

lcheunglci
Copy link
Contributor

@lcheunglci lcheunglci commented Feb 27, 2023

We found bug when using always encrypted with a large query with at least a parameter in async, it would insert extra bytes into the TDS packet header for the enclave byte per parameter when run in async mode resulting in the following error:

The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 2 (""): Data type 0x00 is unknown.

It turns out it was fixed in .NET Core but broken in .NET Framework, so after I backport changes i.e. move the logic of adding the enclave byte from once per parameter to once per rpc call, it seems to fix the issue.

@lcheunglci lcheunglci changed the title Fix | TDS RPC error on large queries Fix | TDS RPC error on large queries in async Feb 27, 2023
@lcheunglci lcheunglci changed the title Fix | TDS RPC error on large queries in async Fix | TDS RPC error on large queries in SqlCommand.ExecuteReaderAsync Feb 27, 2023
@Wraith2
Copy link
Contributor

Wraith2 commented Feb 28, 2023

Looks like a simple fix to a hard to investigate problem. 👍

@lcheunglci
Copy link
Contributor Author

Indeed, the fix was simple but took a long time to get proper environment and repro case, and apparently it happened in all versions of Microsoft.Data.SqlClient including 1.0 but somehow was still working on System.Data.SqlClient.

@DavoudEshtehari DavoudEshtehari added netfx 🐛 Bug! Something isn't right ! labels Feb 28, 2023
@DavoudEshtehari DavoudEshtehari added this to the 5.2.0-preview1 milestone Feb 28, 2023
@DavoudEshtehari DavoudEshtehari added this to In Progress in SqlClient v5.1 via automation Feb 28, 2023
@DavoudEshtehari DavoudEshtehari removed this from In Progress in SqlClient v5.1 Feb 28, 2023
@JRahnama
Copy link
Member

/azurepipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.36 ⚠️

Comparison is base (a4f18ca) 70.82% compared to head (670ad5e) 70.46%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1936      +/-   ##
==========================================
- Coverage   70.82%   70.46%   -0.36%     
==========================================
  Files         292      306      +14     
  Lines       61777    61563     -214     
==========================================
- Hits        43752    43380     -372     
- Misses      18025    18183     +158     
Flag Coverage Δ
addons 92.38% <ø> (ø)
netcore 73.27% <ø> (-1.16%) ⬇️
netfx 69.07% <100.00%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs 70.84% <100.00%> (-0.31%) ⬇️

... and 54 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Co-authored-by: DavoudEshtehari <61173489+DavoudEshtehari@users.noreply.github.com>
@lcheunglci lcheunglci merged commit 3e52e42 into dotnet:main Mar 21, 2023
131 checks passed
lcheunglci added a commit to lcheunglci/SqlClient that referenced this pull request Mar 23, 2023
lcheunglci added a commit to lcheunglci/SqlClient that referenced this pull request Mar 30, 2023
lcheunglci added a commit to lcheunglci/SqlClient that referenced this pull request Mar 30, 2023
lcheunglci added a commit to lcheunglci/SqlClient that referenced this pull request Mar 31, 2023
DavoudEshtehari pushed a commit to DavoudEshtehari/SqlClient that referenced this pull request Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug! Something isn't right ! netfx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants