|
|
63fe67 |
From 9cdb6cb41b9c87c44e788cd1e354b14dbf4eb5f7 Mon Sep 17 00:00:00 2001
|
|
|
63fe67 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
63fe67 |
Date: Wed, 16 Nov 2022 16:37:05 -0500
|
|
|
63fe67 |
Subject: [PATCH 1/3] Issue 5532 - Make db compaction TOD day more robust.
|
|
|
63fe67 |
|
|
|
63fe67 |
Bug Description:
|
|
|
63fe67 |
|
|
|
63fe67 |
The time of day compaction setting does not promise that the compaction
|
|
|
63fe67 |
will happen as configured. This is becuase the compaction interval
|
|
|
63fe67 |
starts when the server is started. Once it wakes up and we are "past"
|
|
|
63fe67 |
the TOD setting then we compact, but it can happen at any time
|
|
|
63fe67 |
once the TOD has passed.
|
|
|
63fe67 |
|
|
|
63fe67 |
Fix Description:
|
|
|
63fe67 |
|
|
|
63fe67 |
Once the compaction interval is hit we create an "event" with the
|
|
|
63fe67 |
exact time the compaction should start.
|
|
|
63fe67 |
|
|
|
63fe67 |
relates: #5532
|
|
|
63fe67 |
|
|
|
63fe67 |
Reviewed by: tbordaz & spichugi(Thanks!!)
|
|
|
63fe67 |
---
|
|
|
63fe67 |
.../tests/suites/config/compact_test.py | 29 +++--
|
|
|
63fe67 |
ldap/servers/plugins/replication/cl5_api.c | 58 +++++----
|
|
|
63fe67 |
.../slapd/back-ldbm/db-bdb/bdb_layer.c | 118 ++++++++++++------
|
|
|
63fe67 |
.../slapd/back-ldbm/db-bdb/bdb_layer.h | 2 +-
|
|
|
63fe67 |
4 files changed, 136 insertions(+), 71 deletions(-)
|
|
|
63fe67 |
|
|
|
63fe67 |
diff --git a/dirsrvtests/tests/suites/config/compact_test.py b/dirsrvtests/tests/suites/config/compact_test.py
|
|
|
63fe67 |
index 1f1c097e4..2e8dee4bb 100644
|
|
|
63fe67 |
--- a/dirsrvtests/tests/suites/config/compact_test.py
|
|
|
63fe67 |
+++ b/dirsrvtests/tests/suites/config/compact_test.py
|
|
|
63fe67 |
@@ -2,6 +2,7 @@ import logging
|
|
|
63fe67 |
import pytest
|
|
|
63fe67 |
import os
|
|
|
63fe67 |
import time
|
|
|
63fe67 |
+import datetime
|
|
|
63fe67 |
from lib389.tasks import DBCompactTask
|
|
|
63fe67 |
from lib389.backend import DatabaseConfig
|
|
|
63fe67 |
from lib389.replica import Changelog5
|
|
|
63fe67 |
@@ -53,22 +54,34 @@ def test_compaction_interval_and_time(topo):
|
|
|
63fe67 |
|
|
|
63fe67 |
inst = topo.ms["supplier1"]
|
|
|
63fe67 |
|
|
|
63fe67 |
- # Configure DB compaction
|
|
|
63fe67 |
- config = DatabaseConfig(inst)
|
|
|
63fe67 |
- config.set([('nsslapd-db-compactdb-interval', '2'), ('nsslapd-db-compactdb-time', '00:01')])
|
|
|
63fe67 |
+ # Calculate the compaction time (2 minutes from now)
|
|
|
63fe67 |
+ now = datetime.datetime.now()
|
|
|
63fe67 |
+ current_hour = now.hour
|
|
|
63fe67 |
+ current_minute = now.minute + 2
|
|
|
63fe67 |
+ if current_hour < 10:
|
|
|
63fe67 |
+ hour = "0" + str(current_hour)
|
|
|
63fe67 |
+ else:
|
|
|
63fe67 |
+ hour = str(current_hour)
|
|
|
63fe67 |
+ if current_minute < 10:
|
|
|
63fe67 |
+ minute = "0" + str(current_minute)
|
|
|
63fe67 |
+ else:
|
|
|
63fe67 |
+ minute = str(current_minute)
|
|
|
63fe67 |
+ compact_time = hour + ":" + minute
|
|
|
63fe67 |
|
|
|
63fe67 |
# Configure changelog compaction
|
|
|
63fe67 |
cl5 = Changelog5(inst)
|
|
|
63fe67 |
cl5.replace_many(
|
|
|
63fe67 |
('nsslapd-changelogcompactdb-interval', '2'),
|
|
|
63fe67 |
- ('nsslapd-changelogcompactdb-time', '00:01'),
|
|
|
63fe67 |
- ('nsslapd-changelogtrim-interval', '2')
|
|
|
63fe67 |
+ ('nsslapd-changelogcompactdb-time', compact_time),
|
|
|
63fe67 |
+ ('nsslapd-changelogtrim-interval', '2')
|
|
|
63fe67 |
)
|
|
|
63fe67 |
inst.deleteErrorLogs()
|
|
|
63fe67 |
|
|
|
63fe67 |
- # Check is compaction occurred
|
|
|
63fe67 |
- time.sleep(6)
|
|
|
63fe67 |
- assert inst.searchErrorsLog("Compacting databases")
|
|
|
63fe67 |
+ # Check compaction occurred as expected
|
|
|
63fe67 |
+ time.sleep(60)
|
|
|
63fe67 |
+ assert not inst.searchErrorsLog("compacting replication changelogs")
|
|
|
63fe67 |
+
|
|
|
63fe67 |
+ time.sleep(61)
|
|
|
63fe67 |
assert inst.searchErrorsLog("compacting replication changelogs")
|
|
|
63fe67 |
inst.deleteErrorLogs(restart=False)
|
|
|
63fe67 |
|
|
|
63fe67 |
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
|
|
|
63fe67 |
index 43fa5bd46..5d4edea92 100644
|
|
|
63fe67 |
--- a/ldap/servers/plugins/replication/cl5_api.c
|
|
|
63fe67 |
+++ b/ldap/servers/plugins/replication/cl5_api.c
|
|
|
63fe67 |
@@ -103,6 +103,7 @@
|
|
|
63fe67 |
|
|
|
63fe67 |
#define NO_DISK_SPACE 1024
|
|
|
63fe67 |
#define MIN_DISK_SPACE 10485760 /* 10 MB */
|
|
|
63fe67 |
+#define _SEC_PER_DAY 86400
|
|
|
63fe67 |
|
|
|
63fe67 |
/***** Data Definitions *****/
|
|
|
63fe67 |
|
|
|
63fe67 |
@@ -293,6 +294,7 @@ static int _cl5FileEndsWith(const char *filename, const char *ext);
|
|
|
63fe67 |
|
|
|
63fe67 |
static PRLock *cl5_diskfull_lock = NULL;
|
|
|
63fe67 |
static int cl5_diskfull_flag = 0;
|
|
|
63fe67 |
+static PRBool compacting = PR_FALSE;
|
|
|
63fe67 |
|
|
|
63fe67 |
static void cl5_set_diskfull(void);
|
|
|
63fe67 |
static void cl5_set_no_diskfull(void);
|
|
|
63fe67 |
@@ -3099,7 +3101,7 @@ _cl5TrimCleanup(void)
|
|
|
63fe67 |
static time_t
|
|
|
63fe67 |
_cl5_get_tod_expiration(char *expire_time)
|
|
|
63fe67 |
{
|
|
|
63fe67 |
- time_t start_time, todays_elapsed_time, now = time(NULL);
|
|
|
63fe67 |
+ time_t todays_elapsed_time, now = time(NULL);
|
|
|
63fe67 |
struct tm *tm_struct = localtime(&now;;
|
|
|
63fe67 |
char hour_str[3] = {0};
|
|
|
63fe67 |
char min_str[3] = {0};
|
|
|
63fe67 |
@@ -3109,9 +3111,8 @@ _cl5_get_tod_expiration(char *expire_time)
|
|
|
63fe67 |
|
|
|
63fe67 |
/* Get today's start time */
|
|
|
63fe67 |
todays_elapsed_time = (tm_struct->tm_hour * 3600) + (tm_struct->tm_min * 60) + (tm_struct->tm_sec);
|
|
|
63fe67 |
- start_time = slapi_current_utc_time() - todays_elapsed_time;
|
|
|
63fe67 |
|
|
|
63fe67 |
- /* Get the hour and minute and calculate the expiring time. The time was
|
|
|
63fe67 |
+ /* Get the hour and minute and calculate the expiring TOD. The time was
|
|
|
63fe67 |
* already validated in bdb_config.c: HH:MM */
|
|
|
63fe67 |
hour_str[0] = *s++;
|
|
|
63fe67 |
hour_str[1] = *s++;
|
|
|
63fe67 |
@@ -3122,7 +3123,34 @@ _cl5_get_tod_expiration(char *expire_time)
|
|
|
63fe67 |
min = strtoll(min_str, &endp, 10);
|
|
|
63fe67 |
expiring_time = (hour * 60 * 60) + (min * 60);
|
|
|
63fe67 |
|
|
|
63fe67 |
- return start_time + expiring_time;
|
|
|
63fe67 |
+ /* Calculate the time in seconds when the compaction should start, midnight
|
|
|
63fe67 |
+ * requires special treatment (for both current time and configured TOD) */
|
|
|
63fe67 |
+ if (expiring_time == 0) {
|
|
|
63fe67 |
+ /* Compaction TOD configured for midnight */
|
|
|
63fe67 |
+ if (todays_elapsed_time == 0) {
|
|
|
63fe67 |
+ /* It's currently midnight, compact now! */
|
|
|
63fe67 |
+ return 0;
|
|
|
63fe67 |
+ } else {
|
|
|
63fe67 |
+ /* Return the time until it's midnight */
|
|
|
63fe67 |
+ return _SEC_PER_DAY - todays_elapsed_time;
|
|
|
63fe67 |
+ }
|
|
|
63fe67 |
+ } else if (todays_elapsed_time == 0) {
|
|
|
63fe67 |
+ /* It's currently midnight, just use the configured TOD */
|
|
|
63fe67 |
+ return expiring_time;
|
|
|
63fe67 |
+ } else if (todays_elapsed_time > expiring_time) {
|
|
|
63fe67 |
+ /* We missed TOD today, do it tomorrow */
|
|
|
63fe67 |
+ return _SEC_PER_DAY - (todays_elapsed_time - expiring_time);
|
|
|
63fe67 |
+ } else {
|
|
|
63fe67 |
+ /* Compaction is coming up */
|
|
|
63fe67 |
+ return expiring_time - todays_elapsed_time;
|
|
|
63fe67 |
+ }
|
|
|
63fe67 |
+}
|
|
|
63fe67 |
+
|
|
|
63fe67 |
+static void
|
|
|
63fe67 |
+do_cl_compact(time_t when, void *arg)
|
|
|
63fe67 |
+{
|
|
|
63fe67 |
+ cl5CompactDBs();
|
|
|
63fe67 |
+ compacting = PR_FALSE;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
|
|
|
63fe67 |
static int
|
|
|
63fe67 |
@@ -3131,7 +3159,6 @@ _cl5TrimMain(void *param __attribute__((unused)))
|
|
|
63fe67 |
time_t timePrev = slapi_current_utc_time();
|
|
|
63fe67 |
time_t timeCompactPrev = slapi_current_utc_time();
|
|
|
63fe67 |
time_t timeNow;
|
|
|
63fe67 |
- PRBool compacting = PR_FALSE;
|
|
|
63fe67 |
int32_t compactdb_time = 0;
|
|
|
63fe67 |
|
|
|
63fe67 |
PR_AtomicIncrement(&s_cl5Desc.threadCount);
|
|
|
63fe67 |
@@ -3144,25 +3171,14 @@ _cl5TrimMain(void *param __attribute__((unused)))
|
|
|
63fe67 |
_cl5DoTrimming();
|
|
|
63fe67 |
}
|
|
|
63fe67 |
|
|
|
63fe67 |
- if (!compacting) {
|
|
|
63fe67 |
- /* Once we know we want to compact we need to stop refreshing the
|
|
|
63fe67 |
- * TOD expiration. Otherwise if the compact time is close to
|
|
|
63fe67 |
- * midnight we could roll over past midnight during the checkpoint
|
|
|
63fe67 |
- * sleep interval, and we'd never actually compact the databases.
|
|
|
63fe67 |
- * We also need to get this value before the sleep.
|
|
|
63fe67 |
- */
|
|
|
63fe67 |
- compactdb_time = _cl5_get_tod_expiration(s_cl5Desc.dbTrim.compactTime);
|
|
|
63fe67 |
- }
|
|
|
63fe67 |
if ((s_cl5Desc.dbTrim.compactInterval > 0) &&
|
|
|
63fe67 |
- (timeNow - timeCompactPrev >= s_cl5Desc.dbTrim.compactInterval))
|
|
|
63fe67 |
+ (timeNow - timeCompactPrev >= s_cl5Desc.dbTrim.compactInterval) &&
|
|
|
63fe67 |
+ !compacting)
|
|
|
63fe67 |
{
|
|
|
63fe67 |
compacting = PR_TRUE;
|
|
|
63fe67 |
- if (slapi_current_utc_time() > compactdb_time) {
|
|
|
63fe67 |
- /* time to trim */
|
|
|
63fe67 |
- timeCompactPrev = timeNow;
|
|
|
63fe67 |
- cl5CompactDBs();
|
|
|
63fe67 |
- compacting = PR_FALSE;
|
|
|
63fe67 |
- }
|
|
|
63fe67 |
+ compactdb_time = _cl5_get_tod_expiration(s_cl5Desc.dbTrim.compactTime);
|
|
|
63fe67 |
+ slapi_eq_once_rel(do_cl_compact, NULL, slapi_current_rel_time_t() + compactdb_time);
|
|
|
63fe67 |
+ timeCompactPrev = timeNow;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
if (NULL == s_cl5Desc.clLock) {
|
|
|
63fe67 |
/* most likely, emergency */
|
|
|
63fe67 |
diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c
|
|
|
63fe67 |
index 3e29feb50..b433fa919 100644
|
|
|
63fe67 |
--- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c
|
|
|
63fe67 |
+++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c
|
|
|
63fe67 |
@@ -95,6 +95,7 @@ static int trans_batch_txn_max_sleep = 50;
|
|
|
63fe67 |
static PRBool log_flush_thread = PR_FALSE;
|
|
|
63fe67 |
static int txn_in_progress_count = 0;
|
|
|
63fe67 |
static int *txn_log_flush_pending = NULL;
|
|
|
63fe67 |
+static PRBool compacting = PR_FALSE;
|
|
|
63fe67 |
|
|
|
63fe67 |
static pthread_mutex_t sync_txn_log_flush;
|
|
|
63fe67 |
static pthread_cond_t sync_txn_log_flush_done;
|
|
|
63fe67 |
@@ -3646,13 +3647,12 @@ log_flush_threadmain(void *param)
|
|
|
63fe67 |
}
|
|
|
63fe67 |
|
|
|
63fe67 |
/*
|
|
|
63fe67 |
- * This refreshes the TOD expiration. So live changes to the configuration
|
|
|
63fe67 |
- * will take effect immediately.
|
|
|
63fe67 |
+ * Get the time in seconds when the compaction should occur
|
|
|
63fe67 |
*/
|
|
|
63fe67 |
static time_t
|
|
|
63fe67 |
bdb_get_tod_expiration(char *expire_time)
|
|
|
63fe67 |
{
|
|
|
63fe67 |
- time_t start_time, todays_elapsed_time, now = time(NULL);
|
|
|
63fe67 |
+ time_t todays_elapsed_time, now = time(NULL);
|
|
|
63fe67 |
struct tm *tm_struct = localtime(&now;;
|
|
|
63fe67 |
char hour_str[3] = {0};
|
|
|
63fe67 |
char min_str[3] = {0};
|
|
|
63fe67 |
@@ -3662,9 +3662,8 @@ bdb_get_tod_expiration(char *expire_time)
|
|
|
63fe67 |
|
|
|
63fe67 |
/* Get today's start time */
|
|
|
63fe67 |
todays_elapsed_time = (tm_struct->tm_hour * 3600) + (tm_struct->tm_min * 60) + (tm_struct->tm_sec);
|
|
|
63fe67 |
- start_time = slapi_current_utc_time() - todays_elapsed_time;
|
|
|
63fe67 |
|
|
|
63fe67 |
- /* Get the hour and minute and calculate the expiring time. The time was
|
|
|
63fe67 |
+ /* Get the hour and minute and calculate the expiring TOD. The time was
|
|
|
63fe67 |
* already validated in bdb_config.c: HH:MM */
|
|
|
63fe67 |
hour_str[0] = *s++;
|
|
|
63fe67 |
hour_str[1] = *s++;
|
|
|
63fe67 |
@@ -3675,7 +3674,55 @@ bdb_get_tod_expiration(char *expire_time)
|
|
|
63fe67 |
min = strtoll(min_str, &endp, 10);
|
|
|
63fe67 |
expiring_time = (hour * 60 * 60) + (min * 60);
|
|
|
63fe67 |
|
|
|
63fe67 |
- return start_time + expiring_time;
|
|
|
63fe67 |
+ /* Calculate the time in seconds when the compaction should start, midnight
|
|
|
63fe67 |
+ * requires special treatment (for both current time and configured TOD) */
|
|
|
63fe67 |
+ if (expiring_time == 0) {
|
|
|
63fe67 |
+ /* Compaction TOD configured for midnight */
|
|
|
63fe67 |
+ if (todays_elapsed_time == 0) {
|
|
|
63fe67 |
+ /* It's currently midnight, compact now! */
|
|
|
63fe67 |
+ return 0;
|
|
|
63fe67 |
+ } else {
|
|
|
63fe67 |
+ /* Return the time until it's midnight */
|
|
|
63fe67 |
+ return _SEC_PER_DAY - todays_elapsed_time;
|
|
|
63fe67 |
+ }
|
|
|
63fe67 |
+ } else if (todays_elapsed_time == 0) {
|
|
|
63fe67 |
+ /* It's currently midnight, just use the configured TOD */
|
|
|
63fe67 |
+ return expiring_time;
|
|
|
63fe67 |
+ } else if (todays_elapsed_time > expiring_time) {
|
|
|
63fe67 |
+ /* We missed TOD today, do it tomorrow */
|
|
|
63fe67 |
+ return _SEC_PER_DAY - (todays_elapsed_time - expiring_time);
|
|
|
63fe67 |
+ } else {
|
|
|
63fe67 |
+ /* Compaction is coming up */
|
|
|
63fe67 |
+ return expiring_time - todays_elapsed_time;
|
|
|
63fe67 |
+ }
|
|
|
63fe67 |
+}
|
|
|
63fe67 |
+
|
|
|
63fe67 |
+static void
|
|
|
63fe67 |
+bdb_compact(time_t when, void *arg)
|
|
|
63fe67 |
+{
|
|
|
63fe67 |
+ struct ldbminfo *li = (struct ldbminfo *)arg;
|
|
|
63fe67 |
+ Object *inst_obj;
|
|
|
63fe67 |
+ ldbm_instance *inst;
|
|
|
63fe67 |
+ DB *db = NULL;
|
|
|
63fe67 |
+ int rc = 0;
|
|
|
63fe67 |
+
|
|
|
63fe67 |
+ for (inst_obj = objset_first_obj(li->li_instance_set);
|
|
|
63fe67 |
+ inst_obj;
|
|
|
63fe67 |
+ inst_obj = objset_next_obj(li->li_instance_set, inst_obj))
|
|
|
63fe67 |
+ {
|
|
|
63fe67 |
+ inst = (ldbm_instance *)object_get_data(inst_obj);
|
|
|
63fe67 |
+ rc = dblayer_get_id2entry(inst->inst_be, &db);
|
|
|
63fe67 |
+ if (!db || rc) {
|
|
|
63fe67 |
+ continue;
|
|
|
63fe67 |
+ }
|
|
|
63fe67 |
+ slapi_log_err(SLAPI_LOG_NOTICE, "bdb_compact", "Compacting DB start: %s\n",
|
|
|
63fe67 |
+ inst->inst_name);
|
|
|
63fe67 |
+ /* Time to compact the DB's */
|
|
|
63fe67 |
+ dblayer_force_checkpoint(li);
|
|
|
63fe67 |
+ bdb_do_compact(li);
|
|
|
63fe67 |
+ dblayer_force_checkpoint(li);
|
|
|
63fe67 |
+ }
|
|
|
63fe67 |
+ compacting = PR_FALSE;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
|
|
|
63fe67 |
/*
|
|
|
63fe67 |
@@ -3763,15 +3810,6 @@ checkpoint_threadmain(void *param)
|
|
|
63fe67 |
PR_Lock(li->li_config_mutex);
|
|
|
63fe67 |
checkpoint_interval_update = (time_t)BDB_CONFIG(li)->bdb_checkpoint_interval;
|
|
|
63fe67 |
compactdb_interval_update = (time_t)BDB_CONFIG(li)->bdb_compactdb_interval;
|
|
|
63fe67 |
- if (!compacting) {
|
|
|
63fe67 |
- /* Once we know we want to compact we need to stop refreshing the
|
|
|
63fe67 |
- * TOD expiration. Otherwise if the compact time is close to
|
|
|
63fe67 |
- * midnight we could roll over past midnight during the checkpoint
|
|
|
63fe67 |
- * sleep interval, and we'd never actually compact the databases.
|
|
|
63fe67 |
- * We also need to get this value before the sleep.
|
|
|
63fe67 |
- */
|
|
|
63fe67 |
- compactdb_time = bdb_get_tod_expiration((char *)BDB_CONFIG(li)->bdb_compactdb_time);
|
|
|
63fe67 |
- }
|
|
|
63fe67 |
PR_Unlock(li->li_config_mutex);
|
|
|
63fe67 |
|
|
|
63fe67 |
if (compactdb_interval_update != compactdb_interval) {
|
|
|
63fe67 |
@@ -3861,23 +3899,21 @@ checkpoint_threadmain(void *param)
|
|
|
63fe67 |
* this could have been a bug in fact, where compactdb_interval
|
|
|
63fe67 |
* was 0, if you change while running it would never take effect ....
|
|
|
63fe67 |
*/
|
|
|
63fe67 |
- if (slapi_timespec_expire_check(&compactdb_expire) == TIMER_EXPIRED) {
|
|
|
63fe67 |
- compacting = PR_TRUE;
|
|
|
63fe67 |
- if (slapi_current_utc_time() < compactdb_time) {
|
|
|
63fe67 |
- /* We have passed the interval, but we need to wait for a
|
|
|
63fe67 |
- * particular TOD to pass before compacting */
|
|
|
63fe67 |
- continue;
|
|
|
63fe67 |
- }
|
|
|
63fe67 |
+ if (compactdb_interval_update != compactdb_interval ||
|
|
|
63fe67 |
+ (slapi_timespec_expire_check(&compactdb_expire) == TIMER_EXPIRED && !compacting))
|
|
|
63fe67 |
+ {
|
|
|
63fe67 |
+ /* Get the time in second when the compaction should occur */
|
|
|
63fe67 |
+ PR_Lock(li->li_config_mutex);
|
|
|
63fe67 |
+ compactdb_time = bdb_get_tod_expiration((char *)BDB_CONFIG(li)->bdb_compactdb_time);
|
|
|
63fe67 |
+ PR_Unlock(li->li_config_mutex);
|
|
|
63fe67 |
|
|
|
63fe67 |
- /* Time to compact the DB's */
|
|
|
63fe67 |
- dblayer_force_checkpoint(li);
|
|
|
63fe67 |
- bdb_compact(li);
|
|
|
63fe67 |
- dblayer_force_checkpoint(li);
|
|
|
63fe67 |
+ /* Start compaction event */
|
|
|
63fe67 |
+ compacting = PR_TRUE;
|
|
|
63fe67 |
+ slapi_eq_once_rel(bdb_compact, (void *)li, slapi_current_rel_time_t() + compactdb_time);
|
|
|
63fe67 |
|
|
|
63fe67 |
- /* Now reset the timer and compacting flag */
|
|
|
63fe67 |
+ /* reset interval timer */
|
|
|
63fe67 |
compactdb_interval = compactdb_interval_update;
|
|
|
63fe67 |
slapi_timespec_expire_at(compactdb_interval, &compactdb_expire);
|
|
|
63fe67 |
- compacting = PR_FALSE;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
}
|
|
|
63fe67 |
slapi_log_err(SLAPI_LOG_HOUSE, "checkpoint_threadmain", "Check point before leaving\n");
|
|
|
63fe67 |
@@ -6210,14 +6246,14 @@ ldbm_back_compact(Slapi_Backend *be)
|
|
|
63fe67 |
|
|
|
63fe67 |
li = (struct ldbminfo *)be->be_database->plg_private;
|
|
|
63fe67 |
dblayer_force_checkpoint(li);
|
|
|
63fe67 |
- rc = bdb_compact(li);
|
|
|
63fe67 |
+ rc = bdb_do_compact(li);
|
|
|
63fe67 |
dblayer_force_checkpoint(li);
|
|
|
63fe67 |
return rc;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
|
|
|
63fe67 |
|
|
|
63fe67 |
int32_t
|
|
|
63fe67 |
-bdb_compact(struct ldbminfo *li)
|
|
|
63fe67 |
+bdb_do_compact(struct ldbminfo *li)
|
|
|
63fe67 |
{
|
|
|
63fe67 |
Object *inst_obj;
|
|
|
63fe67 |
ldbm_instance *inst;
|
|
|
63fe67 |
@@ -6237,7 +6273,7 @@ bdb_compact(struct ldbminfo *li)
|
|
|
63fe67 |
if (!db || rc) {
|
|
|
63fe67 |
continue;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
- slapi_log_err(SLAPI_LOG_NOTICE, "bdb_compact", "Compacting DB start: %s\n",
|
|
|
63fe67 |
+ slapi_log_err(SLAPI_LOG_NOTICE, "bdb_do_compact", "Compacting DB start: %s\n",
|
|
|
63fe67 |
inst->inst_name);
|
|
|
63fe67 |
|
|
|
63fe67 |
/*
|
|
|
63fe67 |
@@ -6249,15 +6285,15 @@ bdb_compact(struct ldbminfo *li)
|
|
|
63fe67 |
DBTYPE type;
|
|
|
63fe67 |
rc = db->get_type(db, &type);
|
|
|
63fe67 |
if (rc) {
|
|
|
63fe67 |
- slapi_log_err(SLAPI_LOG_ERR, "bdb_compact",
|
|
|
63fe67 |
- "compactdb: failed to determine db type for %s: db error - %d %s\n",
|
|
|
63fe67 |
+ slapi_log_err(SLAPI_LOG_ERR, "bdb_do_compact",
|
|
|
63fe67 |
+ "Failed to determine db type for %s: db error - %d %s\n",
|
|
|
63fe67 |
inst->inst_name, rc, db_strerror(rc));
|
|
|
63fe67 |
continue;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
|
|
|
63fe67 |
rc = dblayer_txn_begin(inst->inst_be, NULL, &txn);
|
|
|
63fe67 |
if (rc) {
|
|
|
63fe67 |
- slapi_log_err(SLAPI_LOG_ERR, "bdb_compact", "compactdb: transaction begin failed: %d\n", rc);
|
|
|
63fe67 |
+ slapi_log_err(SLAPI_LOG_ERR, "bdb_do_compact", "Transaction begin failed: %d\n", rc);
|
|
|
63fe67 |
break;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
/*
|
|
|
63fe67 |
@@ -6274,26 +6310,26 @@ bdb_compact(struct ldbminfo *li)
|
|
|
63fe67 |
rc = db->compact(db, txn.back_txn_txn, NULL /*start*/, NULL /*stop*/,
|
|
|
63fe67 |
&c_data, compact_flags, NULL /*end*/);
|
|
|
63fe67 |
if (rc) {
|
|
|
63fe67 |
- slapi_log_err(SLAPI_LOG_ERR, "bdb_compact",
|
|
|
63fe67 |
- "compactdb: failed to compact %s; db error - %d %s\n",
|
|
|
63fe67 |
+ slapi_log_err(SLAPI_LOG_ERR, "bdb_do_compact",
|
|
|
63fe67 |
+ "Failed to compact %s; db error - %d %s\n",
|
|
|
63fe67 |
inst->inst_name, rc, db_strerror(rc));
|
|
|
63fe67 |
if ((rc = dblayer_txn_abort(inst->inst_be, &txn))) {
|
|
|
63fe67 |
- slapi_log_err(SLAPI_LOG_ERR, "bdb_compact", "compactdb: failed to abort txn (%s) db error - %d %s\n",
|
|
|
63fe67 |
+ slapi_log_err(SLAPI_LOG_ERR, "bdb_do_compact", "Failed to abort txn (%s) db error - %d %s\n",
|
|
|
63fe67 |
inst->inst_name, rc, db_strerror(rc));
|
|
|
63fe67 |
break;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
} else {
|
|
|
63fe67 |
- slapi_log_err(SLAPI_LOG_NOTICE, "bdb_compact",
|
|
|
63fe67 |
- "compactdb: compact %s - %d pages freed\n",
|
|
|
63fe67 |
+ slapi_log_err(SLAPI_LOG_NOTICE, "bdb_do_compact",
|
|
|
63fe67 |
+ "compact %s - %d pages freed\n",
|
|
|
63fe67 |
inst->inst_name, c_data.compact_pages_free);
|
|
|
63fe67 |
if ((rc = dblayer_txn_commit(inst->inst_be, &txn))) {
|
|
|
63fe67 |
- slapi_log_err(SLAPI_LOG_ERR, "bdb_compact", "compactdb: failed to commit txn (%s) db error - %d %s\n",
|
|
|
63fe67 |
+ slapi_log_err(SLAPI_LOG_ERR, "bdb_do_compact", "failed to commit txn (%s) db error - %d %s\n",
|
|
|
63fe67 |
inst->inst_name, rc, db_strerror(rc));
|
|
|
63fe67 |
break;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
}
|
|
|
63fe67 |
}
|
|
|
63fe67 |
- slapi_log_err(SLAPI_LOG_NOTICE, "bdb_compact", "Compacting databases finished.\n");
|
|
|
63fe67 |
+ slapi_log_err(SLAPI_LOG_NOTICE, "bdb_do_compact", "Compacting databases finished.\n");
|
|
|
63fe67 |
|
|
|
63fe67 |
return rc;
|
|
|
63fe67 |
}
|
|
|
63fe67 |
diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.h b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.h
|
|
|
63fe67 |
index e3a49dbac..65a633193 100644
|
|
|
63fe67 |
--- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.h
|
|
|
63fe67 |
+++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.h
|
|
|
63fe67 |
@@ -97,7 +97,7 @@ int bdb_db_size(Slapi_PBlock *pb);
|
|
|
63fe67 |
int bdb_upgradedb(Slapi_PBlock *pb);
|
|
|
63fe67 |
int bdb_upgradednformat(Slapi_PBlock *pb);
|
|
|
63fe67 |
int bdb_upgradeddformat(Slapi_PBlock *pb);
|
|
|
63fe67 |
-int32_t bdb_compact(struct ldbminfo *li);
|
|
|
63fe67 |
+int32_t bdb_do_compact(struct ldbminfo *li);
|
|
|
63fe67 |
int bdb_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task);
|
|
|
63fe67 |
int bdb_cleanup(struct ldbminfo *li);
|
|
|
63fe67 |
int bdb_txn_begin(struct ldbminfo *li, back_txnid parent_txn, back_txn *txn, PRBool use_lock);
|
|
|
63fe67 |
--
|
|
|
63fe67 |
2.38.1
|
|
|
63fe67 |
|