From 09d3d9bd831df4af8e2715eb3df3bb3bbf886d85 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Tue, 3 Jul 2012 17:44:00 -0700 Subject: [PATCH] Trac Ticket #398 - Add a way to monitor status in LDAP while CLEANRUV is executing https://fedorahosted.org/389/ticket/398 Fix Description: Set REPLICA_IN_CLEANRUV bit in the replica status flag while CLEAN{RUV}ALL task/extop is being executed. If the replica is searched and returned when the bit is on, it includes "nsds5replicaExtopStatus: replica in cleanruv". Otherwise, the attribute value is not included in the entry. --- ldap/servers/plugins/replication/repl5.h | 2 + .../plugins/replication/repl5_inc_protocol.c | 2 +- .../plugins/replication/repl5_replica_config.c | 31 ++++++++++++++------ ldap/servers/plugins/replication/repl_extop.c | 7 ++++- ldap/servers/plugins/replication/repl_globals.c | 1 + .../plugins/replication/windows_inc_protocol.c | 2 +- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h index b04d9c4..72832e7 100644 --- a/ldap/servers/plugins/replication/repl5.h +++ b/ldap/servers/plugins/replication/repl5.h @@ -186,6 +186,7 @@ extern const char *type_replicaChangeCount; extern const char *type_replicaTombstonePurgeInterval; extern const char *type_replicaLegacyConsumer; extern const char *type_ruvElementUpdatetime; +extern const char *type_replicaExtopStatus; /* multimaster plugin points */ int multimaster_preop_bind (Slapi_PBlock *pb); @@ -569,6 +570,7 @@ void replica_write_ruv (Replica *r); is active, RECV should back off. And vice versa. But SEND can coexist. */ #define REPLICA_TOTAL_EXCL_RECV 32 /* ditto */ +#define REPLICA_IN_CLEANRUV 64 /* Set while replica is in CLEAN{ALL}RUV */ PRBool replica_is_state_flag_set(Replica *r, PRInt32 flag); void replica_set_state_flag (Replica *r, PRUint32 flag, PRBool clear); diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c index 7388d62..25228b1 100644 --- a/ldap/servers/plugins/replication/repl5_inc_protocol.c +++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c @@ -1543,7 +1543,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu { CL5Entry entry; slapi_operation_parameters op; - int return_value; + int return_value = 0; int rc; CL5ReplayIterator *changelog_iterator; int message_id = 0; diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c index 771af61..de78270 100644 --- a/ldap/servers/plugins/replication/repl5_replica_config.c +++ b/ldap/servers/plugins/replication/repl5_replica_config.c @@ -654,14 +654,14 @@ static int replica_config_search (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg) { - multimaster_mtnode_extension *mtnode_ext; - int changeCount = 0; + multimaster_mtnode_extension *mtnode_ext; + int changeCount = 0; PRBool reapActive = PR_FALSE; - char val [64]; + char val [64]; /* add attribute that contains number of entries in the changelog for this replica */ - PR_Lock (s_configLock); + PR_Lock (s_configLock); mtnode_ext = _replica_config_get_mtnode_ext (e); PR_ASSERT (mtnode_ext); @@ -675,17 +675,27 @@ replica_config_search (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter replica = (Replica*)object_get_data (mtnode_ext->replica); if (replica) { reapActive = replica_get_tombstone_reap_active(replica); + if (replica_is_state_flag_set(replica, REPLICA_IN_CLEANRUV)) { + slapi_entry_add_string(e, + type_replicaExtopStatus, + "replica in cleanruv"); + } else { + slapi_entry_delete_string(e, + type_replicaExtopStatus, + "replica in cleanruv"); + } + slapi_entry_add_string (e, type_replicaChangeCount, val); } object_release (mtnode_ext->replica); } - sprintf (val, "%d", changeCount); - slapi_entry_add_string (e, type_replicaChangeCount, val); + sprintf (val, "%d", changeCount); + slapi_entry_add_string (e, type_replicaChangeCount, val); slapi_entry_attr_set_int(e, "nsds5replicaReapActive", (int)reapActive); - PR_Unlock (s_configLock); + PR_Unlock (s_configLock); - return SLAPI_DSE_CALLBACK_OK; + return SLAPI_DSE_CALLBACK_OK; } static int @@ -1210,8 +1220,9 @@ replica_execute_cleanall_ruv_task (Object *r, ReplicaId rid, char *returntext) return -1; } - set_cleaned_rid(rid); + /* Set REPLICA_IN_CLEANRUV bit in the replica status */ + replica_set_state_flag (replica, REPLICA_IN_CLEANRUV, 0); agmt_obj = agmtlist_get_first_agreement_for_replica (replica); while (agmt_obj) @@ -1472,6 +1483,8 @@ replica_cleanallruv_monitor_thread(void *arg) } done: + /* Clean up REPLICA_IN_CLEANRUV bit in the replica status */ + replica_set_state_flag (replica, REPLICA_IN_CLEANRUV, 1); slapi_ch_free((void **)&rid_text); slapi_ch_free((void **)&data); } diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c index f6378d2..e6effa8 100644 --- a/ldap/servers/plugins/replication/repl_extop.c +++ b/ldap/servers/plugins/replication/repl_extop.c @@ -1386,7 +1386,8 @@ free_and_return: * cleanruv_task on this replica. */ int -multimaster_extop_cleanruv(Slapi_PBlock *pb){ +multimaster_extop_cleanruv(Slapi_PBlock *pb) +{ multimaster_mtnode_extension *mtnode_ext; PRThread *thread = NULL; Repl_Connection *conn; @@ -1452,6 +1453,8 @@ multimaster_extop_cleanruv(Slapi_PBlock *pb){ goto free_and_return; } r = (Replica*)object_get_data (mtnode_ext->replica); + /* Set REPLICA_IN_CLEANRUV bit in the replica status */ + replica_set_state_flag (r, REPLICA_IN_CLEANRUV, 0); /* * Send out extended ops to each repl agreement */ @@ -1536,6 +1539,8 @@ free_and_return: slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "cleanALLRUV_extop: failed to clean rid (%d), error (%d)\n",rid, rc); } + /* Clean up REPLICA_IN_CLEANRUV bit in the replica status */ + replica_set_state_flag (r, REPLICA_IN_CLEANRUV, 1); if (mtnode_ext->replica) object_release (mtnode_ext->replica); diff --git a/ldap/servers/plugins/replication/repl_globals.c b/ldap/servers/plugins/replication/repl_globals.c index 9445394..9b7919b 100644 --- a/ldap/servers/plugins/replication/repl_globals.c +++ b/ldap/servers/plugins/replication/repl_globals.c @@ -110,6 +110,7 @@ const char *type_replicaChangeCount = "nsds5ReplicaChangeCount"; const char *type_replicaTombstonePurgeInterval = "nsds5ReplicaTombstonePurgeInterval"; const char *type_replicaLegacyConsumer = "nsds5ReplicaLegacyConsumer"; const char *type_ruvElementUpdatetime = "nsruvReplicaLastModified"; +const char *type_replicaExtopStatus = "nsds5ReplicaExtopStatus"; /* Attribute names for replication agreement attributes */ const char *type_nsds5ReplicaHost = "nsds5ReplicaHost"; diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c index 3bba77d..b76c43f 100644 --- a/ldap/servers/plugins/replication/windows_inc_protocol.c +++ b/ldap/servers/plugins/replication/windows_inc_protocol.c @@ -1168,7 +1168,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu { CL5Entry entry; slapi_operation_parameters op; - int return_value; + int return_value = 0; int rc; int set_mincsn = 0; CL5ReplayIterator *changelog_iterator = NULL; -- 1.7.6.5