From 61b66b8d0a2a29496ad96774011e158e5f089bf0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 11 Sep 2017 13:16:31 +1200 Subject: 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 Reviewed-by: Garming Sam --- lib/ldb/ldb_tdb/ldb_index.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib/ldb') diff --git a/lib/ldb/ldb_tdb/ldb_index.c b/lib/ldb/ldb_tdb/ldb_index.c index fb31ba509e0..621d819ae8e 100644 --- a/lib/ldb/ldb_tdb/ldb_index.c +++ b/lib/ldb/ldb_tdb/ldb_index.c @@ -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; } -- cgit v1.2.1