From: Tim Beale Date: Sun, 11 Nov 2018 22:00:52 +0000 (+1300) Subject: replmd: Only modify the object if it actually changed X-Git-Tag: tdb-1.3.17~709 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c371fef58638a7570becf29dd0df651004219d0a;p=thirdparty%2Fsamba.git replmd: Only modify the object if it actually changed Commit 775054afbe1512 reworked replmd_process_link_attribute() so that we batch together DB operations for the same source object. However, it was possible that the object had not actually changed at all, e.g. - link was already processed by critical-objects-only during join, or - we were doing a full-sync and processing info that was already up-to-date in our DB. In these cases we modified the object anyway, even though nothing had changed. This patch fixes it up, so we check that the object has actually changed before modifying the DB. Signed-off-by: Tim Beale Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index cd6e1cc0fd3..b97c9db355f 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -8228,6 +8228,7 @@ static int replmd_process_la_group(struct ldb_module *module, struct ldb_context *ldb = ldb_module_get_ctx(module); const struct dsdb_attribute *attr = NULL; replmd_link_changed change_type; + uint32_t num_changes = 0; /* * get the attribute being modified and the search result for the @@ -8287,6 +8288,10 @@ static int replmd_process_la_group(struct ldb_module *module, return ret; } + if (change_type != LINK_CHANGE_NONE) { + num_changes++; + } + if ((++replmd_private->num_processed % 8192) == 0) { DBG_NOTICE("Processed %u/%u linked attributes\n", replmd_private->num_processed, @@ -8294,6 +8299,15 @@ static int replmd_process_la_group(struct ldb_module *module, } } + /* + * it's possible we're already up-to-date and so don't need to modify + * the object at all (e.g. doing a 'drs replicate --full-sync') + */ + if (num_changes == 0) { + TALLOC_FREE(tmp_ctx); + return LDB_SUCCESS; + } + /* apply the link changes to the source object */ ret = linked_attr_modify(module, msg, NULL); if (ret != LDB_SUCCESS) {