-
Notifications
You must be signed in to change notification settings - Fork 5k
Port Windows/MSDTC distributed transactions support #72051
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
Conversation
src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/DtcInterfaces.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Transactions.Local/src/ILLink/ILLink.Descriptors.LibraryBuild.xml
Outdated
Show resolved
Hide resolved
} | ||
|
||
// TODO: Do we want to keep supporting this? | ||
protected OletxTransaction(SerializationInfo? serializationInfo, StreamingContext context) |
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.
Note this serialization constructor.
I'm not sure what the state of serialization is exactly - this doesn't use BinaryFormatter, just serializes as an opaque byte array.
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.
// TODO: Do we want to keep supporting this?
I think "no" :-) but @GrabYourPitchforks should make the call.
...raries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/CachedInterfaceBase.cs
Outdated
Show resolved
Hide resolved
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.
Skimmed the beginnings of this and left a few nits (I realize you didn't write much of the code). I'll review the whole thing more when it's out of draft.
src/libraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/CachedReceiver.cs
Outdated
Show resolved
Hide resolved
...ibraries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/CachedTransmitter.cs
Outdated
Show resolved
Hide resolved
...es/System.Transactions.Local/src/System/Transactions/DtcProxyShim/NotificationShimFactory.cs
Outdated
Show resolved
Hide resolved
...es/System.Transactions.Local/src/System/Transactions/DtcProxyShim/NotificationShimFactory.cs
Outdated
Show resolved
Hide resolved
...es/System.Transactions.Local/src/System/Transactions/DtcProxyShim/NotificationShimFactory.cs
Outdated
Show resolved
Hide resolved
...raries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/ResourceManagerShim.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/DTCTransactionManager.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/DTCTransactionManager.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/DtcInterfaces.cs
Outdated
Show resolved
Hide resolved
|
||
namespace System.Transactions.Oletx | ||
{ | ||
[Serializable] |
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.
I expect we want to remove all such attribution.
cc: @GrabYourPitchforks
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.
See #72051 (comment).
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.
I've commented on the COM interfaces. I'll review all when it is out of draft.
/// <param name="pPrepInfo"> | ||
/// Pointer to the caller allocated buffer to receive the prepare information. The size of pPrepInfo is determined by calling <see cref="GetPrepareInfoSize" />. | ||
/// </param> | ||
void GetPrepareInfo([MarshalAs(UnmanagedType.LPArray)] byte[] pPrepInfo); |
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.
I believe you also want [Out]
here.
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.
Thanks, I'm doing the same for ITransactionImportWhereabouts.GetWhereabouts, ITransactionExport.GetTransactionCookie, ITransactionReceiver.MarshalReturnToken, ITransactionTransmitter.MarshalPropagationToken.
Makes sense?
...em.Transactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/IResourceManager.cs
Outdated
Show resolved
Hide resolved
...System.Transactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/IPrepareInfo.cs
Outdated
Show resolved
Hide resolved
...em.Transactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/IResourceManager.cs
Outdated
Show resolved
Hide resolved
.../System.Transactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/ITmNodeName.cs
Outdated
Show resolved
Hide resolved
...sactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/ITransactionTransmitter.cs
Outdated
Show resolved
Hide resolved
...sactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/ITransactionTransmitter.cs
Outdated
Show resolved
Hide resolved
...sactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/ITransactionTransmitter.cs
Outdated
Show resolved
Hide resolved
...sactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/ITransactionTransmitter.cs
Outdated
Show resolved
Hide resolved
/// See https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms678930(v=vs.85). | ||
/// </remarks> | ||
[ComImport, Guid("5433376B-414D-11d3-B206-00C04FC2F3EF"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
internal interface ITransactionVoterNotifyAsync2 |
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.
This inherits from ITransactionOutcomeEvents
in the COM declaration. This needs at least 4 placeholders to fix the vtable layout.
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.
Thanks; I've copied the 4 methods from ITransactionOutcomeEvents to ITransactionVoterNotifyAsync2, before it's added method (VoteRequest). Can you confirm that's the proper way to do it (rather than e.g. having ITransactionVoterNotifyAsync2 extend ITransactionOutcomeEvents)?
This should be ready for review. I'll continue working on test coverage in the coming days, but the code should be more or less ready. |
...libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxTransactionManager.cs
Show resolved
Hide resolved
Re: serialization, since you removed the formatter calls within I also see some stray references to the System.Security.Permissions namespace. Those APIs are all obsolete, so be sure to remove those references. |
Thanks, removed the last lingering one.
Here's a bit more context on this... There are two places where serialization/binary formatting happens in this library:
Hopefully that provides context. As the PR stands, there's no longer any BinaryFormatter anywhere, and OletxTransaction serialization seems safe. Let me know what you think. |
623cf41
to
7767287
Compare
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.
That's a lot of code :) I skimmed through it and left a few very minor nits, but my assumption is that almost all of the code came over with little to no semantic or meaningful changes, yes? I agree with one of the comments you left about not doing work to optimize. I also see you have tests; do they provide enough coverage?
...System.Transactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/IPrepareInfo.cs
Outdated
Show resolved
Hide resolved
...raries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcProxyShimFactory.cs
Outdated
Show resolved
Hide resolved
...raries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcProxyShimFactory.cs
Outdated
Show resolved
Hide resolved
...raries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcProxyShimFactory.cs
Show resolved
Hide resolved
...raries/System.Transactions.Local/src/System/Transactions/DtcProxyShim/DtcProxyShimFactory.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxEnlistment.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxEnlistment.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxEnlistment.cs
Show resolved
Hide resolved
src/libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxEnlistment.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Transactions.Local/src/System/Transactions/Oletx/OletxTransactionManager.cs
Outdated
Show resolved
Hide resolved
@stephentoub sorry for the big pause, was busy with some other urgent stuff - will now work to merge this ASAP.
Yes, that's true - I've done my best to change absolutely nothing and simply convert C++ to C# here, only doing meaningful changes where absolutely necessary (in rare cases). I generally doubt this code is used in a perf-sensitive way which would justify the risk of optimizing/refactoring, at least not at this point...
Not enough... I've done various manual testing against SQL Server to confirm that things work, but automated testing support is lacking. Automated testing is difficult since it involves coordinating between multiple processes, crashing them at specific points, and for some (extreme0 edge cases, even doing stuff with the Windows MSDTC service. I'll be spending some time in the next few days to try to improve coverage at least to some extent - at the worst case maybe I'll continue working on test coverage after merging for rc1... How does that sound? @GrabYourPitchforks @stephentoub can you take a look at #72051 (comment) and confirm whether you really want the serialization support removed? |
7767287
to
699bdcb
Compare
@stephentoub @AaronRobinsonMSFT do you guys have any idea about the build failures? There's various "Managed parameter or return types require runtime marshalling to be enabled" errors reported on other projects, even though they're obviously related to my stuff. I've seen this page but I'm not sure what's the right thing to do here. |
src/libraries/System.Transactions.Local/src/System.Transactions.Local.csproj
Outdated
Show resolved
Hide resolved
...System.Transactions.Local/src/System/Transactions/DtcProxyShim/DTCInterfaces/IPrepareInfo.cs
Outdated
Show resolved
Hide resolved
64057d7
to
c94e4ff
Compare
@roji Is this destined for .NET 7? The cutoff is almost upon us so wondering who owns next action. |
@danmoseley yes, I'm planning to merge this for 7.0. I'm currently blocking on flaky CI test failures, and will spend some time in the next couple of days trying to find the cause.... |
5f33b62
to
a572b48
Compare
a572b48
to
b84598d
Compare
The remaining distributed transaction test failures occur only on 32-bit, these are consistent and easy to reproduce locally as well. As discussed offline, I've skipped the MSDTC tests on 32-bit for merging for rc1, I'll look into this soon. |
bravo, shay! |
Thanks @julielerman :) |
Following #71433, this PR brings over the .NET Framework distributed transaction porting the native shim to fully managed code.
There's some remaining work and cleanup but the bulk of the work should be done and ready for at least a first review. Would appreciate a good look as I'm a newcomer to porting C++ code to C#, COM interop etc.
The code supports a successful distributed transaction flow with SqlClient, tested via a console program, but has no proper test coverage yet. I'll be looking at the old netfx tests and adding test coverage next.
/cc @stephentoub @AaronRobinsonMSFT @jkotas @MichalStrehovsky @vitek-karas @ajcvickers
Closes #715