ldap/servers/slapd/daemon.c | 31 ++++++++++++++++++++-----------
ldap/servers/slapd/libglobs.c | 30 ------------------------------
ldap/servers/slapd/proto-slap.h | 2 --
ldap/servers/slapd/slap.h | 2 --
4 files changed, 20 insertions(+), 45 deletions(-)
New commits:
commit fcd2cebe7672f7d746762e9355815ebfb8f56eae
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jun 6 15:30:41 2013 -0400
Ticket 47385 - DS not shutting down when disk monitoring threshold is reached
Bug Description: If verbose logging is enabled, it fails to correctly
identify that the logging was disabled, and it gets
stuck in an endless loop - never shutting the server down.
Also, whe the server does shutdown due to a disk full, the
pid file is not removed.
Fix Description: Check for the two possible error log levels that indicate
verbose logging is disabled. There were also logic errors
when determining if it was ok to disable access/audit logging,
and if to delete rotated logs.
Also removed the
"nsslapd-disk-monitoring-preserve-logging"
setting, as it really didn't served a purpose because it was
basically the same as
"nsslapd-disk-monitoring-logging-critical".
Lastly, if the server is being shutdown from a "disk
full"
condition, then we need to manually remove the pidfile.
https://fedorahosted.org/389/ticket/47385
Reviewed by: Noriko(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 8945c36..0120aaa 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -722,7 +722,6 @@ disk_monitoring_thread(void *nothing)
time_t now = 0;
int deleted_rotated_logs = 0;
int logging_critical = 0;
- int preserve_logging = 0;
int passed_threshold = 0;
int verbose_logging = 0;
int using_accesslog = 0;
@@ -752,7 +751,6 @@ disk_monitoring_thread(void *nothing)
* Get the config settings, as they could have changed
*/
logging_critical = config_get_disk_logging_critical();
- preserve_logging = config_get_disk_preserve_logging();
grace_period = 60 * config_get_disk_grace_period(); /* convert it to seconds */
verbose_logging = config_get_errorlog_level();
threshold = config_get_disk_threshold();
@@ -809,18 +807,21 @@ disk_monitoring_thread(void *nothing)
}
/*
* If we are low, see if we are using verbose error logging, and turn it off
+ * if logging is not critical
*/
- if(verbose_logging){
+ if(verbose_logging != 0 && verbose_logging != LDAP_DEBUG_ANY){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is low on disk (%s), remaining
space: %d Kb, "
- "setting error loglevel to zero.\n", dirstr, (disk_space /
1024), 0);
- config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, 0, errorbuf,
CONFIG_APPLY);
+ "temporarily setting error loglevel to zero.\n", dirstr,
+ (disk_space / 1024), 0);
+ /* Setting the log level back to zero, actually sets the value to
LDAP_DEBUG_ANY */
+ config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE, "0", errorbuf,
CONFIG_APPLY);
continue;
}
/*
* If we are low, there's no verbose logging, logs are not critical, then
disable the
* access/audit logs, log another error, and continue.
*/
- if(!logs_disabled && (!preserve_logging || !logging_critical)){
+ if(!logs_disabled && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s),
remaining space: %d Kb, "
"disabling access and audit logging.\n", dirstr,
(disk_space / 1024), 0);
@@ -834,7 +835,7 @@ disk_monitoring_thread(void *nothing)
* If we are low, we turned off verbose logging, logs are not critical, and we
disabled
* access/audit logging, then delete the rotated logs, log another error, and
continue.
*/
- if(!deleted_rotated_logs && (!preserve_logging || !logging_critical)){
+ if(!deleted_rotated_logs && !logging_critical){
if(disk_space < previous_mark){
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is too low on disk (%s),
remaining space: %d Kb, "
"deleting rotated logs.\n", dirstr, (disk_space / 1024),
0);
@@ -883,10 +884,10 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Available disk space is now
acceptable (%d bytes). Aborting"
" shutdown, and restoring the log
settings.\n",disk_space,0,0);
- if(!preserve_logging && using_accesslog){
+ if(logs_disabled && using_accesslog){
config_set_accesslog_enabled(LOGGING_ON);
}
- if(!preserve_logging && using_auditlog){
+ if(logs_disabled && using_auditlog){
config_set_auditlog_enabled(LOGGING_ON);
}
deleted_rotated_logs = 0;
@@ -903,7 +904,7 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is critically low on disk
(%s), remaining space: %d Kb."
" Signaling slapd for shutdown...\n", dirstr,
(disk_space / 1024), 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
return;
}
time(&now);
@@ -920,7 +921,8 @@ disk_monitoring_thread(void *nothing)
*/
LDAPDebug(LDAP_DEBUG_ANY, "Disk space is still too low (%d Kb).
Signaling slapd for shutdown...\n",
(disk_space / 1024), 0, 0);
- g_set_shutdown( SLAPI_SHUTDOWN_EXIT );
+ g_set_shutdown( SLAPI_SHUTDOWN_DISKFULL );
+
return;
}
}
@@ -1378,6 +1380,13 @@ void slapd_daemon( daemon_ports_t *ports )
#ifdef _WIN32
WSACleanup();
+#else
+ if ( g_get_shutdown() == SLAPI_SHUTDOWN_DISKFULL ){
+ /* This is a server-induced shutdown, we need to manually remove the pid file */
+ if( unlink(get_pid_file()) ){
+ LDAPDebug( LDAP_DEBUG_ANY, "Failed to remove pid file %s\n", get_pid_file(),
0, 0 );
+ }
+ }
#endif
}
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index cfb8856..b8fe9ba 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -253,7 +253,6 @@ slapi_onoff_t init_slapi_counters;
slapi_onoff_t init_entryusn_global;
slapi_onoff_t init_disk_monitoring;
slapi_onoff_t init_disk_logging_critical;
-slapi_onoff_t init_disk_preserve_logging;
slapi_onoff_t init_ndn_cache_enabled;
slapi_onoff_t init_sasl_mapping_fallback;
slapi_onoff_t init_return_orig_type;
@@ -1015,11 +1014,6 @@ static struct config_get_and_set {
(void**)&global_slapdFrontendConfig.disk_logging_critical,
CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_logging_critical,
&init_disk_logging_critical},
- {CONFIG_DISK_PRESERVE_LOGGING, config_set_disk_preserve_logging,
- NULL, 0,
- (void**)&global_slapdFrontendConfig.disk_preserve_logging,
- CONFIG_ON_OFF, (ConfigGetFunc)config_get_disk_preserve_logging,
- &init_disk_preserve_logging},
{CONFIG_NDN_CACHE, config_set_ndn_cache_enabled,
NULL, 0,
(void**)&global_slapdFrontendConfig.ndn_cache_enabled,
@@ -1493,7 +1487,6 @@ FrontendConfig_init () {
init_disk_monitoring = cfg->disk_monitoring = LDAP_OFF;
cfg->disk_threshold = 2097152; /* 2 mb */
cfg->disk_grace_period = 60; /* 1 hour */
- init_disk_preserve_logging = cfg->disk_preserve_logging = LDAP_OFF;
init_disk_logging_critical = cfg->disk_logging_critical = LDAP_OFF;
init_ndn_cache_enabled = cfg->ndn_cache_enabled = LDAP_OFF;
cfg->ndn_cache_max_size = NDN_DEFAULT_SIZE;
@@ -1694,17 +1687,6 @@ config_set_disk_threshold( const char *attrname, char *value, char
*errorbuf, in
}
int
-config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf, int
apply )
-{
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal = LDAP_SUCCESS;
-
- retVal = config_set_onoff ( attrname, value,
&(slapdFrontendConfig->disk_preserve_logging),
- errorbuf, apply);
- return retVal;
-}
-
-int
config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf, int
apply )
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -4359,18 +4341,6 @@ config_get_disk_monitoring(){
}
int
-config_get_disk_preserve_logging(){
- slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int retVal;
-
- CFG_ONOFF_LOCK_READ(slapdFrontendConfig);
- retVal = (int)slapdFrontendConfig->disk_preserve_logging;
- CFG_ONOFF_UNLOCK_READ(slapdFrontendConfig);
-
- return retVal;
-}
-
-int
config_get_disk_logging_critical(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
int retVal;
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 9fe26ff..86284fc 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -395,7 +395,6 @@ int config_set_default_naming_context( const char *attrname, char
*value, char *
int config_set_disk_monitoring( const char *attrname, char *value, char *errorbuf, int
apply );
int config_set_disk_threshold( const char *attrname, char *value, char *errorbuf, int
apply );
int config_set_disk_grace_period( const char *attrname, char *value, char *errorbuf, int
apply );
-int config_set_disk_preserve_logging( const char *attrname, char *value, char *errorbuf,
int apply );
int config_set_disk_logging_critical( const char *attrname, char *value, char *errorbuf,
int apply );
int config_set_auditlog_unhashed_pw(const char *attrname, char *value, char *errorbuf,
int apply);
int config_set_ndn_cache_enabled(const char *attrname, char *value, char *errorbuf, int
apply);
@@ -556,7 +555,6 @@ int config_get_accesslog_logging_enabled();
int config_get_disk_monitoring();
long config_get_disk_threshold();
int config_get_disk_grace_period();
-int config_get_disk_preserve_logging();
int config_get_disk_logging_critical();
int config_get_ndn_cache_count();
size_t config_get_ndn_cache_size();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 1039b0a..e1af7b9 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2078,7 +2078,6 @@ typedef struct _slapdEntryPoints {
#define CONFIG_DISK_MONITORING "nsslapd-disk-monitoring"
#define CONFIG_DISK_THRESHOLD "nsslapd-disk-monitoring-threshold"
#define CONFIG_DISK_GRACE_PERIOD "nsslapd-disk-monitoring-grace-period"
-#define CONFIG_DISK_PRESERVE_LOGGING
"nsslapd-disk-monitoring-preserve-logging"
#define CONFIG_DISK_LOGGING_CRITICAL
"nsslapd-disk-monitoring-logging-critical"
#define CONFIG_NDN_CACHE "nsslapd-ndn-cache-enabled"
#define CONFIG_NDN_CACHE_SIZE "nsslapd-ndn-cache-max-size"
@@ -2320,7 +2319,6 @@ typedef struct _slapdFrontendConfig {
slapi_onoff_t disk_monitoring;
int disk_threshold;
int disk_grace_period;
- slapi_onoff_t disk_preserve_logging;
slapi_onoff_t disk_logging_critical;
/* normalized dn cache */