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
46504
July 11, 2006 07:51AM
3621
February 25, 2010 05:22PM
2959
November 09, 2010 06:58AM
5004
June 07, 2010 03:05PM
3225
August 31, 2011 05:59AM
7241
August 30, 2006 09:33AM
7874
November 14, 2007 03:15AM
3970
June 13, 2011 08:59AM
11446
February 12, 2008 06:04PM
7308
March 11, 2008 05:17AM
3904
April 10, 2010 06:07PM
8117
August 25, 2008 07:22PM
8502
March 23, 2008 09:27AM
5184
April 19, 2008 05:08PM
4688
May 11, 2008 12:28PM
7076
March 28, 2008 10:20AM
6230
June 05, 2008 08:21AM
4667
May 20, 2009 06:30PM
7224
April 18, 2008 12:52PM
4345
May 20, 2009 06:27PM
5153
April 30, 2008 02:21PM
4910
June 05, 2008 08:02AM
6791
May 02, 2008 01:15PM
4840
May 08, 2008 08:13PM
5027
May 08, 2008 09:05AM
7287
June 04, 2008 01:47PM
4603
May 29, 2008 04:34AM
4652
May 29, 2008 05:54AM
4922
June 02, 2008 11:47AM
9510
June 04, 2008 02:01PM
5672
June 05, 2008 07:46AM
6284
June 09, 2008 02:31AM
4402
June 09, 2008 09:53AM
4776
June 11, 2008 10:47AM
5245
June 16, 2008 06:28AM
7306
September 03, 2008 04:34PM
9184
September 05, 2008 04:09AM
5048
December 14, 2008 11:49AM
7252
May 19, 2009 08:31AM
4564
May 19, 2009 08:43AM
3836
July 29, 2009 08:59AM
3795
August 02, 2009 09:19PM
4556
August 02, 2009 03:18PM
4261
August 28, 2009 06:55PM
7489
August 31, 2009 03:02PM
4496
September 14, 2009 01:54PM
Errores de Conexion
4561
September 24, 2009 09:43PM
3748
September 25, 2009 09:30AM
4012
October 07, 2009 01:51AM
5307
November 05, 2009 05:09PM
3938
November 25, 2009 06:51AM
3120
November 26, 2009 04:13AM
3628
December 28, 2009 10:31PM
4156
February 02, 2010 09:55AM
8479
February 12, 2010 08:35AM
4045
March 01, 2010 03:08PM
3299
March 03, 2010 08:23AM
5090
March 05, 2010 07:57AM
2846
March 06, 2010 04:37PM
4450
April 13, 2010 03:43PM
3057
August 08, 2010 03:15PM
2525
August 08, 2010 03:54PM
1902
September 15, 2010 10:06AM
9265
September 18, 2010 10:24AM
2068
October 10, 2010 10:05AM
1825
November 13, 2010 05:53AM
1989
October 18, 2010 04:05PM
1837
October 18, 2010 07:34PM
1852
January 20, 2011 03:13PM
2818
February 14, 2011 09:18AM
2679
January 31, 2011 04:19PM
2625
February 02, 2011 11:41AM
1697
March 17, 2011 01:35PM
1942
July 30, 2011 10:51PM
1329
August 15, 2011 03:50PM
2209
September 20, 2011 10:54AM
1176
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.