[Internal] Msdata/Direct: Adds support for Nregion synchronous commit#5375
[Internal] Msdata/Direct: Adds support for Nregion synchronous commit#5375ananth7592 wants to merge 4 commits intomsdata/directfrom
Conversation
…ng StoreClient within DocumentClient
- Refactors ConsistencyWriter to support synchronous barrier commits in NRegion accounts (< Strong) when EnableNRegionSynchronousCommit is enabled. - Ensures response is only returned once GlobalNRegionCommittedGLSN has caught up with the write LSN, preserving linearizability. - Adds coverage in StoreReaderTest for NRegion commit path.
c04dad0 to
fbc3366
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for NRegion synchronous commit functionality, enabling write consistency guarantees across multiple read regions for accounts with consistency levels below Strong.
- Introduces NRegion synchronous commit feature that ensures write barriers are met across read regions
- Extends ConsistencyWriter to handle both global strong writes and NRegion synchronous commits with barrier requests
- Adds comprehensive testing including unit tests and emulator tests with transport/HTTP interceptors
Reviewed Changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| StoreReaderTest.cs | Adds unit test for NRegion synchronous commit write barrier functionality |
| DocumentClientUnitTests.cs | Adds test to verify EnableNRegionSynchronousCommit flag is passed to StoreClient |
| CosmosItemConsistencyTests.cs | Adds emulator tests for NRegion commit with transport interceptors |
| StoreResult.cs | Adds GlobalNRegionCommittedGLSN property and parsing logic |
| StatusCodes.cs | Adds new sub-status code for NRegion commit write barrier failures |
| ServiceUnavailableException.cs | Adds error message handling for NRegion barrier failures |
| QuorumReader.cs | Updates BarrierRequestHelper calls to include new parameter |
| ConsistencyWriter.cs | Major refactor to support both global strong and NRegion write barriers |
| BarrierRequestHelper.cs | Extends to support GlobalNRegionCommittedLsn header |
| AccountProperties.cs | Adds EnableNRegionSynchronousCommit property |
| RMResources.resx | Adds error message resources for NRegion barriers |
| DocumentClient.cs | Passes account configuration to StoreClient factory |
Files not reviewed (1)
- Microsoft.Azure.Cosmos/src/RMResources.Designer.cs: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Used Http interceptor to "mock" nregioncommit feature enabled in AccountProperties. - Used Transport interceptor to mock GLobalNRegionCommitLSN for testing scenario. - Tested success and failures cases.
fbc3366 to
8745aee
Compare
| { | ||
| AccountProperties accountProperties = this.accountServiceConfiguration.AccountProperties; | ||
|
|
||
| bool enableNRegionSynchronousCommit = accountProperties.EnableNRegionSynchronousCommit; |
There was a problem hiding this comment.
Shouldn't this be more than a boolean flag (instead an absolute number of regions that must have committed)?
| <value>Global Strong write barrier has not been met for the request.</value> | ||
| </data> | ||
| <data name="NRegionCommitWriteBarrierNotMet" xml:space="preserve"> | ||
| <value>NRegion Commit write barrier has not been met for the request.</value> |
There was a problem hiding this comment.
Hint about how apps can deal with it? Should they retry? Is it useless?
|
|
||
| if (storeResponse.TryGetHeaderValue(WFConstants.BackendHeaders.GlobalNRegionCommittedGLSN, out headerValue)) | ||
| { | ||
| globalNRegionCommittedGLSN = long.Parse(headerValue, CultureInfo.InvariantCulture); |
There was a problem hiding this comment.
Should we handle any parsing issues? Right now the exception thrown would probably be confusing? - so, maybe use TryParse and have dedicated error if it fails? (I admit this should never ever happen and would be a violation of service contract - but still a good safety net IMO.
FabianMeiswinkel
left a comment
There was a problem hiding this comment.
Few NITS - otherwise looks good to me.
|
Used this PR as baseline for N region commit . Feature has been released in 3.54.0 |
Description
NRegion commit changes
Commit #1:
-Adds support for including nregioncommit account feature while creating StoreClient within DocumentClient
Commit #2
NRegion barrier writes support for < Strong consistency
Commit #3
Emulator test for NregionCommit Write Barrier
Type of change
Please delete options that are not relevant.
Closing issues
To automatically close an issue: closes #IssueNumber