Hi Chris,
following other reports, I made a fix on the SVN (trunk) - I did not
commited yet on branch as there is still under testing. I would really
appreciate your help in confirming the correctness of this fix, by
simply testing it - apply the attached patch to your 1.5 sources and
give it a try.
Thanks and regards,
Bogdan
Chris Maciejewski wrote:
Hi,
I just noticed OpenSIPs dies with the following output in the log,
when MySQL goes down:
ERROR:db_mysql:re_init_statement: failed while mysql_stmt_prepare:
(1243) Unknown prepared statement handler (4) given to
mysql_stmt_close
ERROR:db_mysql:db_mysql_do_prepared_query: failed to re-init statement!
ERROR:usrloc:db_timer_udomain: failed to delete from table location
ERROR:usrloc:timer: synchronizing cache failed
ERROR:db_mysql:re_init_statement: failed while mysql_stmt_prepare:
(2013) Lost connection to MySQL server during query
ERROR:db_mysql:db_mysql_do_prepared_query: failed to re-init statement!
ERROR:presence:update_db_subs: deleting expired information from database
INFO:core:handle_sigs: child process 8655 exited by a signal 11
INFO:core:handle_sigs: core was generated
INFO:core:handle_sigs: terminating due to SIGCHLD
Would it be possible to change this behaviour, so for example:
1. Both OpenSIPs and MySQL is running.
2. MySQL goes down.
3. OpenSIPs sends "500 Server error" but the process stays up and running.
4. MySQL is back online.
5. OpenSIPs resumes normal operation.
Best regards,
Chris
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Index: modules/db_mysql/dbase.c
===================================================================
--- modules/db_mysql/dbase.c (revision 5777)
+++ modules/db_mysql/dbase.c (revision 5778)
@@ -132,7 +132,9 @@
*/
for (i=0; i < (db_mysql_auto_reconnect ? 3 : 1); i++) {
if (mysql_real_query(CON_CONNECTION(_h), _s->s, _s->len) == 0) {
- if (id!=mysql_thread_id(CON_CONNECTION(_h)))
+ /* if we jsut connected (previusly disconnected) or reconect
+ on the fly was detected -> reset statements */
+ if ( CON_DISCON(_h) || (id!=mysql_thread_id(CON_CONNECTION(_h))) )
reset_all_statements(_h);
LM_DBG("discon reset for %ld\n",_h->tail);
CON_DISCON(_h) = 0;
@@ -146,7 +148,6 @@
CON_DISCON(_h) = 1;
LM_DBG("discon set for %ld\n",_h->tail);
- reset_all_statements(_h);
}
LM_ERR("driver error on query: %s\n", mysql_error(CON_CONNECTION(_h)));
return -2;
@@ -385,7 +386,6 @@
struct prep_stmt *pq_ptr;
struct my_stmt_ctx *ctx;
MYSQL_BIND *mysql_bind;
- unsigned long id;
LM_DBG("conn=%p (tail=%ld) MC=%p\n",conn, conn->tail,CON_CONNECTION(conn));
@@ -451,23 +451,18 @@
*/
LM_DBG("discon is %d for %ld\n",CON_DISCON(conn),conn->tail);
if (CON_DISCON(conn)) {
- id = mysql_thread_id(CON_CONNECTION(conn));
if (mysql_ping(CON_CONNECTION(conn))) {
code = mysql_errno(CON_CONNECTION(conn));
LM_ERR("driver error on ping: (%u) %s\n", code,
mysql_error(CON_CONNECTION(conn)));
- if (code==CR_CONNECTION_ERROR || code==CR_CONN_HOST_ERROR) {
- LM_DBG("discon set for %ld\n",conn->tail);
- CON_DISCON(conn) = 1;
- }
+ /* keep the connection in disconnected state */
return -1;
}
- if (id!=mysql_thread_id(CON_CONNECTION(conn))) {
- reset_all_statements(conn);
- if ( re_init_statement(conn, pq_ptr, ctx)!=0 ) {
- LM_ERR("failed to re-init statement!\n");
- return -1;
- }
+ /* we are connected back ! */
+ reset_all_statements(conn);
+ if ( re_init_statement(conn, pq_ptr, ctx)!=0 ) {
+ LM_ERR("failed to re-init statement!\n");
+ return -1;
}
}
@@ -497,6 +492,10 @@
if ( mysql_stmt_bind_param(ctx->stmt, mysql_bind) ) {
LM_ERR("mysql_stmt_bind_param() failed: %s\n",
mysql_stmt_error(ctx->stmt));
+ for(i=0;i<n+un;i++) {
+ LM_ERR("param %d was found as type %d\n",
+ i,mysql_bind[i].buffer_type);
+ }
return -1;
}
@@ -522,6 +521,7 @@
mysql_stmt_error(ctx->stmt));
return -1;
}
+ code = CR_SERVER_LOST;
/* try reconnect */
} else {
if (code != CR_SERVER_GONE_ERROR && code != CR_SERVER_LOST
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users