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

cache all appcontext switches #2227

Merged
merged 6 commits into from Nov 21, 2023

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Nov 17, 2023

fixes #2225

Change any uncached appcontext switches to use caching like the others.

/cc @JulianRooze

@@ -15,8 +15,8 @@ internal static partial class LocalAppContextSwitches

private static bool? s_legacyRowVersionNullBehavior;
private static bool? s_suppressInsecureTLSWarning;
private static bool s_makeReadAsyncBlocking;
private static bool s_useMinimumLoginTimeout;
private static bool? s_makeReadAsyncBlocking;
Copy link
Member

Choose a reason for hiding this comment

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

bool? is a structure with two fields. It is not updated atomically. The lock-free reads and writes below have race conditions.

If you want the reads to be lock-free, you can either:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I've updated all the variables to use the tristate enum pattern.

@jkotas
Copy link
Member

jkotas commented Nov 18, 2023

Failing tests:

  [xUnit.net 00:01:04.53]       System.InvalidCastException : Unable to cast object of type 'Tristate' to type 'System.Nullable`1[System.Boolean]'.
  [xUnit.net 00:01:04.53]       Stack Trace:
  [xUnit.net 00:01:04.53]         D:\a\_work\1\s\src\Microsoft.Data.SqlClient\tests\ManualTests\SQL\DataReaderTest\DataReaderTest.cs(330,0): at Microsoft.Data.SqlClient.ManualTesting.Tests.DataReaderTest.SetLegacyRowVersionNullBehavior(Nullable`1 value)
  [xUnit.net 00:01:04.53]         D:\a\_work\1\s\src\Microsoft.Data.SqlClient\tests\ManualTests\SQL\DataReaderTest\DataReaderTest.cs(301,0): at Microsoft.Data.SqlClient.ManualTesting.Tests.DataReaderTest.CheckLegacyNullRowVersionIsEmptyArray()

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 18, 2023

Thanks. Fixed and added note to tests and source to indicate that private reflection is being used. I wrote that test so I should have remembered.

Copy link

codecov bot commented Nov 18, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (d30d9d1) 71.49% compared to head (f1243c0) 68.34%.
Report is 1 commits behind head on main.

Files Patch % Lines
...icrosoft/Data/SqlClient/LocalAppContextSwitches.cs 64.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2227      +/-   ##
==========================================
- Coverage   71.49%   68.34%   -3.16%     
==========================================
  Files         309      309              
  Lines       62181    62195      +14     
==========================================
- Hits        44459    42506    -1953     
- Misses      17722    19689    +1967     
Flag Coverage Δ
addons 92.88% <ø> (ø)
netcore 65.87% <60.00%> (-8.69%) ⬇️
netfx 69.84% <64.00%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DavoudEshtehari DavoudEshtehari added the 💡 Enhancement New feature request label Nov 21, 2023
@DavoudEshtehari DavoudEshtehari added this to In progress in SqlClient v5.2 via automation Nov 21, 2023
@DavoudEshtehari DavoudEshtehari merged commit b02cf41 into dotnet:main Nov 21, 2023
130 of 132 checks passed
SqlClient v5.2 automation moved this from In progress to Done Nov 21, 2023
@Wraith2 Wraith2 deleted the cache-appcontext-switches branch November 22, 2023 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 Enhancement New feature request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Result of System.AppContext.GetData is not being cached
5 participants