Bug #31703 Should Throw NotSupportedException When Enlisting In Distributed Transaction

Submitted: 18 Oct 2007 20:13 Modified: 13 Nov 2007 11:34
Reporter: Dean Ward Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.1.3 RC OS:Windows (XP SP2)
Assigned to: CPU Architecture:Any
Tags: Promotable Single Phase Enlistment, PSPE, TransactionScope

[18 Oct 2007 20:13] Dean Ward
Description:
In MySqlConnection::EnlistConnection there is the following code:

if (this.driver.CurrentTransaction == null)
{
   MySqlPromotableTransaction promotableSinglePhaseNotification = new MySqlPromotableTransaction(this, transaction);
   transaction.EnlistPromotableSinglePhase(promotableSinglePhaseNotification);
   ...
}

As MySql Connector/Net doesn't support promotable single phase enlistment just yet it should read:

if (this.driver.CurrentTransaction == null)
{
   MySqlPromotableTransaction promotableSinglePhaseNotification = new MySqlPromotableTransaction(this, transaction);
   if (!transaction.EnlistPromotableSinglePhase(promotableSinglePhaseNotification))
      throw new NotSupportedException();
   ...
}

EnlistPromotableSinglePhase will return false if the transaction is already a distributed transaction - in which case the MySql driver will not be able to successfully participate in it.

How to repeat:
using (TransactionScope txScope = new TransactionScope())
{
   using (SqlConnection sqlConnection = new SqlConnection("Database=Test;Server=(local);Integrated Security=SSPI"))
   {
      sqlConnection.Open();
      using (SqlCommand sqlCommand = new SqlCommand("SELECT * FROM TEST", sqlConnection))
      {
         sqlCommand.ExecuteNonQuery();
      }
   }

   // the transaction scope will promote the ambient transaction
   // to a distributed transaction as soon as the second connection
   // is opened. MySql doesn't support distributed (MSDTC) transactions
   // so should throw a NotSupportedException
   using (MySqlConnection mySqlConnection = new MySqlConnection("Database=test;Server=localhost;Uid=test;Password=test"))
   {
      mySqlConnection.Open();
      using (MySqlCommand mySqlCommand = new MySqlCommand("SELECT * FROM TEST", mySqlConnection))
      {
         mySqlCommand.ExecuteNonQuery();
      }
   }

   txScope.Complete();
}

Suggested fix:
See above.
[23 Oct 2007 20:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/36202
[23 Oct 2007 20:54] Reggie Burnett
Fixed in 5.1.4
[5 Nov 2007 13:14] Tonci Grgin
Hi Dean and thanks for your report. Our c/NET team was faster than me but I hope you don't mind that the problem is solved :-)

Thanks for your interest in MySQL.
[13 Nov 2007 11:34] MC Brown
A note has been added to the 5.1.4 changelog: 

Connector/NET would incorrectly report success when enlisting in
        a distributed transaction, although distributed transactions are
        not supported.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.