Lost db connection while in transaction = exception

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
97itr217
Posts: 19
Joined: Tue 31 Mar 2009 14:54
Location: Canada

Lost db connection while in transaction = exception

Post by 97itr217 » Wed 02 Dec 2009 18:42

Hi there,
I am observing an exception problem when connection is lost during a transaction, am wondering if gurus out there can shed some light.
Here is some background info:
IDE: BDS 2006
MyDAC: v5.55.0.39 for Delphi 2006
Windows: XP sp2
MySQL: v5.1.41-community


In my datamodule:

Code: Select all

DataModule::PingTimer()
try
{
   MyConn->Ping();
}
catch (EMyError &e)
{
   if (e.ErrorCode == CR_SERVER_LOST && m_connectionLost)
   {
       DisplayErrorDialog();
       Application->Terminate();
   }
}
/*-------------------------------------------------*/

DataModule::MyConnectConnectionLost()
m_retryConnectCount++;
if (m_retryConnectCount > m_max_retryConnectCount)
{
   m_connectionLost = true;
   RetryMode = rmRaise;
}
else
   RetryMode = rmReconnectExecute;
/*-------------------------------------------------*/

DataModule::~DataModule()
MyQuery->Close();
MyConnect->Close();

When MyConnect is not in transaction, reconnect works fine. Even if db error dialog box is display (ie: cannot reconnect successfully), exiting the application will not result in exception.

But, consider this:

In MainForm:

Code: Select all

MyConnect->StartTransaction();
MyQuery->Edit();     // MyQuery->Connection is set to MyConnect in IDE
if (ScreenForEdit->ShowModal()  == mrOk)
   MyConnect->Commit();
else
   MyConnect->Rollback();

Under this scenario, if connection is lost during the transaction and cannot be reconnected, I would get the db error dialog box. However, exiting the application will result in an exception.
From the call stack of IDE debugger, I can see that the exception was raised after the DataModules had been unloaded, and when the MyDAC internal thread (I presume there is one) tried to unload the db connection.

kernal32.RaiseException + 0x52
CC3270MT.__raiseDebuggerException + 0x1a
CC3270MT.__raiseDebuggerException + 0xf4
ntdll.RtlConvertingUlongToLargeInteger + 0x7a
ntdll.RtlConvertUlongToLargeInteger + 0x46
ntdll.kilUserExceptionDispatcher + 0xe
ntdll.kilUserExceptionDispatcher + 0xe
mydac100.@Myclasses@TMySQLTransaction@GetConnection$qqrv + 0xa8
mydac100.@Myclasses@TMySQLTransaction@Rollback$qqrv + 0x11
c:\wiondows\system32\mydac100.bpl
dac100.@Dbaccess@TDATransaction@InternalRemoveConnection$qqrp28Dbaccess@TCustomDAConnection + 0x30

By tracing under debugger, I can see that when Rollback() was executed without error when the app was terminated. All dtor were also run without error. But right after the DataModule dtor was finish, exception occurred.

Could anyone point me into the right direction to get this fixed? Thanks in advance.
Last edited by 97itr217 on Thu 03 Dec 2009 18:59, edited 1 time in total.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 03 Dec 2009 08:12

I can not reproduce the problem.
Please, try to download the latest MyDAC build and check if this problem still exists.
If this will not solve the problem, please try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.

97itr217
Posts: 19
Joined: Tue 31 Mar 2009 14:54
Location: Canada

Post by 97itr217 » Thu 03 Dec 2009 17:27

I think I have problem upgrading from 5.55 to 5.90.
I downloaded MyDAC 5.90 for BDS2006, uninstalled MyDAC 5.55 and tried to install 5.90. But as soon as the 5.90 installer starts, it says incompatible with prior version and that I need to uninstall first. Wait a minute, I have done that. So I proceeded to clean the registry. Rebooted the PC and started the installer again. Same problem.
What have I done wrong?
DW

97itr217
Posts: 19
Joined: Tue 31 Mar 2009 14:54
Location: Canada

Post by 97itr217 » Thu 03 Dec 2009 17:41

Install problem fixed.
There were dac100.bpl and mydac100.bpl still sitting in the system32 directory after uninstall (of v5.55). Once I removed these 2 files, v5.90 install went fine.

97itr217
Posts: 19
Joined: Tue 31 Mar 2009 14:54
Location: Canada

Post by 97itr217 » Thu 03 Dec 2009 18:09

Dimon,
Sample app sent. Waiting for solution...

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 04 Dec 2009 10:05

Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next MyDAC build.

arthurhabraken
Posts: 6
Joined: Tue 26 Aug 2008 19:44

Post by arthurhabraken » Wed 09 Dec 2009 10:57

We experience connection problems as well, and the solution to this problem might solve our problem too. When will that new build be available ?

Regards,
Arthur Habraken

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 09 Dec 2009 15:17

We are planning to release the new build of MyDAC in two weeks.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Post by eduardosic » Wed 16 Dec 2009 17:09

Dimon wrote:We are planning to release the new build of MyDAC in two weeks.
Dimon, this problem was fixed in build 5.90.0.54?

you don't post a Announcement for the new Build..

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 17 Dec 2009 12:51

Yes, it was.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Post by eduardosic » Fri 29 Jan 2010 23:51

Dimon wrote:Yes, it was.
not fixed.. up

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 01 Feb 2010 08:14

We have fixed this problem in the latest MyDAC build (5.90.0.55). Please, upgrade to this build to solve the problem.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: Lost db connection while in transaction = exception

Post by eduardosic » Thu 04 Feb 2010 01:15

97itr217 wrote:Hi there,
I am observing an exception problem when connection is lost during a transaction, am wondering if gurus out there can shed some light.
Here is some background info:
IDE: BDS 2006
MyDAC: v5.55.0.39 for Delphi 2006
Windows: XP sp2
MySQL: v5.1.41-community


In my datamodule:

Code: Select all

DataModule::PingTimer()
try
{
   MyConn->Ping();
}
catch (EMyError &e)
{
   if (e.ErrorCode == CR_SERVER_LOST && m_connectionLost)
   {
       DisplayErrorDialog();
       Application->Terminate();
   }
}
/*-------------------------------------------------*/

DataModule::MyConnectConnectionLost()
m_retryConnectCount++;
if (m_retryConnectCount > m_max_retryConnectCount)
{
   m_connectionLost = true;
   RetryMode = rmRaise;
}
else
   RetryMode = rmReconnectExecute;
/*-------------------------------------------------*/

DataModule::~DataModule()
MyQuery->Close();
MyConnect->Close();

When MyConnect is not in transaction, reconnect works fine. Even if db error dialog box is display (ie: cannot reconnect successfully), exiting the application will not result in exception.

But, consider this:

In MainForm:

Code: Select all

MyConnect->StartTransaction();
MyQuery->Edit();     // MyQuery->Connection is set to MyConnect in IDE
if (ScreenForEdit->ShowModal()  == mrOk)
   MyConnect->Commit();
else
   MyConnect->Rollback();

Under this scenario, if connection is lost during the transaction and cannot be reconnected, I would get the db error dialog box. However, exiting the application will result in an exception.
From the call stack of IDE debugger, I can see that the exception was raised after the DataModules had been unloaded, and when the MyDAC internal thread (I presume there is one) tried to unload the db connection.

kernal32.RaiseException + 0x52
CC3270MT.__raiseDebuggerException + 0x1a
CC3270MT.__raiseDebuggerException + 0xf4
ntdll.RtlConvertingUlongToLargeInteger + 0x7a
ntdll.RtlConvertUlongToLargeInteger + 0x46
ntdll.kilUserExceptionDispatcher + 0xe
ntdll.kilUserExceptionDispatcher + 0xe
mydac100.@Myclasses@TMySQLTransaction@GetConnection$qqrv + 0xa8
mydac100.@Myclasses@TMySQLTransaction@Rollback$qqrv + 0x11
c:\wiondows\system32\mydac100.bpl
dac100.@Dbaccess@TDATransaction@InternalRemoveConnection$qqrp28Dbaccess@TCustomDAConnection + 0x30

By tracing under debugger, I can see that when Rollback() was executed without error when the app was terminated. All dtor were also run without error. But right after the DataModule dtor was finish, exception occurred.

Could anyone point me into the right direction to get this fixed? Thanks in advance.

i'm have same problem in: http://www.devart.com/forums/viewtopic. ... 3254#53254

Post Reply