MySQL Forums
Forum List  »  Spanish

Errores de Conexion
Posted by: Sonia Vazquez
Date: September 24, 2009 09:43PM

En estos días están siendo frecuentes estos errores
2005.Unknown MySQL server host 'mysql' (0)
2004.Can't create TCP/IP socket (24).
La aplicación maneja threads.Esta desarrollada en lenguaje C sobre Centos 5.3 Una breve descripcion del funcionamiento seria el sgte. Cada hilo se conecta a la base de datos. Realiza operaciones sobre tablas, cierra la conexión y termina el hilo.
Lo raro es que el momento del problema de conexión no es constante. Supongamos que quiero conectarme 1000 veces..
De esas 1000 veces son 250 la que tienen errores de conexion. Se dan de forma alternada.. 20 veces se conecta.. 2 no. Luego de nuevo 100 se conectan 15 no..
El comportamiento varia mucho.
Lo último que hice hoy fue probar solo la conexión a la base de datos. El resto del funcionamiento de la aplicación fue comentado(insert, update, delete, etc).
Sinceramente no se que puede ser.. que estaré haciendo mal....
Esta es la función que realiza la conexión.

int makeMysqlConnect(MYSQL *dbConn, const char *szHost, const char *szUser, const char *szPass,
const char *szDatabase, unsigned int iPort)
{

time_t hora_inic, hora_fin;
int temps;
hora_inic = time(NULL);
pthread_t tid = pthread_self();

printf("[%lu]szHost %s\n", tid,szHost);
printf("[%lu]szUser %s\n", tid,szUser);
printf("[%lu]szPass %s\n", tid,szPass);
printf("[%lu]iPort %d\n", tid,iPort);

if (mysql_init(dbConn))
{

if (mysql_real_connect(dbConn, szHost , szUser, szPass, NULL, iPort , NULL, 0))
{

if(!mysql_select_db(dbConn, szDatabase))
{
printf("[%lu]Fallo en seteo de autocommit = false. %u.%s\n", tid, mysql_errno(dbConn), mysql_error(dbConn));
closeMysql(dbConn);
return GENERIC_ERROR;
}
else
{
printf("[%lu]Fallo en la seleccion de base de datos. %u.%s\n", tid, mysql_errno(dbConn), mysql_error(dbConn));
closeMysql(dbConn);
return GENERIC_ERROR;
}
}
else
{

printf("[%lu]Fallo en la conexion a la base de datos. %u.%s\n", tid, mysql_errno(dbConn), mysql_error(dbConn));
closeMysql(dbConn);
return GENERIC_ERROR;

}

}
else
{
printf("[%lu]No se puedo crear el objeto MYSQL\n", tid);
return GENERIC_ERROR;
}

hora_fin = time(NULL);
temps=hora_fin - hora_inic;
printf("[%lu]Tiempo ejecucion en conectarse a la BD : %d segs\n",tid, temps);
return PROCESS_OK;

}
Estoy atenta a comentarios. Muchas Gracias!

Options: ReplyQuote


Subject
Views
Written By
Posted
47527
July 11, 2006 07:51AM
3766
February 25, 2010 05:22PM
3124
November 09, 2010 06:58AM
5168
June 07, 2010 03:05PM
3404
August 31, 2011 05:59AM
7385
August 30, 2006 09:33AM
8045
November 14, 2007 03:15AM
4292
June 13, 2011 08:59AM
11597
February 12, 2008 06:04PM
7449
March 11, 2008 05:17AM
4050
April 10, 2010 06:07PM
8266
August 25, 2008 07:22PM
8648
March 23, 2008 09:27AM
5328
April 19, 2008 05:08PM
4828
May 11, 2008 12:28PM
7241
March 28, 2008 10:20AM
6387
June 05, 2008 08:21AM
4809
May 20, 2009 06:30PM
7367
April 18, 2008 12:52PM
4486
May 20, 2009 06:27PM
5290
April 30, 2008 02:21PM
5066
June 05, 2008 08:02AM
6958
May 02, 2008 01:15PM
5077
May 08, 2008 08:13PM
5174
May 08, 2008 09:05AM
7431
June 04, 2008 01:47PM
4743
May 29, 2008 04:34AM
4791
May 29, 2008 05:54AM
5059
June 02, 2008 11:47AM
9869
June 04, 2008 02:01PM
5832
June 05, 2008 07:46AM
6428
June 09, 2008 02:31AM
4540
June 09, 2008 09:53AM
4922
June 11, 2008 10:47AM
5390
June 16, 2008 06:28AM
7466
September 03, 2008 04:34PM
9339
September 05, 2008 04:09AM
5191
December 14, 2008 11:49AM
7407
May 19, 2009 08:31AM
4712
May 19, 2009 08:43AM
3971
July 29, 2009 08:59AM
3933
August 02, 2009 09:19PM
4702
August 02, 2009 03:18PM
4401
August 28, 2009 06:55PM
7640
August 31, 2009 03:02PM
4634
September 14, 2009 01:54PM
Errores de Conexion
4705
September 24, 2009 09:43PM
3885
September 25, 2009 09:30AM
4162
October 07, 2009 01:51AM
5459
November 05, 2009 05:09PM
4088
November 25, 2009 06:51AM
3261
November 26, 2009 04:13AM
3768
December 28, 2009 10:31PM
4301
February 02, 2010 09:55AM
8927
February 12, 2010 08:35AM
4185
March 01, 2010 03:08PM
3438
March 03, 2010 08:23AM
5240
March 05, 2010 07:57AM
2984
March 06, 2010 04:37PM
4623
April 13, 2010 03:43PM
3192
August 08, 2010 03:15PM
2677
August 08, 2010 03:54PM
2042
September 15, 2010 10:06AM
9572
September 18, 2010 10:24AM
2205
October 10, 2010 10:05AM
1969
November 13, 2010 05:53AM
2138
October 18, 2010 04:05PM
1974
October 18, 2010 07:34PM
1997
January 20, 2011 03:13PM
3012
February 14, 2011 09:18AM
2822
January 31, 2011 04:19PM
2877
February 02, 2011 11:41AM
1837
March 17, 2011 01:35PM
2090
July 30, 2011 10:51PM
1470
August 15, 2011 03:50PM
2346
September 20, 2011 10:54AM
1314
September 20, 2011 01:53PM


Sorry, you can't reply to this topic. It has been closed.

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.