1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-01 04:58:35 +03:00

ldb_tdb: Print progress messages on re-index

A re-index of 10,000 entries is slow enough and rare enought that we can
justify the message being at LDB_DEBUG_WARNING as otherwise the administrator
will be sure the "lockup" was one.

The default for ldb is to print LDB_DEBUG_WARNING in comand-line tools
and the default for Samba is to log it at level 2.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2017-09-11 13:16:31 +12:00
parent c71ddab974
commit 61b66b8d0a

View File

@ -2264,6 +2264,7 @@ static int delete_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, vo
struct ltdb_reindex_context {
struct ldb_module *module;
int error;
uint32_t count;
};
/*
@ -2368,6 +2369,13 @@ static int re_key(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *st
talloc_free(msg);
ctx->count++;
if (ctx->count % 10000 == 0) {
ldb_debug(ldb, LDB_DEBUG_WARNING,
"Reindexing: re-keyed %u records so far",
ctx->count);
}
return 0;
}
@ -2449,6 +2457,13 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
talloc_free(msg);
ctx->count++;
if (ctx->count % 10000 == 0) {
ldb_debug(ldb, LDB_DEBUG_WARNING,
"Reindexing: re-indexed %u records so far",
ctx->count);
}
return 0;
}
@ -2498,6 +2513,7 @@ int ltdb_reindex(struct ldb_module *module)
ctx.module = module;
ctx.error = 0;
ctx.count = 0;
/* now traverse adding any indexes for normal LDB records */
ret = tdb_traverse(ltdb->tdb, re_key, &ctx);
@ -2515,6 +2531,7 @@ int ltdb_reindex(struct ldb_module *module)
}
ctx.error = 0;
ctx.count = 0;
/* now traverse adding any indexes for normal LDB records */
ret = tdb_traverse(ltdb->tdb, re_index, &ctx);
@ -2531,5 +2548,11 @@ int ltdb_reindex(struct ldb_module *module)
return ctx.error;
}
if (ctx.count > 10000) {
ldb_debug(ldb_module_get_ctx(module),
LDB_DEBUG_WARNING, "Reindexing: re_index successful on %s, "
"final index write-out will be in transaction commit",
tdb_name(ltdb->tdb));
}
return LDB_SUCCESS;
}