Skip to content

Commit

Permalink
SYSDB: remove index on dataExpireTimestamp
Browse files Browse the repository at this point in the history
This index was only used in cleanup tasks that don't run often.
On the other hand, this index is huge and degrades performance of libldb
in general.

Reviewed-by: Alejandro López <[email protected]>
Reviewed-by: Sumit Bose <[email protected]>
Reviewed-by: Tomáš Halman <[email protected]>
  • Loading branch information
alexey-tikhonov committed Jul 18, 2024
1 parent fc2a26c commit f0d4546
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/db/sysdb_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,13 @@ static errno_t sysdb_domain_cache_upgrade(TALLOC_CTX *mem_ctx,
}
}

if (strcmp(version, SYSDB_VERSION_0_24) == 0) {
ret = sysdb_upgrade_24(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

ret = EOK;
done:
sysdb->ldb = save_ldb;
Expand Down Expand Up @@ -737,6 +744,7 @@ static int sysdb_domain_cache_connect(struct sysdb_ctx *sysdb,
ret = sysdb_domain_cache_upgrade(tmp_ctx, sysdb, upgrade_ctx,
ldb, domain, version, &version);
if (ret != EOK) {
DEBUG(SSSDBG_TRACE_FUNC, "sysdb_domain_cache_upgrade() failed\n");
goto done;
}

Expand Down
9 changes: 5 additions & 4 deletions src/db/sysdb_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#ifndef __INT_SYS_DB_H__
#define __INT_SYS_DB_H__

#define SYSDB_VERSION_0_25 "0.25"
#define SYSDB_VERSION_0_24 "0.24"
#define SYSDB_VERSION_0_23 "0.23"
#define SYSDB_VERSION_0_22 "0.22"
Expand All @@ -48,7 +49,7 @@
#define SYSDB_VERSION_0_2 "0.2"
#define SYSDB_VERSION_0_1 "0.1"

#define SYSDB_VERSION SYSDB_VERSION_0_24
#define SYSDB_VERSION SYSDB_VERSION_0_25

#define SYSDB_BASE_LDIF \
"dn: @ATTRIBUTES\n" \
Expand All @@ -73,7 +74,6 @@
"@IDXATTR: uidNumber\n" \
"@IDXATTR: gidNumber\n" \
"@IDXATTR: lastUpdate\n" \
"@IDXATTR: dataExpireTimestamp\n" \
"@IDXATTR: originalDN\n" \
"@IDXATTR: nameAlias\n" \
"@IDXATTR: servicePort\n" \
Expand Down Expand Up @@ -106,18 +106,18 @@
"\n"

/* The timestamp cache has its own versioning */
#define SYSDB_TS_VERSION_0_3 "0.3"
#define SYSDB_TS_VERSION_0_2 "0.2"
#define SYSDB_TS_VERSION_0_1 "0.1"

#define SYSDB_TS_VERSION SYSDB_TS_VERSION_0_2
#define SYSDB_TS_VERSION SYSDB_TS_VERSION_0_3

#define SYSDB_TS_BASE_LDIF \
"dn: @ATTRIBUTES\n" \
"dn: CASE_INSENSITIVE\n" \
"\n" \
"dn: @INDEXLIST\n" \
"@IDXATTR: lastUpdate\n" \
"@IDXATTR: dataExpireTimestamp\n" \
"\n" \
"dn: cn=sysdb\n" \
"cn: sysdb\n" \
Expand Down Expand Up @@ -196,6 +196,7 @@ int sysdb_upgrade_20(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_21(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_22(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_23(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_24(struct sysdb_ctx *sysdb, const char **ver);

int sysdb_ts_upgrade_01(struct sysdb_ctx *sysdb, const char **ver);

Expand Down
27 changes: 27 additions & 0 deletions src/db/sysdb_upgrade.c
Original file line number Diff line number Diff line change
Expand Up @@ -2820,6 +2820,33 @@ int sysdb_upgrade_23(struct sysdb_ctx *sysdb, const char **ver)
return ret;
}

int sysdb_upgrade_24(struct sysdb_ctx *sysdb, const char **ver)
{
struct upgrade_ctx *ctx;
errno_t ret;

ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_25, &ctx);
if (ret) {
return ret;
}

ret = sysdb_ldb_mod_index(sysdb, SYSDB_IDX_DELETE, sysdb->ldb, "dataExpireTimestamp");
if (ret == ENOENT) { /*nothing to delete */
ret = EOK;
}
if (ret != EOK) {
DEBUG(SSSDBG_TRACE_FUNC, "sysdb_ldb_mod_index() failed [%d]: %s\n",
ret, sss_strerror(ret));
goto done;
}

ret = update_version(ctx);

done:
ret = finish_upgrade(ret, &ctx, ver);
return ret;
}

/*
* Example template for future upgrades.
* Copy and change version numbers as appropriate.
Expand Down

0 comments on commit f0d4546

Please sign in to comment.