public void Prepare(PreparingEnlistment preparingEnlistment) { try { log.Debug("Prepare {0}, Messages {1}. Sending the message batch.", TransactionId, Messages.Count); if (_onprepare != null) _onprepare(this); preparingEnlistment.Prepared(); } catch (Exception ex) { log.Error("Error preparing transaction {0} ({1} messages): {2}", TransactionId, Messages.Count, ex); preparingEnlistment.ForceRollback(ex); TransactionOpen = false; if (_onrollback != null) { try { _onrollback(this); } catch (Exception e2) { log.Error("Error performing rollback after a failed prepare: {0}", e2); } } } }
/// <summary> /// Notifies an enlisted object that a transaction is being prepared for commitment. /// </summary> /// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment"/> object used to send a response to the transaction manager.</param> public void Prepare(PreparingEnlistment preparingEnlistment) { onTxComplete(); session.StoreRecoveryInformation(session.ResourceManagerId, PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction), preparingEnlistment.RecoveryInformation()); preparingEnlistment.Prepared(); }
void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment) { bool success = false; try { IAsyncResult result = new PrepareAsyncResult(this, TransactionContext.handleEndPrepare, preparingEnlistment); if (result.CompletedSynchronously) { PrepareAsyncResult.End(result); preparingEnlistment.Prepared(); } success = true; } //we need to swollow the TransactionException as it could because another party aborting it catch (TransactionException) { } finally { if (!success) { preparingEnlistment.ForceRollback(); } } }
/// <summary> /// Notifies an enlisted object that a transaction is being prepared for commitment. /// </summary> /// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment"/> object used to send a response to the transaction manager.</param> public void Prepare(PreparingEnlistment preparingEnlistment) { onTxComplete(); try { using (var machineStoreForApplication = IsolatedStorageFile.GetMachineStoreForDomain()) { var name = TransactionRecoveryInformationFileName; using (var file = machineStoreForApplication.CreateFile(name + ".temp")) using(var writer = new BinaryWriter(file)) { writer.Write(session.ResourceManagerId.ToString()); writer.Write(PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction).ToString()); writer.Write(session.DatabaseName ?? ""); writer.Write(preparingEnlistment.RecoveryInformation()); file.Flush(true); } machineStoreForApplication.MoveFile(name + ".temp", name); } } catch (Exception e) { logger.ErrorException("Could not prepare distributed transaction", e); preparingEnlistment.ForceRollback(e); return; } preparingEnlistment.Prepared(); }
public virtual void Prepare(PreparingEnlistment preparingEnlistment) { Trace.WriteIf(Tracing.Is.TraceVerbose, string.Empty); if (null == preparingEnlistment) { return; } try { Operation.Info = Convert.ToBase64String(preparingEnlistment.RecoveryInformation()); if (ConfigureOperation() && Operation.Do()) { Trace.WriteIf(Tracing.Is.TraceVerbose, "preparingEnlistment.Prepared()"); preparingEnlistment.Prepared(); return; } Trace.WriteIf(Tracing.Is.TraceVerbose, "preparingEnlistment.ForceRollback()"); preparingEnlistment.ForceRollback(); } catch (Exception exception) { Trace.TraceError("{0}", exception); preparingEnlistment.ForceRollback(exception); } }
public void Prepare(PreparingEnlistment preparingEnlistment) { if (_transaction.IsValid(false) == false) preparingEnlistment.ForceRollback(); else preparingEnlistment.Prepared(); }
/// <summary> /// Notifies an enlisted object that a transaction is being prepared for commitment. /// </summary> /// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment"/> object used to send a response to the transaction manager.</param> public void Prepare(PreparingEnlistment preparingEnlistment) { try { onTxComplete(); ctx.CreateFile(TransactionRecoveryInformationFileName, stream => { var writer = new BinaryWriter(stream); writer.Write(session.ResourceManagerId.ToString()); writer.Write(transaction.LocalIdentifier); writer.Write(session.DatabaseName ?? ""); writer.Write(preparingEnlistment.RecoveryInformation()); }); session.PrepareTransaction(transaction.LocalIdentifier); } catch (Exception e) { logger.ErrorException("Could not prepare distributed transaction", e); try { session.Rollback(transaction.LocalIdentifier); DeleteFile(); } catch (Exception e2) { logger.ErrorException("Could not roll back transaction after prepare failed", e2); } preparingEnlistment.ForceRollback(e); return; } preparingEnlistment.Prepared(); }
public void Prepare(PreparingEnlistment preparingEnlistment) { lock (_sharedLock) { if (PrepareCommitAction != null) PrepareCommitAction(); } preparingEnlistment.Done(); }
public void Prepare(PreparingEnlistment preparingEnlistment) { DeveelDbException error; if (!transaction.IsOpen(out error)) { preparingEnlistment.ForceRollback(error); } else { preparingEnlistment.Prepared(); } }
public void Prepare(PreparingEnlistment preparingEnlistment) { byte[] recoveryInformation = preparingEnlistment.RecoveryInformation(); var ravenJObject = new RavenJObject { {Constants.NotForReplication, true} }; database.PutStatic("transactions/recoveryInformation/" + txId, null, new MemoryStream(recoveryInformation), ravenJObject); preparingEnlistment.Prepared(); }
public void Prepare(PreparingEnlistment preparingEnlistment) { _assertNotDisposed(); _logger.Debug("Preparing enlistment with id: {0}", Id); var information = preparingEnlistment.RecoveryInformation(); _queueStorage.Global(actions => { actions.RegisterRecoveryInformation(Id, information); }); preparingEnlistment.Prepared(); _logger.Debug("Prepared enlistment with id: {0}", Id); }
public void Prepare(PreparingEnlistment preparingEnlistment) { try { transaction.Commit(); preparingEnlistment.Prepared(); } catch (Exception ex) { preparingEnlistment.ForceRollback(ex); } }
public void Prepare(PreparingEnlistment preparingEnlistment) { try { _transaction.IsValid(); } catch(Exception e) { preparingEnlistment.ForceRollback(e); return; } preparingEnlistment.Prepared(); }
public void Prepare(PreparingEnlistment preparingEnlistment) { if (commit) { preparingEnlistment.Prepared(); } else { preparingEnlistment.ForceRollback(); // Rollback is not called after 'Rollback' vote this.WasRollback = true; preparingEnlistment.Done(); } }
/// <summary> /// Notifies an enlisted object that a transaction is being prepared for commitment. /// </summary> /// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment"/> object used to send a response to the transaction manager.</param> public void Prepare( PreparingEnlistment preparingEnlistment ) { Status = TxfmStatus.InPrepare; // TODO: Write to recovery log. foreach( var operation in operations ) { operation.Commit(); } preparingEnlistment.Prepared(); Status = TxfmStatus.InTransaction; }
/// <summary> /// Notifies an enlisted object that a transaction is being prepared for commitment. /// </summary> /// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment"/> object used to send a response to the transaction manager.</param> public void Prepare(PreparingEnlistment preparingEnlistment) { onTxComplete(); try { session.StoreRecoveryInformation(session.ResourceManagerId, PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction), preparingEnlistment.RecoveryInformation()); } catch (Exception e) { logger.ErrorException("Could not prepare distributed transaction", e); preparingEnlistment.ForceRollback(e); return; } preparingEnlistment.Prepared(); }
public void Prepare(PreparingEnlistment preparingEnlistment) { try { using (var ts = new TransactionScope(_transaction)) { _unitOfWork.Commit(); ts.Complete(); } preparingEnlistment.Prepared(); } catch (Exception ex) { preparingEnlistment.ForceRollback(ex); } }
void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment) { bool flag = false; try { IAsyncResult result = new PrepareAsyncResult(this, handleEndPrepare, preparingEnlistment); if (result.CompletedSynchronously) { PrepareAsyncResult.End(result); preparingEnlistment.Prepared(); } flag = true; } catch (TransactionException) { } finally { if (!flag) { preparingEnlistment.ForceRollback(); } } }
static void PrepareCallbackWrapper(object state) { PreparingEnlistment enlist = state as PreparingEnlistment; enlist.EnlistmentNotification.Prepare(enlist); }
public void Prepare(PreparingEnlistment preparingEnlistment) { TestLog.WriteLine("{0}: Prepare", phase); preparingEnlistment.Prepared(); }
void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment) { this.handle.OnPrepare(preparingEnlistment); }
private void OnRollBack(AcquireContextAsyncResult rollingBack) { bool flag = false; lock (this.ThisLock) { this.TooLateToEnlist = true; if (this.OperationPending && (this.AcquirePending == null)) { this.pendingRollback = rollingBack; this.pendingPreparingEnlistment = null; } else { flag = true; } } if (flag) { rollingBack.RollBack(); } }
private void OnPrepare(PreparingEnlistment preparingEnlistment) { bool flag = false; lock (this.ThisLock) { if (this.TooLateToEnlist) { return; } this.TooLateToEnlist = true; if (this.OperationPending && (this.AcquirePending == null)) { this.pendingPreparingEnlistment = preparingEnlistment; } else { flag = true; } } if (flag) { preparingEnlistment.Prepared(); } }
private void FinishOperation() { List<InstanceHandleReference> handlesPendingResolution = null; try { bool needFreedNotification; PreparingEnlistment pendingPreparingEnlistment; AcquireContextAsyncResult pendingRollback; lock (this.ThisLock) { this.OperationPending = false; this.AcquirePending = null; this.CurrentExecutionContext = null; if ((this.inProgressBind != null) && ((this.Version == -1L) || !this.IsValid)) { this.Owner.CancelBind(ref this.inProgressBind, ref handlesPendingResolution); } else if ((this.Version != -1L) && !this.IsValid) { this.Owner.Unbind(this); } needFreedNotification = this.needFreedNotification; this.needFreedNotification = false; pendingPreparingEnlistment = this.pendingPreparingEnlistment; this.pendingPreparingEnlistment = null; pendingRollback = this.pendingRollback; this.pendingRollback = null; } try { if (needFreedNotification) { this.Store.FreeInstanceHandle(this, this.ProviderObject); } } finally { if (pendingRollback != null) { pendingRollback.RollBack(); } else if (pendingPreparingEnlistment != null) { pendingPreparingEnlistment.Prepared(); } } } finally { InstanceOwner.ResolveHandles(handlesPendingResolution); } }
void DoPreparePhase () { // Call prepare on all volatile managers. foreach (IEnlistmentNotification enlist in Volatiles) { PreparingEnlistment pe = new PreparingEnlistment (this, enlist); ThreadPool.QueueUserWorkItem (new WaitCallback(PrepareCallbackWrapper), pe); /* Wait (with timeout) for manager to prepare */ TimeSpan timeout = Scope != null ? Scope.Timeout : TransactionManager.DefaultTimeout; // FIXME: Should we managers in parallel or on-by-one? if (!pe.WaitHandle.WaitOne(timeout, true)) { this.Aborted = true; throw new TimeoutException("Transaction timedout"); } if (pe.Exception != null) { innerException = pe.Exception; Aborted = true; break; } if (!pe.IsPrepared) { /* FIXME: if not prepared & !aborted as yet, then this is inDoubt ? . For now, setting aborted = true */ Aborted = true; break; } } /* Either InDoubt(tmp) or Prepare failed and Tx has rolledback */ CheckAborted (); }
public void Prepare(PreparingEnlistment preparingEnlistment) { Neo4jTransaction.DoKeepAlive(_transactionExecutionEnvironment); preparingEnlistment.Done(); }
public void Prepare(PreparingEnlistment preparingEnlistment) { // Abort if this happens before all messges are consumed if (this.channel.State == CommunicationState.Opened && this.channel.InternalPendingItems > 0) { Exception e = DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqSessionChannelsMustBeClosed))); preparingEnlistment.ForceRollback(e); this.channel.Fault(); } else { preparingEnlistment.Done(); } }
public void Prepare(PreparingEnlistment preparingEnlistment) { // Abort if this happens before all messges are consumed // Note that we are not placing any restriction on the channel state if (this.channel.TotalPendingItems > 0 || this.channel.sessiongramDoomed) { Exception e = DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqSessionChannelHasPendingItems))); this.sessiongramReceiveContext.Abandon(TimeSpan.MaxValue); preparingEnlistment.ForceRollback(e); this.channel.Fault(); } else { Transaction savedTransaction = Transaction.Current; // complete the sessiongram message within this transaction try { Transaction.Current = this.transaction; try { this.sessiongramReceiveContext.Complete(TimeSpan.MaxValue); preparingEnlistment.Done(); } catch (MsmqException msmqex) { preparingEnlistment.ForceRollback(msmqex); this.channel.Fault(); } } finally { Transaction.Current = savedTransaction; } } }
public void Prepare(PreparingEnlistment preparingEnlistment) { preparingEnlistment.Prepared(); }
public void Prepare(PreparingEnlistment preparingEnlistment) { preparingEnlistment.Done(); }
public void Prepare(PreparingEnlistment preparingEnlistment) { database.PutStatic("transactions/recoveryInformation/" + txId, null, preparingEnlistment.RecoveryInformation(), new JObject()); preparingEnlistment.Prepared(); }