From d98444de850e5ad3424ffd6a0256eda0ba16e3bf Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Wed, 4 Mar 2015 13:05:02 -0800 Subject: [PATCH] Ticket #47957 - Make ReplicaWaitForAsyncResults configurable Description: Introducing a config attr nsDS5ReplicaWaitForAsyncResults to the agreement entry. dn: cn=,cn=replica,cn="",cn=mapping tree,cn=config nsDS5ReplicaWaitForAsyncResults: Prior to this patch, supplier sleeps 1 second if it finds the response from consumer is not ready. 1 second could be too long if higher replication throughput is required. This patch makes the waiting time configurable, and change the default to 100 millisecond. If the attribute nsDS5ReplicaWaitForAsyncResults does not exist or the value is 0, the default value is set. --- ldap/schema/01core389.ldif | 3 ++- ldap/servers/plugins/replication/repl5.h | 7 ++++++ ldap/servers/plugins/replication/repl5_agmt.c | 26 +++++++++++++++++++++- ldap/servers/plugins/replication/repl5_agmtlist.c | 11 ++++++++- .../plugins/replication/repl5_inc_protocol.c | 15 +++++++------ ldap/servers/plugins/replication/repl_globals.c | 1 + 6 files changed, 53 insertions(+), 10 deletions(-) diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif index 9b7ec1d..ffd8710 100644 --- a/ldap/schema/01core389.ldif +++ b/ldap/schema/01core389.ldif @@ -306,6 +306,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2310 NAME 'nsds5ReplicaFlowControlWindow attributeTypes: ( 2.16.840.1.113730.3.1.2311 NAME 'nsds5ReplicaFlowControlPause' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.2313 NAME 'nsslapd-changelogtrim-interval' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.2314 NAME 'nsslapd-changelogcompactdb-interval' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) +attributeTypes: ( 2.16.840.1.113730.3.1.2315 NAME 'nsDS5ReplicaWaitForAsyncResults' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' ) # # objectclasses # @@ -317,7 +318,7 @@ objectClasses: ( 2.16.840.1.113730.3.2.110 NAME 'nsMappingTree' DESC 'Netscape d objectClasses: ( 2.16.840.1.113730.3.2.104 NAME 'nsContainer' DESC 'Netscape defined objectclass' SUP top MUST ( CN ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.108 NAME 'nsDS5Replica' DESC 'Netscape defined objectclass' SUP top MUST ( nsDS5ReplicaRoot $ nsDS5ReplicaId ) MAY (cn $ nsds5ReplicaPreciseTombstonePurging $ nsds5ReplicaCleanRUV $ nsds5ReplicaAbortCleanRUV $ nsDS5ReplicaType $ nsDS5ReplicaBindDN $ nsState $ nsDS5ReplicaName $ nsDS5Flags $ nsDS5Task $ nsDS5ReplicaReferral $ nsDS5ReplicaAutoReferral $ nsds5ReplicaPurgeDelay $ nsds5ReplicaTombstonePurgeInterval $ nsds5ReplicaChangeCount $ nsds5ReplicaLegacyConsumer $ nsds5ReplicaProtocolTimeout $ nsds5ReplicaBackoffMin $ nsds5ReplicaBackoffMax ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.113 NAME 'nsTombstone' DESC 'Netscape defined objectclass' SUP top MAY ( nstombstonecsn $ nsParentUniqueId $ nscpEntryDN ) X-ORIGIN 'Netscape Directory Server' ) -objectClasses: ( 2.16.840.1.113730.3.2.103 NAME 'nsDS5ReplicationAgreement' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( nsds5ReplicaCleanRUVNotified $ nsDS5ReplicaHost $ nsDS5ReplicaPort $ nsDS5ReplicaTransportInfo $ nsDS5ReplicaBindDN $ nsDS5ReplicaCredentials $ nsDS5ReplicaBindMethod $ nsDS5ReplicaRoot $ nsDS5ReplicatedAttributeList $ nsDS5ReplicatedAttributeListTotal $ nsDS5ReplicaUpdateSchedule $ nsds5BeginReplicaRefresh $ description $ nsds50ruv $ nsruvReplicaLastModified $ nsds5ReplicaTimeout $ nsds5replicaChangesSentSinceStartup $ nsds5replicaLastUpdateEnd $ nsds5replicaLastUpdateStart $ nsds5replicaLastUpdateStatus $ nsds5replicaUpdateInProgress $ nsds5replicaLastInitEnd $ nsds5ReplicaEnabled $ nsds5replicaLastInitStart $ nsds5replicaLastInitStatus $ nsds5debugreplicatimeout $ nsds5replicaBusyWaitTime $ nsds5ReplicaStripAttrs $ nsds5replicaSessionPauseTime $ nsds5ReplicaProtocolTimeout $ nsds5ReplicaFlowControlWindow $ nsds5ReplicaFlowControlPause ) X-ORIGIN 'Netscape Directory Server' ) +objectClasses: ( 2.16.840.1.113730.3.2.103 NAME 'nsDS5ReplicationAgreement' DESC 'Netscape defined objectclass' SUP top MUST ( cn ) MAY ( nsds5ReplicaCleanRUVNotified $ nsDS5ReplicaHost $ nsDS5ReplicaPort $ nsDS5ReplicaTransportInfo $ nsDS5ReplicaBindDN $ nsDS5ReplicaCredentials $ nsDS5ReplicaBindMethod $ nsDS5ReplicaRoot $ nsDS5ReplicatedAttributeList $ nsDS5ReplicatedAttributeListTotal $ nsDS5ReplicaUpdateSchedule $ nsds5BeginReplicaRefresh $ description $ nsds50ruv $ nsruvReplicaLastModified $ nsds5ReplicaTimeout $ nsds5replicaChangesSentSinceStartup $ nsds5replicaLastUpdateEnd $ nsds5replicaLastUpdateStart $ nsds5replicaLastUpdateStatus $ nsds5replicaUpdateInProgress $ nsds5replicaLastInitEnd $ nsds5ReplicaEnabled $ nsds5replicaLastInitStart $ nsds5replicaLastInitStatus $ nsds5debugreplicatimeout $ nsds5replicaBusyWaitTime $ nsds5ReplicaStripAttrs $ nsds5replicaSessionPauseTime $ nsds5ReplicaProtocolTimeout $ nsds5ReplicaFlowControlWindow $ nsds5ReplicaFlowControlPause $ nsDS5ReplicaWaitForAsyncResults ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.39 NAME 'nsslapdConfig' DESC 'Netscape defined objectclass' SUP top MAY ( cn ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.317 NAME 'nsSaslMapping' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSaslMapRegexString $ nsSaslMapBaseDNTemplate $ nsSaslMapFilterTemplate ) MAY ( nsSaslMapPriority ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.43 NAME 'nsSNMP' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSNMPEnabled ) MAY ( nsSNMPOrganization $ nsSNMPLocation $ nsSNMPContact $ nsSNMPDescription $ nsSNMPName $ nsSNMPMasterHost $ nsSNMPMasterPort ) X-ORIGIN 'Netscape Directory Server' ) diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h index 39d25bb..a7da266 100644 --- a/ldap/servers/plugins/replication/repl5.h +++ b/ldap/servers/plugins/replication/repl5.h @@ -194,6 +194,9 @@ extern const char *type_winSyncSubtreePair; /* To Allow Consumer Initialisation when adding an agreement - */ extern const char *type_nsds5BeginReplicaRefresh; +/* For tuning replica release */ +extern const char *type_nsds5WaitForAsyncResults; + /* replica related attributes */ extern const char *attr_replicaId; extern const char *attr_replicaRoot; @@ -412,6 +415,7 @@ void add_agmt_maxcsns(Slapi_Entry *e, Replica *r); void agmt_set_maxcsn(Repl_Agmt *ra); void agmt_remove_maxcsn(Repl_Agmt *ra); int agmt_maxcsn_to_smod (Replica *r, Slapi_Mod *smod); +int agmt_set_WaitForAsyncResults(Repl_Agmt *ra, const Slapi_Entry *e); /* In repl5_agmtlist.c */ int agmtlist_config_init(); @@ -748,6 +752,9 @@ void repl5_set_debug_timeout(const char *val); /* temp hack XXX */ ReplicaId agmt_get_consumerRID(Repl_Agmt *ra); +/* For replica release tuning */ +int agmt_get_WaitForAsyncResults(Repl_Agmt *ra); + PRBool ldif_dump_is_running(); void windows_init_agreement_from_entry(Repl_Agmt *ra, Slapi_Entry *e); diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c index d27648e..2ccb7ba 100644 --- a/ldap/servers/plugins/replication/repl5_agmt.c +++ b/ldap/servers/plugins/replication/repl5_agmt.c @@ -154,6 +154,8 @@ typedef struct repl5agmt { * This is the duration (in msec) that the RA will pause before sending the next entry */ Slapi_RWLock *attr_lock; /* RW lock for all the stripped attrs */ + int WaitForAsyncResults; /* Pass to DS_Sleep(PR_MillisecondsToInterval(WaitForAsyncResults)) + * in repl5_inc_waitfor_async_results */ } repl5agmt; /* Forward declarations */ @@ -315,7 +317,8 @@ agmt_new_from_entry(Slapi_Entry *e) ra->port = slapi_entry_attr_get_int(e, type_nsds5ReplicaPort); /* SSL, TLS, or other transport stuff */ ra->transport_flags = 0; - agmt_set_transportinfo_no_lock(ra, e); + (void) agmt_set_transportinfo_no_lock(ra, e); + (void) agmt_set_WaitForAsyncResults(ra, e); /* DN to use when binding. May be empty if certain SASL auth is to be used e.g. EXTERNAL GSSAPI. */ ra->binddn = slapi_entry_attr_get_charptr(e, type_nsds5ReplicaBindDN); @@ -1727,6 +1730,27 @@ agmt_set_transportinfo_no_lock(Repl_Agmt *ra, const Slapi_Entry *e) return (rc); } +int +agmt_set_WaitForAsyncResults(Repl_Agmt *ra, const Slapi_Entry *e) +{ + int wait = 0; + if (e) { + wait = slapi_entry_attr_get_int(e, type_nsds5WaitForAsyncResults); + } + if (wait <= 0) { + ra->WaitForAsyncResults = 100; /* 0.1 sec */ + } else { + ra->WaitForAsyncResults = wait; + } + return 0; +} + +int +agmt_get_WaitForAsyncResults(Repl_Agmt *ra) +{ + return ra->WaitForAsyncResults; +} + int agmt_set_transportinfo_from_entry(Repl_Agmt *ra, const Slapi_Entry *e) { diff --git a/ldap/servers/plugins/replication/repl5_agmtlist.c b/ldap/servers/plugins/replication/repl5_agmtlist.c index e414e0b..5b419c6 100644 --- a/ldap/servers/plugins/replication/repl5_agmtlist.c +++ b/ldap/servers/plugins/replication/repl5_agmtlist.c @@ -548,7 +548,8 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry rc = SLAPI_DSE_CALLBACK_ERROR; } } - else if (slapi_attr_types_equivalent(mods[i]->mod_type, type_replicaProtocolTimeout)){ + else if (slapi_attr_types_equivalent(mods[i]->mod_type, type_replicaProtocolTimeout)) + { if (mods[i]->mod_op & LDAP_MOD_DELETE) { agmt_set_protocol_timeout(agmt, 0); @@ -574,6 +575,14 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry agmt_set_protocol_timeout(agmt, ptimeout); } } + else if (slapi_attr_types_equivalent(mods[i]->mod_type, type_nsds5WaitForAsyncResults)) + { + if (mods[i]->mod_op & LDAP_MOD_DELETE) { + (void) agmt_set_WaitForAsyncResults(agmt, NULL); + } else { + (void) agmt_set_WaitForAsyncResults(agmt, e); + } + } else if (0 == windows_handle_modify_agreement(agmt, mods[i]->mod_type, e)) { slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: " diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c index f18fde5..bd4edeb 100644 --- a/ldap/servers/plugins/replication/repl5_inc_protocol.c +++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c @@ -110,6 +110,7 @@ typedef struct result_data int last_message_id_received; int flowcontrol_detection; int result; /* The UPDATE_TRANSIENT_ERROR etc */ + int WaitForAsyncResults; } result_data; /* Various states the incremental protocol can pass through */ @@ -492,18 +493,17 @@ repl5_inc_waitfor_async_results(result_data *rd) slapi_log_error(SLAPI_LOG_REPL, NULL, "repl5_inc_waitfor_async_results: %d %d\n", rd->last_message_id_received, rd->last_message_id_sent); - if (rd->last_message_id_received >= rd->last_message_id_sent) - { + if (rd->last_message_id_received >= rd->last_message_id_sent) { /* If so then we're done */ done = 1; - } - if (rd->abort && (rd->result == UPDATE_CONNECTION_LOST)) - { + } else if (rd->abort && (rd->result == UPDATE_CONNECTION_LOST)) { done = 1; /* no connection == no more results */ } PR_Unlock(rd->lock); - /* If not then sleep a bit */ - DS_Sleep(PR_SecondsToInterval(1)); + if (!done) { + /* If not then sleep a bit */ + DS_Sleep(PR_MillisecondsToInterval(rd->WaitForAsyncResults)); + } loops++; /* If we sleep forever then we can conclude that something bad happened, and bail... */ /* Arbitrary 30 second delay : basically we should only expect to wait as long as it takes to process a few operations, which should be on the order of a second at most */ @@ -1912,6 +1912,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu { /* We need to ensure that we wait until all the responses have been received from our operations */ if (return_value != UPDATE_CONNECTION_LOST) { + rd->WaitForAsyncResults = agmt_get_WaitForAsyncResults(prp->agmt); /* if connection was lost/closed, there will be nothing to read */ repl5_inc_waitfor_async_results(rd); } diff --git a/ldap/servers/plugins/replication/repl_globals.c b/ldap/servers/plugins/replication/repl_globals.c index e2157fa..7f4fcd2 100644 --- a/ldap/servers/plugins/replication/repl_globals.c +++ b/ldap/servers/plugins/replication/repl_globals.c @@ -141,6 +141,7 @@ const char *type_nsds5ReplicaEnabled = "nsds5ReplicaEnabled"; const char *type_nsds5ReplicaStripAttrs = "nsds5ReplicaStripAttrs"; const char* type_nsds5ReplicaFlowControlWindow = "nsds5ReplicaFlowControlWindow"; const char* type_nsds5ReplicaFlowControlPause = "nsds5ReplicaFlowControlPause"; +const char *type_nsds5WaitForAsyncResults = "nsds5ReplicaWaitForAsyncResults"; /* windows sync specific attributes */ const char *type_nsds7WindowsReplicaArea = "nsds7WindowsReplicaSubtree"; -- 1.9.3