summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2016-06-29 18:37:02 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-07-07 10:30:04 +0200
commit3b67fc6488ac10ca13561d9032f59951f82203e6 (patch)
treee0da9158d5bbc861274725bb02419e67205cee7c /src
parentee71456b887c82ff6aa2581cbb6ddb3607bba51e (diff)
downloadsssd-3b67fc6488ac10ca13561d9032f59951f82203e6.tar.gz
sssd-3b67fc6488ac10ca13561d9032f59951f82203e6.tar.xz
sssd-3b67fc6488ac10ca13561d9032f59951f82203e6.zip
SYSDB: Remove the timestamps cache on update
When the cache is upgraded, we want to avoid upgrading the timestamps cache, because it was only introduced recently in Beta, so it doesn't make senes to write complex code to change the format. This patch rather removes the cache during upgrade, it will be recreated with later lookups anyway. Reviewed-by: Sumit Bose <sbose@redhat.com>
Diffstat (limited to 'src')
-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));