-
Notifications
You must be signed in to change notification settings - Fork 43
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
Thread-safe Item Collections for Concurrent mode #112
Conversation
Added new ThreadSafeSessionStateItemCollection to replace built-in Microsoft one. This fixes the race condition in the indexers. Also commented out all serialization since this is intended to only be used with the in-memory session, so serialization is not necessary.
…t can be used by serializing providers.
…currentRequestsPerSession.
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.
Pull Request Overview
This pull request enhances session state management by introducing thread-safe item collections and helper methods to support concurrent requests across asynchronous session state providers.
- Introduces new helper methods for creating, serializing, and deserializing session state item collections.
- Refactors both CosmosDB and SQL session state providers to use thread-safe and configurable item collections.
- Updates tests to cover both standard and concurrent session collection scenarios.
Reviewed Changes
Copilot reviewed 7 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/SessionStateModule/StateSerializationUtil.cs | Adds serialization utilities handling various data types including object serialization via BinaryFormatter. |
src/CosmosDBSessionStateProviderAsync/CosmosDBSessionStateProviderAsync.cs | Refactors session store data creation to use a configurable item collection method. |
src/SqlSessionStateProviderAsync/SqlSessionStateProviderAsync.cs | Consolidates item collection creation and serialization/deserialization logic for concurrent scenarios. |
src/SessionStateModule/SessionStateModuleAsync.cs | Exposes a configuration flag to control concurrent request handling. |
src/SessionStateModule/InProcSessionStateStoreAsync.cs | Adjusts session item initialization based on the concurrent requests flag. |
test/Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test/SqlSessionStateAsyncProviderTest.cs | Extends tests with varied session collection inputs to validate serialization and deserialization logic. |
Files not reviewed (3)
- src/SessionStateModule/Microsoft.AspNet.SessionState.SessionStateModule.csproj: Language not supported
- src/SessionStateModule/Resources/SR.Designer.cs: Language not supported
- src/SessionStateModule/Resources/SR.resx: Language not supported
Comments suppressed due to low confidence (2)
test/Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync.Test/SqlSessionStateAsyncProviderTest.cs:232
- The test data method yields duplicate scenarios for session collection types which may limit the diversity of test cases. Consider diversifying the inputs to better cover all supported configurations.
public static IEnumerable<object[]> SerializeSessionData()
src/SqlSessionStateProviderAsync/SqlSessionStateProviderAsync.cs:175
- [nitpick] The 'CreateItemCollection' method is introduced in multiple files with similar logic. Consolidating this functionality into a shared utility could reduce code duplication and improve maintainability.
private static ISessionStateItemCollection CreateItemCollection()
Started with PR #99 from @mellamokb. Decided to fill out the concept to apply to all our async providers that might work in
AllowConcurrentRequestsPerSession
mode.Original PR description:
This pull request introduces significant changes to the session state management in the
CosmosDBSessionStateProviderAsync
andSqlSessionStateProviderAsync
classes, focusing on support for concurrent requests and improved serialization. The most important changes include the addition of new helper methods for creating and serializing session state item collections, as well as updates to existing methods to utilize these new helpers.