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