Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TransactionStatePromoted.cs
Go to the documentation of this file.
3
4namespace System.Transactions;
5
7{
8 internal override void EnterState(InternalTransaction tx)
9 {
11 if (tx._outcomeSource._isoLevel == IsolationLevel.Snapshot)
12 {
14 }
16 DistributedCommittableTransaction distributedCommittableTransaction = null;
17 try
18 {
19 TimeSpan timeSpan;
20 if (tx.AbsoluteTimeout == long.MaxValue)
21 {
22 timeSpan = TimeSpan.Zero;
23 }
24 else
25 {
26 timeSpan = TransactionManager.TransactionTable.RecalcTimeout(tx);
27 if (timeSpan <= TimeSpan.Zero)
28 {
29 return;
30 }
31 }
33 options.IsolationLevel = tx._outcomeSource._isoLevel;
34 options.Timeout = timeSpan;
35 distributedCommittableTransaction = TransactionManager.DistributedTransactionManager.CreateTransaction(options);
36 distributedCommittableTransaction.SavedLtmPromotedTransaction = tx._outcomeSource;
38 if (log.IsEnabled())
39 {
40 log.TransactionPromoted(tx.TransactionTraceId, distributedCommittableTransaction.TransactionTraceId);
41 }
42 }
43 catch (TransactionException innerException)
44 {
47 if (log2.IsEnabled())
48 {
50 }
51 return;
52 }
53 finally
54 {
55 if (distributedCommittableTransaction == null)
56 {
58 }
59 }
60 tx.PromotedTransaction = distributedCommittableTransaction;
61 Hashtable promotedTransactionTable = TransactionManager.PromotedTransactionTable;
62 lock (promotedTransactionTable)
63 {
64 tx._finalizedObject = new FinalizedObject(tx, distributedCommittableTransaction.Identifier);
65 WeakReference value = new WeakReference(tx._outcomeSource, trackResurrection: false);
66 promotedTransactionTable[distributedCommittableTransaction.Identifier] = value;
67 }
70 }
71
72 protected bool PromotePhaseVolatiles(InternalTransaction tx, ref VolatileEnlistmentSet volatiles, bool phase0)
73 {
74 if (volatiles._volatileEnlistmentCount + volatiles._dependentClones > 0)
75 {
76 if (phase0)
77 {
78 volatiles.VolatileDemux = new Phase0VolatileDemultiplexer(tx);
79 }
80 else
81 {
82 volatiles.VolatileDemux = new Phase1VolatileDemultiplexer(tx);
83 }
84 volatiles.VolatileDemux._promotedEnlistment = tx.PromotedTransaction.EnlistVolatile(volatiles.VolatileDemux, phase0 ? EnlistmentOptions.EnlistDuringPrepareRequired : EnlistmentOptions.None);
85 }
86 return true;
87 }
88
89 internal virtual bool PromoteDurable(InternalTransaction tx)
90 {
91 if (tx._durableEnlistment != null)
92 {
93 InternalEnlistment durableEnlistment = tx._durableEnlistment;
94 IPromotedEnlistment promotedEnlistment = tx.PromotedTransaction.EnlistDurable(durableEnlistment.ResourceManagerIdentifier, (DurableInternalEnlistment)durableEnlistment, durableEnlistment.SinglePhaseNotification != null, EnlistmentOptions.None);
96 }
97 return true;
98 }
99
101 {
102 bool flag = false;
103 tx.PromotedTransaction.RealTransaction.InternalTransaction = tx;
104 try
105 {
106 flag = PromotePhaseVolatiles(tx, ref tx._phase0Volatiles, phase0: true);
107 }
108 catch (TransactionException innerException)
109 {
112 if (log.IsEnabled())
113 {
115 }
116 return;
117 }
118 finally
119 {
120 if (!flag)
121 {
124 }
125 }
126 flag = false;
127 try
128 {
129 flag = PromotePhaseVolatiles(tx, ref tx._phase1Volatiles, phase0: false);
130 }
131 catch (TransactionException innerException2)
132 {
133 TransactionException exception2 = (TransactionException)(tx._innerException = innerException2);
135 if (log2.IsEnabled())
136 {
137 log2.ExceptionConsumed(exception2);
138 }
139 return;
140 }
141 finally
142 {
143 if (!flag)
144 {
147 }
148 }
149 flag = false;
150 try
151 {
152 flag = PromoteDurable(tx);
153 }
154 catch (TransactionException innerException3)
155 {
156 TransactionException exception3 = (TransactionException)(tx._innerException = innerException3);
158 if (log3.IsEnabled())
159 {
160 log3.ExceptionConsumed(exception3);
161 }
162 }
163 finally
164 {
165 if (!flag)
166 {
169 }
170 }
171 }
172
173 internal override void DisposeRoot(InternalTransaction tx)
174 {
175 tx.State.Rollback(tx, null);
176 }
177}
static string CannotPromoteSnapshot
Definition SR.cs:20
Definition SR.cs:7
IPromotedEnlistment EnlistDurable(Guid resourceManagerIdentifier, DurableInternalEnlistment internalEnlistment, bool v, EnlistmentOptions enlistmentOptions)
IPromotedEnlistment EnlistVolatile(InternalEnlistment internalEnlistment, EnlistmentOptions enlistmentOptions)
virtual void ChangeStatePromoted(InternalEnlistment enlistment, IPromotedEnlistment promotedEnlistment)
ISinglePhaseNotification SinglePhaseNotification
TransactionTraceIdentifier TransactionTraceId
static Exception CreateInvalidOperationException(TraceSourceType traceSource, string message, Exception innerException)
static DistributedTransactionManager DistributedTransactionManager
static void FireDistributedTransactionStarted(Transaction transaction)
override void EnterState(InternalTransaction tx)
override void DisposeRoot(InternalTransaction tx)
virtual bool PromoteDurable(InternalTransaction tx)
bool PromotePhaseVolatiles(InternalTransaction tx, ref VolatileEnlistmentSet volatiles, bool phase0)
virtual void PromoteEnlistmentsAndOutcome(InternalTransaction tx)
virtual void Rollback(InternalTransaction tx, Exception e)
virtual void ChangeStateAbortedDuringPromotion(InternalTransaction tx)
void CommonEnterState(InternalTransaction tx)
void ExceptionConsumed(TraceSourceType traceSource, Exception exception)
void TransactionPromoted(TransactionTraceIdentifier transactionID, TransactionTraceIdentifier distributedTxID)
static readonly TransactionsEtwProvider Log
static readonly TimeSpan Zero
Definition TimeSpan.cs:21