Lost db connection while in transaction = exception
Posted: 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:
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:
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 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.