summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/db/sysdb_init.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/db/sysdb_init.c b/src/db/sysdb_init.c
index fc7e13ac1..b713a65d3 100644
--- a/src/db/sysdb_init.c
+++ b/src/db/sysdb_init.c
@@ -612,6 +612,22 @@ done:
return ret;
}
+static errno_t remove_ts_cache(struct sysdb_ctx *sysdb)
+{
+ errno_t ret;
+
+ if (sysdb->ldb_ts_file == NULL) {
+ return EOK;
+ }
+
+ ret = unlink(sysdb->ldb_ts_file);
+ if (ret != EOK && errno != ENOENT) {
+ return errno;
+ }
+
+ return EOK;
+}
+
static int sysdb_domain_cache_connect(struct sysdb_ctx *sysdb,
struct sss_domain_info *domain,
struct sysdb_dom_upgrade_ctx *upgrade_ctx)
@@ -644,6 +660,18 @@ static int sysdb_domain_cache_connect(struct sysdb_ctx *sysdb,
goto done;
}
+ /* To be on the safe side, nuke the timestamp cache on upgrades.
+ * This is just a one-time performance hit after an upgrade
+ */
+ ret = remove_ts_cache(sysdb);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "Could not delete the timestamp ldb file (%d) (%s)\n",
+ ret, sss_strerror(ret));
+ return ret;
+ }
+
+
/* The version should now match SYSDB_VERSION.
* If not, it means we didn't match any of the
* known older versions. The DB might be
@@ -755,9 +783,8 @@ static int sysdb_timestamp_cache_connect(struct sysdb_ctx *sysdb,
"The timestamps cache could not be opened. "
"Throwing away the database and opening a new one\n");
- ret = unlink(sysdb->ldb_ts_file);
- if (ret != EOK && errno != ENOENT) {
- ret = errno;
+ ret = remove_ts_cache(sysdb);
+ if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE,
"Could not delete the timestamp ldb file (%d) (%s)\n",
ret, sss_strerror(ret));