From 420189ba2f860fe29b75a2c8e426d7ca9b1ffaf7 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 27 Apr 2012 12:32:57 +0200 Subject: bugfix: active input in "light delay state" could block rsyslog termination at least for prolonged period of time... --- ChangeLog | 2 ++ runtime/queue.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 07f746a7..20a9656a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ --------------------------------------------------------------------------- Version 5.8.11 [V5-stable] 2012-04-?? +- bugfix: active input in "light delay state" could block rsyslog + termination, at least for prolonged period of time - bugfix: imptcp input name could not be set config directive was accepted, but had no effect - bugfix: assigned ruleset was lost when using disk queues diff --git a/runtime/queue.c b/runtime/queue.c index 9f318523..5e000cd2 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -2247,6 +2247,10 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) DEFiRet; struct timespec t; + if(glbl.GetGlobalInputTermState()) { + ABORT_FINALIZE(RS_RET_FORCE_TERM); + } + STATSCOUNTER_INC(pThis->ctrEnqueued, pThis->mutCtrEnqueued); /* first check if we need to discard this message (which will cause CHKiRet() to exit) */ -- cgit From 8597affe159dfd44e75bcc72a1ce42eff61da96e Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 3 May 2012 08:49:05 +0200 Subject: debug: slightly improved debug info for input module startup --- tools/syslogd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/syslogd.c b/tools/syslogd.c index af63b111..93f37e4a 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -1489,6 +1489,7 @@ runInputModules(void) pMod = module.GetNxtType(NULL, eMOD_IN); while(pMod != NULL) { if(pMod->mod.im.bCanRun) { + DBGPRINTF("trying to start input module '%s'\n", pMod->pszName); /* activate here */ bNeedsCancel = (pMod->isCompatibleWithFeature(sFEATURENonCancelInputTermination) == RS_RET_OK) ? 0 : 1; -- cgit From a4d9f6e70f4bbe24708067653516655474f46493 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 3 May 2012 09:25:06 +0200 Subject: bugfix: inside queue.c, some thread cancel states were not correctly reset. While this is a bug, we assume it did have no practical effect because the reset as it was done was set to the state the code actually had at this point. But better fix this... --- ChangeLog | 4 ++++ runtime/queue.c | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20a9656a..aed525d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,10 @@ Version 5.8.11 [V5-stable] 2012-04-?? - bugfix: hostname was not requeried on HUP Thanks to Per Jessen for reporting this bug and Marius Tomaschewski for his help in testing the fix. +- bugfix: inside queue.c, some thread cancel states were not correctly + reset. While this is a bug, we assume it did have no practical effect + because the reset as it was done was set to the state the code actually + had at this point. But better fix this... --------------------------------------------------------------------------- Version 5.8.10 [V5-stable] 2012-04-05 - bugfix: segfault on startup if $actionqueuefilename was missing for disk diff --git a/runtime/queue.c b/runtime/queue.c index 5e000cd2..9961ed4d 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -1715,7 +1715,7 @@ ConsumerReg(qqueue_t *pThis, wti_t *pWti) } /* but now cancellation is no longer permitted */ - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); + pthread_setcancelstate(iCancelStateSave, NULL); finalize_it: DBGPRINTF("regular consumer finished, iret=%d, szlog %d sz phys %d\n", iRet, @@ -1768,7 +1768,7 @@ ConsumerDA(qqueue_t *pThis, wti_t *pWti) } /* but now cancellation is no longer permitted */ - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); + pthread_setcancelstate(iCancelStateSave, NULL); /* now we are done, but need to re-aquire the mutex */ d_pthread_mutex_lock(pThis->mut); @@ -1847,7 +1847,6 @@ qqueueStart(qqueue_t *pThis) /* this is the ConstructionFinalizer */ int wrk; uchar *qName; size_t lenBuf; - int iQueueSizeSave; ASSERT(pThis != NULL); @@ -2244,8 +2243,8 @@ finalize_it: static inline rsRetVal doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) { - DEFiRet; struct timespec t; + DEFiRet; if(glbl.GetGlobalInputTermState()) { ABORT_FINALIZE(RS_RET_FORCE_TERM); @@ -2279,7 +2278,7 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) if(flowCtlType == eFLOWCTL_FULL_DELAY) { while(pThis->iQueueSize >= pThis->iFullDlyMrk) { DBGOPRINT((obj_t*) pThis, "enqueueMsg: FullDelay mark reached for full delayable message - blocking.\n"); - pthread_cond_wait(&pThis->belowFullDlyWtrMrk, pThis->mut); /* TODO error check? But what do then? */ + pthread_cond_wait(&pThis->belowFullDlyWtrMrk, pThis->mut); } } else if(flowCtlType == eFLOWCTL_LIGHT_DELAY) { if(pThis->iQueueSize >= pThis->iLightDlyMrk) { -- cgit From 6f529cc2daafb791ca1bbef8a3ee128833db19c1 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 3 May 2012 09:53:48 +0200 Subject: bugfix: rsyslog did not terminate when delayable inputs were blocked ...due to unvailable sources. Fixes: http://bugzilla.adiscon.com/show_bug.cgi?id=299 Thanks to Marcin M for bringing up this problem and Andre Lorbach for helping to reproduce and fix it. --- ChangeLog | 5 +++++ runtime/queue.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index aed525d2..eb99a245 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ --------------------------------------------------------------------------- Version 5.8.11 [V5-stable] 2012-04-?? +- bugfix: rsyslog did not terminate when delayable inputs were blocked + due to unvailable sources. Fixes: + http://bugzilla.adiscon.com/show_bug.cgi?id=299 + Thanks to Marcin M for bringing up this problem and Andre Lorbach + for helping to reproduce and fix it. - bugfix: active input in "light delay state" could block rsyslog termination, at least for prolonged period of time - bugfix: imptcp input name could not be set diff --git a/runtime/queue.c b/runtime/queue.c index 9961ed4d..e968806c 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -2243,8 +2243,9 @@ finalize_it: static inline rsRetVal doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) { - struct timespec t; DEFiRet; + int err; + struct timespec t; if(glbl.GetGlobalInputTermState()) { ABORT_FINALIZE(RS_RET_FORCE_TERM); @@ -2276,15 +2277,48 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) * It's a side effect, but a good one ;) -- rgerhards, 2008-03-14 */ if(flowCtlType == eFLOWCTL_FULL_DELAY) { + DBGOPRINT((obj_t*) pThis, "enqueueMsg: FullDelay mark reached for full delayable message " + "- blocking.\n"); while(pThis->iQueueSize >= pThis->iFullDlyMrk) { - DBGOPRINT((obj_t*) pThis, "enqueueMsg: FullDelay mark reached for full delayable message - blocking.\n"); - pthread_cond_wait(&pThis->belowFullDlyWtrMrk, pThis->mut); + /* We have a problem during shutdown if we block eternally. In that + * case, the the input thread cannot be terminated. So we wake up + * from time to time to check for termination. + * TODO/v6(at earliest): check if we could signal the condition during + * shutdown. However, this requires new queue registries and thus is + * far to much change for a stable version (and I am still not sure it + * is worth the effort, given how seldom this situation occurs and how + * few resources the wakeups need). -- rgerhards, 2012-05-03 + * In any case, this was the old code (if we do the TODO): + * pthread_cond_wait(&pThis->belowFullDlyWtrMrk, pThis->mut); + */ + timeoutComp(&t, 1000); + err = pthread_cond_timedwait(&pThis->belowLightDlyWtrMrk, pThis->mut, &t); + if(err != 0 && err != ETIMEDOUT) { + /* Something is really wrong now. Report to debug log and abort the + * wait. That keeps us running, even though we may lose messages. + */ + DBGOPRINT((obj_t*) pThis, "potential program bug: pthread_cond_timedwait()" + "/fulldelay returned %d\n", err); + break; + + } + DBGPRINTF("wti worker in full delay timed out, checking termination...\n"); + if(glbl.GetGlobalInputTermState()) { + ABORT_FINALIZE(RS_RET_FORCE_TERM); + } } } else if(flowCtlType == eFLOWCTL_LIGHT_DELAY) { if(pThis->iQueueSize >= pThis->iLightDlyMrk) { - DBGOPRINT((obj_t*) pThis, "enqueueMsg: LightDelay mark reached for light delayable message - blocking a bit.\n"); + DBGOPRINT((obj_t*) pThis, "enqueueMsg: LightDelay mark reached for light " + "delayable message - blocking a bit.\n"); timeoutComp(&t, 1000); /* 1000 millisconds = 1 second TODO: make configurable */ - pthread_cond_timedwait(&pThis->belowLightDlyWtrMrk, pThis->mut, &t); /* TODO error check? But what do then? */ + err = pthread_cond_timedwait(&pThis->belowLightDlyWtrMrk, pThis->mut, &t); + if(err != 0 && err != ETIMEDOUT) { + /* Something is really wrong now. Report to debug log */ + DBGOPRINT((obj_t*) pThis, "potential program bug: pthread_cond_timedwait()" + "/lightdelay returned %d\n", err); + + } } } @@ -2297,6 +2331,9 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) || (pThis->qType == QUEUETYPE_DISK && pThis->sizeOnDiskMax != 0 && pThis->tVars.disk.sizeOnDisk > pThis->sizeOnDiskMax)) { DBGOPRINT((obj_t*) pThis, "enqueueMsg: queue FULL - waiting to drain.\n"); + if(glbl.GetGlobalInputTermState()) { + ABORT_FINALIZE(RS_RET_FORCE_TERM); + } timeoutComp(&t, pThis->toEnq); STATSCOUNTER_INC(pThis->ctrFull, pThis->mutCtrFull); // TODO : handle enqOnly => discard! -- cgit From a34e46801b52b2614f9f3f16eb23e6fd14de6288 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 3 May 2012 12:32:03 +0200 Subject: bugfix: ommysql did not properly init/exit the mysql runtime library This could lead to segfaults. Triggering condition: multiple action instances using ommysql. Thanks to Tomas Heinrich for reporting this problem and providing an initial patch (which my solution is based on, I need to add more code to clean the mess up). --- ChangeLog | 5 +++++ plugins/ommysql/ommysql.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index eb99a245..03c5ca93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ --------------------------------------------------------------------------- Version 5.8.11 [V5-stable] 2012-04-?? +- bugfix: ommysql did not properly init/exit the mysql runtime library + this could lead to segfaults. Triggering condition: multiple action + instances using ommysql. Thanks to Tomas Heinrich for reporting this + problem and providing an initial patch (which my solution is based on, + I need to add more code to clean the mess up). - bugfix: rsyslog did not terminate when delayable inputs were blocked due to unvailable sources. Fixes: http://bugzilla.adiscon.com/show_bug.cgi?id=299 diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c index 58e347bf..01f6a844 100644 --- a/plugins/ommysql/ommysql.c +++ b/plugins/ommysql/ommysql.c @@ -90,7 +90,6 @@ static void closeMySQL(instanceData *pData) ASSERT(pData != NULL); if(pData->f_hmysql != NULL) { /* just to be on the safe side... */ - mysql_server_end(); mysql_close(pData->f_hmysql); pData->f_hmysql = NULL; } @@ -319,6 +318,7 @@ ENDparseSelectorAct BEGINmodExit CODESTARTmodExit + mysql_server_end(); ENDmodExit @@ -346,6 +346,14 @@ CODESTARTmodInit *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(errmsg, CORE_COMPONENT)); + + /* we need to init the MySQL library. If that fails, we cannot run */ + if(mysql_server_init(0, NULL, NULL)) { + errmsg.LogError(0, NO_ERRCODE, "ommysql: mysql_server_init() failed, plugin " + "can not run"); + ABORT_FINALIZE(RS_RET_ERR); + } + /* register our config handlers */ CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionommysqlserverport", 0, eCmdHdlrInt, NULL, &iSrvPort, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID)); -- cgit From bec43b53804ab420ba3f3652849114e42f40e16a Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 3 May 2012 13:48:46 +0200 Subject: ommysql: added support for new mysql_library_[init/exit] --- configure.ac | 16 ++++++++++++++++ plugins/ommysql/ommysql.c | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e7a2619c..5124dabd 100644 --- a/configure.ac +++ b/configure.ac @@ -514,8 +514,24 @@ if test "x$enable_mysql" = "xyes"; then [AC_MSG_FAILURE([MySQL library is missing])], [`mysql_config --libs`] ) + AC_MSG_CHECKING(if we have mysql_library_init) + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $MYSQL_CFLAGS" + save_LIBS="$LIBS" + LIBS="$LIBS $MYSQL_LIBS" + AC_TRY_LINK( + [#include + #include ], + [mysql_library_init(0, NULL, NULL)], + [have_mysql_library_init=yes], + [have_mysql_library_init=no]) + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" fi AM_CONDITIONAL(ENABLE_MYSQL, test x$enable_mysql = xyes) +if test "$have_mysql_library_init" = "yes"; then + AC_DEFINE([HAVE_MYSQL_LIBRARY_INIT], [1], [mysql_library_init available]) +fi AC_SUBST(MYSQL_CFLAGS) AC_SUBST(MYSQL_LIBS) diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c index 01f6a844..7ff89f5a 100644 --- a/plugins/ommysql/ommysql.c +++ b/plugins/ommysql/ommysql.c @@ -318,7 +318,11 @@ ENDparseSelectorAct BEGINmodExit CODESTARTmodExit +# ifdef HAVE_MYSQL_LIBRARY_INIT + mysql_library_end(); +# else mysql_server_end(); +# endif ENDmodExit @@ -348,7 +352,13 @@ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(errmsg, CORE_COMPONENT)); /* we need to init the MySQL library. If that fails, we cannot run */ - if(mysql_server_init(0, NULL, NULL)) { + if( +# ifdef HAVE_MYSQL_LIBRARY_INIT + mysql_library_init(0, NULL, NULL) +# else + mysql_server_init(0, NULL, NULL) +# endif + ) { errmsg.LogError(0, NO_ERRCODE, "ommysql: mysql_server_init() failed, plugin " "can not run"); ABORT_FINALIZE(RS_RET_ERR); -- cgit From fe8ac119f75bc6d2763896b8e1a85ecfeb41bffb Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 3 May 2012 14:52:09 +0200 Subject: preparing for 5.8.11 release --- ChangeLog | 2 +- configure.ac | 2 +- doc/manual.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03c5ca93..7cfc3a00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ --------------------------------------------------------------------------- -Version 5.8.11 [V5-stable] 2012-04-?? +Version 5.8.11 [V5-stable] 2012-05-03 - bugfix: ommysql did not properly init/exit the mysql runtime library this could lead to segfaults. Triggering condition: multiple action instances using ommysql. Thanks to Tomas Heinrich for reporting this diff --git a/configure.ac b/configure.ac index 5124dabd..ff50984a 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([rsyslog],[5.8.10],[rsyslog@lists.adiscon.com]) +AC_INIT([rsyslog],[5.8.11],[rsyslog@lists.adiscon.com]) AM_INIT_AUTOMAKE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git a/doc/manual.html b/doc/manual.html index 29ac1ad5..2ee85570 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -19,7 +19,7 @@ rsyslog support available directly from the source!

Please visit the rsyslog sponsor's page to honor the project sponsors or become one yourself! We are very grateful for any help towards the project goals.

-

This documentation is for version 5.8.10 (v5-stable branch) of rsyslog. +

This documentation is for version 5.8.11 (v5-stable branch) of rsyslog. Visit the rsyslog status page to obtain current version information and project status.

If you like rsyslog, you might -- cgit