From 1b20ceedbbce85a8c9e4ddbea4f07aeb453aba86 Mon Sep 17 00:00:00 2001 From: Ludwig Krispenz Date: Thu, 26 Oct 2017 15:18:39 +0200 Subject: [PATCH] ticket 48118 - part 1 - ensure ruv is written --- ldap/servers/plugins/replication/repl5_replica.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c index 92f847f..5fc13f7 100644 --- a/ldap/servers/plugins/replication/repl5_replica.c +++ b/ldap/servers/plugins/replication/repl5_replica.c @@ -2744,6 +2744,11 @@ replica_write_ruv(Replica *r) ruv_to_smod((RUV *)object_get_data(r->repl_ruv), &smod); ruv_last_modified_to_smod((RUV *)object_get_data(r->repl_ruv), &smod_last_modified); + /* we will unlock the replica, if we reset the dirty flag later we might miss any + * updates which set it dirty in between. + * So reset now, if writing the ruv fails set it to dirty again + */ + r->repl_ruv_dirty = PR_FALSE; replica_unlock(r->repl_lock); mods[0] = (LDAPMod *)slapi_mod_get_ldapmod_byref(&smod); @@ -2773,20 +2778,19 @@ replica_write_ruv(Replica *r) /* ruv does not exist - create one */ replica_lock(r->repl_lock); - if (rc == LDAP_SUCCESS) { - r->repl_ruv_dirty = PR_FALSE; - } else if (rc == LDAP_NO_SUCH_OBJECT) { + if (rc == LDAP_NO_SUCH_OBJECT) { /* this includes an internal operation - but since this only happens during server startup - its ok that we have lock around it */ rc = _replica_configure_ruv(r, PR_TRUE); if (rc == 0) r->repl_ruv_dirty = PR_FALSE; - } else /* error */ - { + } else if (rc != LDAP_SUCCESS) { slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "replica_write_ruv - Failed to update RUV tombstone for %s; " "LDAP error - %d\n", slapi_sdn_get_dn(r->repl_root), rc); + /* the ruv was dirty, but writing failed, so set it dirty again */ + r->repl_ruv_dirty = PR_TRUE; } replica_unlock(r->repl_lock); -- 2.5.5