Page 1 of 1

Access Violation when connecting to MySQL Server

Posted: Fri 11 Mar 2011 11:09
by TommyA
I have a windows service application that is installed on a number of machines. The service application uses MyDAC version 5.90.0.60 and is built using C++ Builder 2010. The services are all connected (direct connection) to a database on the same local network as the servers. The database is MySQL version 5.1.41.

From time to time I get an access violation when trying to connect to the database from a service application. There doesn't seem to be a direct pattern. However this week I had two of the three services I had running produce the access violation within 4 seconds. Both at precisely the same place in code.

The error message:

Code: Select all

19:59:10.084 Access violation at address 57F50003. Read of address 57F50003
This is the stack trace of the problem:

Code: Select all

(001B7425){test.exe} [005B8425] DBAccess.__fastcall Dbaccess::TCustomDAConnection::DoError + $1D
(001E3D57){test.exe} [005E4D57] CRAccess.__fastcall Craccess::TCRConnection::DoError + $63
(00217AFC){test.exe} [00618AFC] MyClasses.__fastcall Myclasses::TMySQLConnection::DoError + $8
(00217604){test.exe} [00618604] MyClasses.__fastcall Myclasses::TMySQLConnection::MySQLError + $AC
(00217522){test.exe} [00618522] MyClasses.__fastcall Myclasses::TMySQLConnection::Check + $6
(002180C4){test.exe} [006190C4] MyClasses.__fastcall Myclasses::TMySQLConnection::Connect + $210
(00204981){test.exe} [00605981] MyConnectionPool.__fastcall Myconnectionpool::TMyLocalConnectionPool::CreateNewConnector + $299
(0017F6AD){test.exe} [005806AD] CRConnectionPool.__fastcall Crconnectionpool::TCRLocalConnectionPool::GetConnection + $185
(0017FD8D){test.exe} [00580D8D] CRConnectionPool.__fastcall Crconnectionpool::TCRConnectionPoolManager::InternalGetConnection + $31
(00204A91){test.exe} [00605A91] MyConnectionPool.__fastcall Myconnectionpool::TMyConnectionPoolManager::GetConnection + $6D
(0020F40B){test.exe} [0061040B] MyAccess.__fastcall Myaccess::TCustomMyConnection::GetMySQLConnection + $67
(0020ECDE){test.exe} [0060FCDE] MyAccess.__fastcall Myaccess::TCustomMyConnection::CreateIConnection + $E
(001B577B){test.exe} [005B677B] DBAccess.__fastcall Dbaccess::TCustomDAConnection::DoConnect + $37
(0020F1F0){test.exe} [006101F0] MyAccess.__fastcall Myaccess::TCustomMyConnection::DoConnect + $0
(00210E9E){test.exe} [00611E9E] MyAccess.__fastcall Myaccess::TMyConnection::DoConnect + $22
(001B5B1B){test.exe} [005B6B1B] DBAccess.__fastcall Dbaccess::TCustomDAConnection::PerformConnect + $37
(001B7BDA){test.exe} [005B8BDA] DBAccess.__fastcall Dbaccess::TCustomDAConnection::SetConnected + $2A2
(001B5AD8){test.exe} [005B6AD8] DBAccess.__fastcall Dbaccess::TCustomDAConnection::Connect + $4
I do not have access to the MyDAC source so I can not tell you more precisely than this where the error occurs. The servers all use a connection pool with these options set:

Code: Select all

db->PoolingOptions->MaxPoolSize = 100;
db->PoolingOptions->MinPoolSize = 5;
db->PoolingOptions->Validate = false;
sb->PoolingOptions->ConnectionLifetime = 360000;
The problem is most likely triggered by the database server, I have not been able to find a way to - with certainty - reproduce the error, but it should not produce an access violation on the services. I have not tried the newest version of the MyDAC component, as my MyDAC subscription has not been renewed yet.

Posted: Mon 14 Mar 2011 09:31
by AndreyZ
Hello,

I cannot reproduce the problem. This error occurs when you are trying to connect to the server. Please try using the following code to determine the cause of this error:

Code: Select all

try
{
  MyConnection->Open();
}
catch(EMyError &e)
{
  ShowMessage(e.Message + "; ErrorCode=" + IntToStr(e.ErrorCode)); // or you can write in a log file
}