andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0006-Issue-3903-Supplier-should-do-periodic-updates.patch

0a5078
From e65d6225398901c3319e72a460bc58e5d50df67c Mon Sep 17 00:00:00 2001
0a5078
From: Mark Reynolds <mreynolds@redhat.com>
0a5078
Date: Wed, 3 Aug 2022 16:27:15 -0400
0a5078
Subject: [PATCH 2/5] Issue 3903 - Supplier should do periodic updates
0a5078
0a5078
Description:
0a5078
0a5078
On suppliers update the keep alive entry periodically to keep the RUV up
0a5078
to date in case a replica is neglected for along time.  This prevents
0a5078
very long changelog scans when finally processing updates.
0a5078
0a5078
relates: https://github.com/389ds/389-ds-base/issues/3903
0a5078
0a5078
Reviewed by: firstyear & tbordaz(Thanks!)
0a5078
---
0a5078
 .../suites/replication/regression_m2_test.py  |  96 +++++--------
0a5078
 .../suites/replication/replica_config_test.py |   6 +-
0a5078
 ldap/schema/01core389.ldif                    |   3 +-
0a5078
 ldap/servers/plugins/replication/repl5.h      |  11 +-
0a5078
 .../plugins/replication/repl5_inc_protocol.c  |  44 +-----
0a5078
 .../plugins/replication/repl5_replica.c       | 127 +++++++++++++-----
0a5078
 .../replication/repl5_replica_config.c        |  12 ++
0a5078
 .../plugins/replication/repl5_tot_protocol.c  |   4 +-
0a5078
 ldap/servers/plugins/replication/repl_extop.c |   2 +-
0a5078
 .../plugins/replication/repl_globals.c        |   1 +
0a5078
 .../src/lib/replication/replConfig.jsx        |  32 ++++-
0a5078
 src/cockpit/389-console/src/replication.jsx   |   6 +
0a5078
 src/lib389/lib389/cli_conf/replication.py     |   6 +-
0a5078
 13 files changed, 202 insertions(+), 148 deletions(-)
0a5078
0a5078
diff --git a/dirsrvtests/tests/suites/replication/regression_m2_test.py b/dirsrvtests/tests/suites/replication/regression_m2_test.py
0a5078
index 466e3c2c0..7dd0f2984 100644
0a5078
--- a/dirsrvtests/tests/suites/replication/regression_m2_test.py
0a5078
+++ b/dirsrvtests/tests/suites/replication/regression_m2_test.py
0a5078
@@ -14,6 +14,7 @@ import ldif
0a5078
 import ldap
0a5078
 import pytest
0a5078
 import subprocess
0a5078
+import time
0a5078
 from lib389.idm.user import TEST_USER_PROPERTIES, UserAccounts
0a5078
 from lib389.pwpolicy import PwPolicyManager
0a5078
 from lib389.utils import *
0a5078
@@ -204,12 +205,12 @@ def rename_entry(server, idx, ou_name, new_parent):
0a5078
 def add_ldapsubentry(server, parent):
0a5078
     pwp = PwPolicyManager(server)
0a5078
     policy_props = {'passwordStorageScheme': 'ssha',
0a5078
-                                'passwordCheckSyntax': 'on',
0a5078
-                                'passwordInHistory': '6',
0a5078
-                                'passwordChange': 'on',
0a5078
-                                'passwordMinAge': '0',
0a5078
-                                'passwordExp': 'off',
0a5078
-                                'passwordMustChange': 'off',}
0a5078
+                    'passwordCheckSyntax': 'on',
0a5078
+                    'passwordInHistory': '6',
0a5078
+                    'passwordChange': 'on',
0a5078
+                    'passwordMinAge': '0',
0a5078
+                    'passwordExp': 'off',
0a5078
+                    'passwordMustChange': 'off',}
0a5078
     log.info('Create password policy for subtree {}'.format(parent))
0a5078
     pwp.create_subtree_policy(parent, policy_props)
0a5078
 
0a5078
@@ -742,7 +743,7 @@ def get_keepalive_entries(instance, replica):
0a5078
     try:
0a5078
         entries = instance.search_s(replica.get_suffix(), ldap.SCOPE_ONELEVEL,
0a5078
                                     "(&(objectclass=ldapsubentry)(cn=repl keep alive*))",
0a5078
-                                    ['cn', 'nsUniqueId', 'modifierTimestamp'])
0a5078
+                                    ['cn', 'keepalivetimestamp', 'nsUniqueId', 'modifierTimestamp'])
0a5078
     except ldap.LDAPError as e:
0a5078
         log.fatal('Failed to retrieve keepalive entry (%s) on instance %s: error %s' % (dn, instance, str(e)))
0a5078
         assert False
0a5078
@@ -761,6 +762,7 @@ def verify_keepalive_entries(topo, expected):
0a5078
     # (for example after: db2ldif / demote a supplier / ldif2db / init other suppliers)
0a5078
     # ==> if the function is somehow pushed in lib389, a check better than simply counting the entries
0a5078
     # should be done.
0a5078
+    entries = []
0a5078
     for supplierId in topo.ms:
0a5078
         supplier = topo.ms[supplierId]
0a5078
         for replica in Replicas(supplier).list():
0a5078
@@ -771,6 +773,7 @@ def verify_keepalive_entries(topo, expected):
0a5078
             keepaliveEntries = get_keepalive_entries(supplier, replica);
0a5078
             expectedCount = len(topo.ms) if expected else 0
0a5078
             foundCount = len(keepaliveEntries)
0a5078
+            entries += keepaliveEntries
0a5078
             if (foundCount == expectedCount):
0a5078
                 log.debug(f'Found {foundCount} keepalive entries as expected on {replica_info}.')
0a5078
             else:
0a5078
@@ -778,70 +781,45 @@ def verify_keepalive_entries(topo, expected):
0a5078
                           f'while {expectedCount} were expected on {replica_info}.')
0a5078
                 assert False
0a5078
 
0a5078
+    return entries
0a5078
+
0a5078
 
0a5078
-def test_online_init_should_create_keepalive_entries(topo_m2):
0a5078
-    """Check that keep alive entries are created when initializinf a supplier from another one
0a5078
+def test_keepalive_entries(topo_m2):
0a5078
+    """Check that keep alive entries are created
0a5078
 
0a5078
     :id: d5940e71-d18a-4b71-aaf7-b9185361fffe
0a5078
     :setup: Two suppliers replication setup
0a5078
     :steps:
0a5078
-        1. Generate ldif without replication data
0a5078
-        2  Init both suppliers from that ldif
0a5078
-        3  Check that keep alive entries does not exists
0a5078
-        4  Perform on line init of supplier2 from supplier1
0a5078
-        5  Check that keep alive entries exists
0a5078
+        1. Keep alives entries are present
0a5078
+        2. Keep alive entries are updated every 60 seconds
0a5078
     :expectedresults:
0a5078
-        1. No error while generating ldif
0a5078
-        2. No error while importing the ldif file
0a5078
-        3. No keepalive entrie should exists on any suppliers
0a5078
-        4. No error while initializing supplier2
0a5078
-        5. All keepalive entries should exist on every suppliers
0a5078
+        1. Success
0a5078
+        2. Success
0a5078
 
0a5078
     """
0a5078
 
0a5078
-    repl = ReplicationManager(DEFAULT_SUFFIX)
0a5078
-    m1 = topo_m2.ms["supplier1"]
0a5078
-    m2 = topo_m2.ms["supplier2"]
0a5078
-    # Step 1: Generate ldif without replication data
0a5078
-    m1.stop()
0a5078
-    m2.stop()
0a5078
-    ldif_file = '%s/norepl.ldif' % m1.get_ldif_dir()
0a5078
-    m1.db2ldif(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX],
0a5078
-               excludeSuffixes=None, repl_data=False,
0a5078
-               outputfile=ldif_file, encrypt=False)
0a5078
-    # Remove replication metadata that are still in the ldif
0a5078
-    _remove_replication_data(ldif_file)
0a5078
-
0a5078
-    # Step 2: Init both suppliers from that ldif
0a5078
-    m1.ldif2db(DEFAULT_BENAME, None, None, None, ldif_file)
0a5078
-    m2.ldif2db(DEFAULT_BENAME, None, None, None, ldif_file)
0a5078
-    m1.start()
0a5078
-    m2.start()
0a5078
-
0a5078
-    """ Replica state is now as if CLI setup has been done using:
0a5078
-        dsconf supplier1 replication enable --suffix "${SUFFIX}" --role supplier
0a5078
-        dsconf supplier2 replication enable --suffix "${SUFFIX}" --role supplier
0a5078
-        dsconf supplier1 replication create-manager --name "${REPLICATION_MANAGER_NAME}" --passwd "${REPLICATION_MANAGER_PASSWORD}"
0a5078
-        dsconf supplier2 replication create-manager --name "${REPLICATION_MANAGER_NAME}" --passwd "${REPLICATION_MANAGER_PASSWORD}"
0a5078
-        dsconf supplier1 repl-agmt create --suffix "${SUFFIX}"
0a5078
-        dsconf supplier2 repl-agmt create --suffix "${SUFFIX}"
0a5078
-    """
0a5078
+    # default interval is 1 hour, too long for test, set it to the minimum of
0a5078
+    # 60 seconds
0a5078
+    for supplierId in topo_m2.ms:
0a5078
+        supplier = topo_m2.ms[supplierId]
0a5078
+        replica = Replicas(supplier).get(DEFAULT_SUFFIX)
0a5078
+        replica.replace('nsds5ReplicaKeepAliveUpdateInterval', '60')
0a5078
+        supplier.restart()
0a5078
 
0a5078
-    # Step 3: No keepalive entrie should exists on any suppliers
0a5078
-    verify_keepalive_entries(topo_m2, False)
0a5078
+    # verify entries exist
0a5078
+    entries = verify_keepalive_entries(topo_m2, True);
0a5078
 
0a5078
-    # Step 4: Perform on line init of supplier2 from supplier1
0a5078
-    agmt = Agreements(m1).list()[0]
0a5078
-    agmt.begin_reinit()
0a5078
-    (done, error) = agmt.wait_reinit()
0a5078
-    assert done is True
0a5078
-    assert error is False
0a5078
+    # Get current time from keep alive entry
0a5078
+    keep_alive_s1 = str(entries[0].data['keepalivetimestamp'])
0a5078
+    keep_alive_s2 = str(entries[1].data['keepalivetimestamp'])
0a5078
+
0a5078
+    # Wait for event interval (60 secs) to pass
0a5078
+    time.sleep(61)
0a5078
 
0a5078
-    # Step 5: All keepalive entries should exists on every suppliers
0a5078
-    #  Verify the keep alive entry once replication is in sync
0a5078
-    # (that is the step that fails when bug is not fixed)
0a5078
-    repl.wait_for_ruv(m2,m1)
0a5078
-    verify_keepalive_entries(topo_m2, True);
0a5078
+    # Check keep alives entries have been updated
0a5078
+    entries = verify_keepalive_entries(topo_m2, True);
0a5078
+    assert keep_alive_s1 != str(entries[0].data['keepalivetimestamp'])
0a5078
+    assert keep_alive_s2 != str(entries[1].data['keepalivetimestamp'])
0a5078
 
0a5078
 
0a5078
 @pytest.mark.ds49915
0a5078
diff --git a/dirsrvtests/tests/suites/replication/replica_config_test.py b/dirsrvtests/tests/suites/replication/replica_config_test.py
0a5078
index c2140a2ac..06ae5afcf 100644
0a5078
--- a/dirsrvtests/tests/suites/replication/replica_config_test.py
0a5078
+++ b/dirsrvtests/tests/suites/replication/replica_config_test.py
0a5078
@@ -50,7 +50,8 @@ repl_add_attrs = [('nsDS5ReplicaType', '-1', '4', overflow, notnum, '1'),
0a5078
                   ('nsds5ReplicaProtocolTimeout', '-1', too_big, overflow, notnum, '1'),
0a5078
                   ('nsds5ReplicaReleaseTimeout', '-1', too_big, overflow, notnum, '1'),
0a5078
                   ('nsds5ReplicaBackoffMin', '0', too_big, overflow, notnum, '3'),
0a5078
-                  ('nsds5ReplicaBackoffMax', '0', too_big, overflow, notnum, '6')]
0a5078
+                  ('nsds5ReplicaBackoffMax', '0', too_big, overflow, notnum, '6'),
0a5078
+                  ('nsds5ReplicaKeepAliveUpdateInterval', '59', too_big, overflow, notnum, '60'),]
0a5078
 
0a5078
 repl_mod_attrs = [('nsDS5Flags', '-1', '2', overflow, notnum, '1'),
0a5078
                   ('nsds5ReplicaPurgeDelay', '-2', too_big, overflow, notnum, '1'),
0a5078
@@ -59,7 +60,8 @@ repl_mod_attrs = [('nsDS5Flags', '-1', '2', overflow, notnum, '1'),
0a5078
                   ('nsds5ReplicaProtocolTimeout', '-1', too_big, overflow, notnum, '1'),
0a5078
                   ('nsds5ReplicaReleaseTimeout', '-1', too_big, overflow, notnum, '1'),
0a5078
                   ('nsds5ReplicaBackoffMin', '0', too_big, overflow, notnum, '3'),
0a5078
-                  ('nsds5ReplicaBackoffMax', '0', too_big, overflow, notnum, '6')]
0a5078
+                  ('nsds5ReplicaBackoffMax', '0', too_big, overflow, notnum, '6'),
0a5078
+                  ('nsds5ReplicaKeepAliveUpdateInterval', '59', too_big, overflow, notnum, '60'),]
0a5078
 
0a5078
 agmt_attrs = [
0a5078
               ('nsds5ReplicaPort', '0', '65535', overflow, notnum, '389'),
0a5078
diff --git a/ldap/schema/01core389.ldif b/ldap/schema/01core389.ldif
0a5078
index 0c73e5114..7a9598730 100644
0a5078
--- a/ldap/schema/01core389.ldif
0a5078
+++ b/ldap/schema/01core389.ldif
0a5078
@@ -327,6 +327,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.2371 NAME 'nsDS5ReplicaBootstrapBindDN'
0a5078
 attributeTypes: ( 2.16.840.1.113730.3.1.2372 NAME 'nsDS5ReplicaBootstrapCredentials' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
0a5078
 attributeTypes: ( 2.16.840.1.113730.3.1.2373 NAME 'nsDS5ReplicaBootstrapBindMethod' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
0a5078
 attributeTypes: ( 2.16.840.1.113730.3.1.2374 NAME 'nsDS5ReplicaBootstrapTransportInfo' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
0a5078
+attributeTypes: ( 2.16.840.1.113730.3.1.2390 NAME 'nsds5ReplicaKeepAliveUpdateInterval' DESC '389 defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN '389 Directory Server' )
0a5078
 #
0a5078
 # objectclasses
0a5078
 #
0a5078
@@ -336,7 +337,7 @@ objectClasses: ( 2.16.840.1.113730.3.2.44 NAME 'nsIndex' DESC 'Netscape defined
0a5078
 objectClasses: ( 2.16.840.1.113730.3.2.109 NAME 'nsBackendInstance' DESC 'Netscape defined objectclass' SUP top  MUST ( CN ) X-ORIGIN 'Netscape Directory Server' )
0a5078
 objectClasses: ( 2.16.840.1.113730.3.2.110 NAME 'nsMappingTree' DESC 'Netscape defined objectclass' SUP top  MUST ( CN ) X-ORIGIN 'Netscape Directory Server' )
0a5078
 objectClasses: ( 2.16.840.1.113730.3.2.104 NAME 'nsContainer' DESC 'Netscape defined objectclass' SUP top  MUST ( CN ) X-ORIGIN 'Netscape Directory Server' )
0a5078
-objectClasses: ( 2.16.840.1.113730.3.2.108 NAME 'nsDS5Replica' DESC 'Replication configuration objectclass' SUP top  MUST ( nsDS5ReplicaRoot $  nsDS5ReplicaId ) MAY (cn $ nsds5ReplicaPreciseTombstonePurging $ nsds5ReplicaCleanRUV $ nsds5ReplicaAbortCleanRUV $ nsDS5ReplicaType $ nsDS5ReplicaBindDN $ nsDS5ReplicaBindDNGroup $ nsState $ nsDS5ReplicaName $ nsDS5Flags $ nsDS5Task $ nsDS5ReplicaReferral $ nsDS5ReplicaAutoReferral $ nsds5ReplicaPurgeDelay $ nsds5ReplicaTombstonePurgeInterval $ nsds5ReplicaChangeCount $ nsds5ReplicaLegacyConsumer $ nsds5ReplicaProtocolTimeout $ nsds5ReplicaBackoffMin $ nsds5ReplicaBackoffMax $ nsds5ReplicaReleaseTimeout $ nsDS5ReplicaBindDnGroupCheckInterval ) X-ORIGIN 'Netscape Directory Server' )
0a5078
+objectClasses: ( 2.16.840.1.113730.3.2.108 NAME 'nsDS5Replica' DESC 'Replication configuration objectclass' SUP top  MUST ( nsDS5ReplicaRoot $  nsDS5ReplicaId ) MAY (cn $ nsds5ReplicaPreciseTombstonePurging $ nsds5ReplicaCleanRUV $ nsds5ReplicaAbortCleanRUV $ nsDS5ReplicaType $ nsDS5ReplicaBindDN $ nsDS5ReplicaBindDNGroup $ nsState $ nsDS5ReplicaName $ nsDS5Flags $ nsDS5Task $ nsDS5ReplicaReferral $ nsDS5ReplicaAutoReferral $ nsds5ReplicaPurgeDelay $ nsds5ReplicaTombstonePurgeInterval $ nsds5ReplicaChangeCount $ nsds5ReplicaLegacyConsumer $ nsds5ReplicaProtocolTimeout $ nsds5ReplicaBackoffMin $ nsds5ReplicaBackoffMax $ nsds5ReplicaReleaseTimeout $ nsDS5ReplicaBindDnGroupCheckInterval $ nsds5ReplicaKeepAliveUpdateInterval ) X-ORIGIN 'Netscape Directory Server' )
0a5078
 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' )
0a5078
 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 $ nsds5ReplicaIgnoreMissingChange $ nsDS5ReplicaBootstrapBindDN $ nsDS5ReplicaBootstrapCredentials $ nsDS5ReplicaBootstrapBindMethod $ nsDS5ReplicaBootstrapTransportInfo ) X-ORIGIN 'Netscape Directory Server' )
0a5078
 objectClasses: ( 2.16.840.1.113730.3.2.39 NAME 'nsslapdConfig' DESC 'Netscape defined objectclass' SUP top MAY ( cn ) X-ORIGIN 'Netscape Directory Server' )
0a5078
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
0a5078
index 06e747811..c2fbff8c0 100644
0a5078
--- a/ldap/servers/plugins/replication/repl5.h
0a5078
+++ b/ldap/servers/plugins/replication/repl5.h
0a5078
@@ -1,6 +1,6 @@
0a5078
 /** BEGIN COPYRIGHT BLOCK
0a5078
  * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
0a5078
- * Copyright (C) 2020 Red Hat, Inc.
0a5078
+ * Copyright (C) 2022 Red Hat, Inc.
0a5078
  * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
0a5078
  * All rights reserved.
0a5078
  *
0a5078
@@ -120,6 +120,8 @@
0a5078
 #define PROTOCOL_STATUS_TOTAL_SENDING_DATA             711
0a5078
 
0a5078
 #define DEFAULT_PROTOCOL_TIMEOUT 120
0a5078
+#define DEFAULT_REPLICA_KEEPALIVE_UPDATE_INTERVAL 3600
0a5078
+#define REPLICA_KEEPALIVE_UPDATE_INTERVAL_MIN 60
0a5078
 
0a5078
 /* To Allow Consumer Initialization when adding an agreement - */
0a5078
 #define STATE_PERFORMING_TOTAL_UPDATE       501
0a5078
@@ -162,6 +164,7 @@ extern const char *type_nsds5ReplicaBootstrapBindDN;
0a5078
 extern const char *type_nsds5ReplicaBootstrapCredentials;
0a5078
 extern const char *type_nsds5ReplicaBootstrapBindMethod;
0a5078
 extern const char *type_nsds5ReplicaBootstrapTransportInfo;
0a5078
+extern const char *type_replicaKeepAliveUpdateInterval;
0a5078
 
0a5078
 /* Attribute names for windows replication agreements */
0a5078
 extern const char *type_nsds7WindowsReplicaArea;
0a5078
@@ -677,8 +680,8 @@ Replica *windows_replica_new(const Slapi_DN *root);
0a5078
    during addition of the replica over LDAP */
0a5078
 int replica_new_from_entry(Slapi_Entry *e, char *errortext, PRBool is_add_operation, Replica **r);
0a5078
 void replica_destroy(void **arg);
0a5078
-int replica_subentry_update(Slapi_DN *repl_root, ReplicaId rid);
0a5078
-int replica_subentry_check(Slapi_DN *repl_root, ReplicaId rid);
0a5078
+void replica_subentry_update(time_t when, void *arg);
0a5078
+int replica_subentry_check(const char *repl_root, ReplicaId rid);
0a5078
 PRBool replica_get_exclusive_access(Replica *r, PRBool *isInc, uint64_t connid, int opid, const char *locking_purl, char **current_purl);
0a5078
 void replica_relinquish_exclusive_access(Replica *r, uint64_t connid, int opid);
0a5078
 PRBool replica_get_tombstone_reap_active(const Replica *r);
0a5078
@@ -739,6 +742,8 @@ void consumer5_set_mapping_tree_state_for_replica(const Replica *r, RUV *supplie
0a5078
 Replica *replica_get_for_backend(const char *be_name);
0a5078
 void replica_set_purge_delay(Replica *r, uint32_t purge_delay);
0a5078
 void replica_set_tombstone_reap_interval(Replica *r, long interval);
0a5078
+void replica_set_keepalive_update_interval(Replica *r, int64_t interval);
0a5078
+int64_t replica_get_keepalive_update_interval(Replica *r);
0a5078
 void replica_update_ruv_consumer(Replica *r, RUV *supplier_ruv);
0a5078
 Slapi_Entry *get_in_memory_ruv(Slapi_DN *suffix_sdn);
0a5078
 int replica_write_ruv(Replica *r);
0a5078
diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c
0a5078
index 4bb384882..846951b9e 100644
0a5078
--- a/ldap/servers/plugins/replication/repl5_inc_protocol.c
0a5078
+++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c
0a5078
@@ -1,6 +1,6 @@
0a5078
 /** BEGIN COPYRIGHT BLOCK
0a5078
  * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
0a5078
- * Copyright (C) 2020 Red Hat, Inc.
0a5078
+ * Copyright (C) 2022 Red Hat, Inc.
0a5078
  * All rights reserved.
0a5078
  *
0a5078
  * License: GPL (version 3 or any later version).
0a5078
@@ -1677,13 +1677,9 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
0a5078
     } else {
0a5078
         ConnResult replay_crc;
0a5078
         Replica *replica = prp->replica;
0a5078
-        PRBool subentry_update_needed = PR_FALSE;
0a5078
         PRUint64 release_timeout = replica_get_release_timeout(replica);
0a5078
         char csn_str[CSN_STRSIZE];
0a5078
-        int skipped_updates = 0;
0a5078
-        int fractional_repl;
0a5078
         int finished = 0;
0a5078
-#define FRACTIONAL_SKIPPED_THRESHOLD 100
0a5078
 
0a5078
         /* Start the results reading thread */
0a5078
         rd = repl5_inc_rd_new(prp);
0a5078
@@ -1700,7 +1696,6 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
0a5078
 
0a5078
         memset((void *)&op, 0, sizeof(op));
0a5078
         entry.op = &op;
0a5078
-        fractional_repl = agmt_is_fractional(prp->agmt);
0a5078
         do {
0a5078
             cl5_operation_parameters_done(entry.op);
0a5078
             memset((void *)entry.op, 0, sizeof(op));
0a5078
@@ -1781,14 +1776,6 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
0a5078
                     replica_id = csn_get_replicaid(entry.op->csn);
0a5078
                     uniqueid = entry.op->target_address.uniqueid;
0a5078
 
0a5078
-                    if (fractional_repl && message_id) {
0a5078
-                        /* This update was sent no need to update the subentry
0a5078
-                         * and restart counting the skipped updates
0a5078
-                         */
0a5078
-                        subentry_update_needed = PR_FALSE;
0a5078
-                        skipped_updates = 0;
0a5078
-                    }
0a5078
-
0a5078
                     if (prp->repl50consumer && message_id) {
0a5078
                         int operation, error = 0;
0a5078
 
0a5078
@@ -1816,15 +1803,6 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
0a5078
                                       agmt_get_long_name(prp->agmt),
0a5078
                                       entry.op->target_address.uniqueid, csn_str);
0a5078
                         agmt_inc_last_update_changecount(prp->agmt, csn_get_replicaid(entry.op->csn), 1 /*skipped*/);
0a5078
-                        if (fractional_repl) {
0a5078
-                            skipped_updates++;
0a5078
-                            if (skipped_updates > FRACTIONAL_SKIPPED_THRESHOLD) {
0a5078
-                                slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
0a5078
-                                              "send_updates - %s: skipped updates is too high (%d) if no other update is sent we will update the subentry\n",
0a5078
-                                              agmt_get_long_name(prp->agmt), skipped_updates);
0a5078
-                                subentry_update_needed = PR_TRUE;
0a5078
-                            }
0a5078
-                        }
0a5078
                     }
0a5078
                 }
0a5078
                 break;
0a5078
@@ -1906,26 +1884,6 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
0a5078
             PR_Unlock(rd->lock);
0a5078
         } while (!finished);
0a5078
 
0a5078
-        if (fractional_repl && subentry_update_needed) {
0a5078
-            ReplicaId rid = -1; /* Used to create the replica keep alive subentry */
0a5078
-            Slapi_DN *replarea_sdn = NULL;
0a5078
-
0a5078
-            if (replica) {
0a5078
-                rid = replica_get_rid(replica);
0a5078
-            }
0a5078
-            slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
0a5078
-                          "send_updates - %s: skipped updates was definitely too high (%d) update the subentry now\n",
0a5078
-                          agmt_get_long_name(prp->agmt), skipped_updates);
0a5078
-            replarea_sdn = agmt_get_replarea(prp->agmt);
0a5078
-            if (!replarea_sdn) {
0a5078
-                slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
0a5078
-                              "send_updates - Unknown replication area due to agreement not found.");
0a5078
-                agmt_set_last_update_status(prp->agmt, 0, -1, "Agreement is corrupted: missing suffix");
0a5078
-                return_value = UPDATE_FATAL_ERROR;
0a5078
-            } else {
0a5078
-                replica_subentry_update(replarea_sdn, rid);
0a5078
-            }
0a5078
-        }
0a5078
         /* Terminate the results reading thread */
0a5078
         if (!prp->repl50consumer) {
0a5078
             /* We need to ensure that we wait until all the responses have been received from our operations */
0a5078
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
0a5078
index 3bd57647f..ded4cf754 100644
0a5078
--- a/ldap/servers/plugins/replication/repl5_replica.c
0a5078
+++ b/ldap/servers/plugins/replication/repl5_replica.c
0a5078
@@ -1,6 +1,6 @@
0a5078
 /** BEGIN COPYRIGHT BLOCK
0a5078
  * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
0a5078
- * Copyright (C) 2005 Red Hat, Inc.
0a5078
+ * Copyright (C) 2022 Red Hat, Inc.
0a5078
  * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
0a5078
  * All rights reserved.
0a5078
  *
0a5078
@@ -22,7 +22,6 @@
0a5078
 #include "slap.h"
0a5078
 
0a5078
 #define RUV_SAVE_INTERVAL (30 * 1000) /* 30 seconds */
0a5078
-
0a5078
 #define REPLICA_RDN "cn=replica"
0a5078
 
0a5078
 /*
0a5078
@@ -48,6 +47,7 @@ struct replica
0a5078
     PRMonitor *repl_lock;              /* protects entire structure */
0a5078
     Slapi_Eq_Context repl_eqcxt_rs;    /* context to cancel event that saves ruv */
0a5078
     Slapi_Eq_Context repl_eqcxt_tr;    /* context to cancel event that reaps tombstones */
0a5078
+    Slapi_Eq_Context repl_eqcxt_ka_update; /* keep-alive entry update event */
0a5078
     Object *repl_csngen;               /* CSN generator for this replica */
0a5078
     PRBool repl_csn_assigned;          /* Flag set when new csn is assigned. */
0a5078
     int64_t repl_purge_delay;          /* When purgeable, CSNs are held on to for this many extra seconds */
0a5078
@@ -66,6 +66,7 @@ struct replica
0a5078
     uint64_t agmt_count;               /* Number of agmts */
0a5078
     Slapi_Counter *release_timeout;    /* The amount of time to wait before releasing active replica */
0a5078
     uint64_t abort_session;            /* Abort the current replica session */
0a5078
+    int64_t keepalive_update_interval; /* interval to do dummy update to keep RUV fresh */)
0a5078
 };
0a5078
 
0a5078
 
0a5078
@@ -133,8 +134,8 @@ replica_new(const Slapi_DN *root)
0a5078
                                &r);
0a5078
 
0a5078
         if (NULL == r) {
0a5078
-            slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "replica_new - "
0a5078
-                                                           "Unable to configure replica %s: %s\n",
0a5078
+            slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
0a5078
+                          "replica_new - Unable to configure replica %s: %s\n",
0a5078
                           slapi_sdn_get_dn(root), errorbuf);
0a5078
         }
0a5078
         slapi_entry_free(e);
0a5078
@@ -232,7 +233,15 @@ replica_new_from_entry(Slapi_Entry *e, char *errortext, PRBool is_add_operation,
0a5078
        In that case the updated would fail but nothing bad would happen. The next
0a5078
        scheduled update would save the state */
0a5078
     r->repl_eqcxt_rs = slapi_eq_repeat_rel(replica_update_state, r->repl_name,
0a5078
-                                           slapi_current_rel_time_t() + START_UPDATE_DELAY, RUV_SAVE_INTERVAL);
0a5078
+                                           slapi_current_rel_time_t() + START_UPDATE_DELAY,
0a5078
+                                           RUV_SAVE_INTERVAL);
0a5078
+
0a5078
+    /* create supplier update event */
0a5078
+    if (r->repl_eqcxt_ka_update == NULL && replica_get_type(r) == REPLICA_TYPE_UPDATABLE) {
0a5078
+        r->repl_eqcxt_ka_update = slapi_eq_repeat_rel(replica_subentry_update, r,
0a5078
+                                                   slapi_current_rel_time_t() + START_UPDATE_DELAY,
0a5078
+                                                   replica_get_keepalive_update_interval(r));
0a5078
+    }
0a5078
 
0a5078
     if (r->tombstone_reap_interval > 0) {
0a5078
         /*
0a5078
@@ -302,6 +311,11 @@ replica_destroy(void **arg)
0a5078
      * and ruv updates.
0a5078
      */
0a5078
 
0a5078
+    if (r->repl_eqcxt_ka_update) {
0a5078
+        slapi_eq_cancel_rel(r->repl_eqcxt_ka_update);
0a5078
+        r->repl_eqcxt_ka_update = NULL;
0a5078
+    }
0a5078
+
0a5078
     if (r->repl_eqcxt_rs) {
0a5078
         slapi_eq_cancel_rel(r->repl_eqcxt_rs);
0a5078
         r->repl_eqcxt_rs = NULL;
0a5078
@@ -393,7 +407,7 @@ replica_destroy(void **arg)
0a5078
 
0a5078
 
0a5078
 static int
0a5078
-replica_subentry_create(Slapi_DN *repl_root, ReplicaId rid)
0a5078
+replica_subentry_create(const char *repl_root, ReplicaId rid)
0a5078
 {
0a5078
     char *entry_string = NULL;
0a5078
     Slapi_Entry *e = NULL;
0a5078
@@ -402,7 +416,7 @@ replica_subentry_create(Slapi_DN *repl_root, ReplicaId rid)
0a5078
     int rc = 0;
0a5078
 
0a5078
     entry_string = slapi_ch_smprintf("dn: cn=%s %d,%s\nobjectclass: top\nobjectclass: ldapsubentry\nobjectclass: extensibleObject\ncn: %s %d",
0a5078
-                                     KEEP_ALIVE_ENTRY, rid, slapi_sdn_get_dn(repl_root), KEEP_ALIVE_ENTRY, rid);
0a5078
+                                     KEEP_ALIVE_ENTRY, rid, repl_root, KEEP_ALIVE_ENTRY, rid);
0a5078
     if (entry_string == NULL) {
0a5078
         slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
0a5078
                       "replica_subentry_create - Failed in slapi_ch_smprintf\n");
0a5078
@@ -441,7 +455,7 @@ done:
0a5078
 }
0a5078
 
0a5078
 int
0a5078
-replica_subentry_check(Slapi_DN *repl_root, ReplicaId rid)
0a5078
+replica_subentry_check(const char *repl_root, ReplicaId rid)
0a5078
 {
0a5078
     Slapi_PBlock *pb;
0a5078
     char *filter = NULL;
0a5078
@@ -451,7 +465,7 @@ replica_subentry_check(Slapi_DN *repl_root, ReplicaId rid)
0a5078
 
0a5078
     pb = slapi_pblock_new();
0a5078
     filter = slapi_ch_smprintf("(&(objectclass=ldapsubentry)(cn=%s %d))", KEEP_ALIVE_ENTRY, rid);
0a5078
-    slapi_search_internal_set_pb(pb, slapi_sdn_get_dn(repl_root), LDAP_SCOPE_ONELEVEL,
0a5078
+    slapi_search_internal_set_pb(pb, repl_root, LDAP_SCOPE_ONELEVEL,
0a5078
                                  filter, NULL, 0, NULL, NULL,
0a5078
                                  repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0);
0a5078
     slapi_search_internal_pb(pb);
0a5078
@@ -460,17 +474,19 @@ replica_subentry_check(Slapi_DN *repl_root, ReplicaId rid)
0a5078
         slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
0a5078
         if (entries && (entries[0] == NULL)) {
0a5078
             slapi_log_err(SLAPI_LOG_NOTICE, repl_plugin_name,
0a5078
-                          "replica_subentry_check - Need to create replication keep alive entry <cn=%s %d,%s>\n", KEEP_ALIVE_ENTRY, rid, slapi_sdn_get_dn(repl_root));
0a5078
+                          "replica_subentry_check - Need to create replication keep alive entry <cn=%s %d,%s>\n",
0a5078
+                          KEEP_ALIVE_ENTRY, rid, repl_root);
0a5078
             rc = replica_subentry_create(repl_root, rid);
0a5078
         } else {
0a5078
             slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
0a5078
-                          "replica_subentry_check - replication keep alive entry <cn=%s %d,%s> already exists\n", KEEP_ALIVE_ENTRY, rid, slapi_sdn_get_dn(repl_root));
0a5078
+                          "replica_subentry_check - replication keep alive entry <cn=%s %d,%s> already exists\n",
0a5078
+                          KEEP_ALIVE_ENTRY, rid, repl_root);
0a5078
             rc = 0;
0a5078
         }
0a5078
     } else {
0a5078
         slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
0a5078
                       "replica_subentry_check - Error accessing replication keep alive entry <cn=%s %d,%s> res=%d\n",
0a5078
-                      KEEP_ALIVE_ENTRY, rid, slapi_sdn_get_dn(repl_root), res);
0a5078
+                      KEEP_ALIVE_ENTRY, rid, repl_root, res);
0a5078
         /* The status of the entry is not clear, do not attempt to create it */
0a5078
         rc = 1;
0a5078
     }
0a5078
@@ -481,60 +497,59 @@ replica_subentry_check(Slapi_DN *repl_root, ReplicaId rid)
0a5078
     return rc;
0a5078
 }
0a5078
 
0a5078
-int
0a5078
-replica_subentry_update(Slapi_DN *repl_root, ReplicaId rid)
0a5078
+void
0a5078
+replica_subentry_update(time_t when __attribute__((unused)), void *arg)
0a5078
 {
0a5078
-    int ldrc;
0a5078
-    int rc = LDAP_SUCCESS; /* Optimistic default */
0a5078
+    Slapi_PBlock *modpb = NULL;
0a5078
+    Replica *replica = (Replica *)arg;
0a5078
+    ReplicaId rid;
0a5078
     LDAPMod *mods[2];
0a5078
     LDAPMod mod;
0a5078
     struct berval *vals[2];
0a5078
-    char buf[SLAPI_TIMESTAMP_BUFSIZE];
0a5078
     struct berval val;
0a5078
-    Slapi_PBlock *modpb = NULL;
0a5078
-    char *dn;
0a5078
+    const char *repl_root = NULL;
0a5078
+    char buf[SLAPI_TIMESTAMP_BUFSIZE];
0a5078
+    char *dn = NULL;
0a5078
+    int ldrc = 0;
0a5078
 
0a5078
+    rid = replica_get_rid(replica);
0a5078
+    repl_root = slapi_ch_strdup(slapi_sdn_get_dn(replica_get_root(replica)));
0a5078
     replica_subentry_check(repl_root, rid);
0a5078
 
0a5078
     slapi_timestamp_utc_hr(buf, SLAPI_TIMESTAMP_BUFSIZE);
0a5078
-
0a5078
-    slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "subentry_update called at %s\n", buf);
0a5078
-
0a5078
-
0a5078
+    slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name, "replica_subentry_update called at %s\n", buf);
0a5078
     val.bv_val = buf;
0a5078
     val.bv_len = strlen(val.bv_val);
0a5078
-
0a5078
     vals[0] = &val;
0a5078
     vals[1] = NULL;
0a5078
 
0a5078
     mod.mod_op = LDAP_MOD_REPLACE | LDAP_MOD_BVALUES;
0a5078
     mod.mod_type = KEEP_ALIVE_ATTR;
0a5078
     mod.mod_bvalues = vals;
0a5078
-
0a5078
     mods[0] = &mod;
0a5078
     mods[1] = NULL;
0a5078
 
0a5078
     modpb = slapi_pblock_new();
0a5078
-    dn = slapi_ch_smprintf(KEEP_ALIVE_DN_FORMAT, KEEP_ALIVE_ENTRY, rid, slapi_sdn_get_dn(repl_root));
0a5078
-
0a5078
+    dn = slapi_ch_smprintf(KEEP_ALIVE_DN_FORMAT, KEEP_ALIVE_ENTRY, rid, repl_root);
0a5078
     slapi_modify_internal_set_pb(modpb, dn, mods, NULL, NULL,
0a5078
                                  repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0);
0a5078
     slapi_modify_internal_pb(modpb);
0a5078
-
0a5078
     slapi_pblock_get(modpb, SLAPI_PLUGIN_INTOP_RESULT, &ldrc;;
0a5078
-
0a5078
     if (ldrc != LDAP_SUCCESS) {
0a5078
         slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
0a5078
-                      "Failure (%d) to update replication keep alive entry \"%s: %s\"\n", ldrc, KEEP_ALIVE_ATTR, buf);
0a5078
-        rc = ldrc;
0a5078
+                      "replica_subentry_update - "
0a5078
+                      "Failure (%d) to update replication keep alive entry \"%s: %s\"\n",
0a5078
+                      ldrc, KEEP_ALIVE_ATTR, buf);
0a5078
     } else {
0a5078
         slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name,
0a5078
-                      "Successful update of replication keep alive entry \"%s: %s\"\n", KEEP_ALIVE_ATTR, buf);
0a5078
+                      "replica_subentry_update - "
0a5078
+                      "Successful update of replication keep alive entry \"%s: %s\"\n",
0a5078
+                      KEEP_ALIVE_ATTR, buf);
0a5078
     }
0a5078
 
0a5078
     slapi_pblock_destroy(modpb);
0a5078
+    slapi_ch_free_string((char **)&repl_root);
0a5078
     slapi_ch_free_string(&dn;;
0a5078
-    return rc;
0a5078
 }
0a5078
 /*
0a5078
  * Attempt to obtain exclusive access to replica (advisory only)
0a5078
@@ -1512,7 +1527,15 @@ replica_set_enabled(Replica *r, PRBool enable)
0a5078
         if (r->repl_eqcxt_rs == NULL) /* event is not already registered */
0a5078
         {
0a5078
             r->repl_eqcxt_rs = slapi_eq_repeat_rel(replica_update_state, r->repl_name,
0a5078
-                                                   slapi_current_rel_time_t() + START_UPDATE_DELAY, RUV_SAVE_INTERVAL);
0a5078
+                                                   slapi_current_rel_time_t() + START_UPDATE_DELAY,
0a5078
+                                                   RUV_SAVE_INTERVAL);
0a5078
+
0a5078
+        }
0a5078
+        /* create supplier update event */
0a5078
+        if (r->repl_eqcxt_ka_update == NULL && replica_get_type(r) == REPLICA_TYPE_UPDATABLE) {
0a5078
+            r->repl_eqcxt_ka_update = slapi_eq_repeat_rel(replica_subentry_update, r,
0a5078
+                                                       slapi_current_rel_time_t() + START_UPDATE_DELAY,
0a5078
+                                                       replica_get_keepalive_update_interval(r));
0a5078
         }
0a5078
     } else /* disable */
0a5078
     {
0a5078
@@ -1521,6 +1544,11 @@ replica_set_enabled(Replica *r, PRBool enable)
0a5078
             slapi_eq_cancel_rel(r->repl_eqcxt_rs);
0a5078
             r->repl_eqcxt_rs = NULL;
0a5078
         }
0a5078
+        /* Remove supplier update event */
0a5078
+        if (replica_get_type(r) == REPLICA_TYPE_PRIMARY) {
0a5078
+            slapi_eq_cancel_rel(r->repl_eqcxt_ka_update);
0a5078
+            r->repl_eqcxt_ka_update = NULL;
0a5078
+        }
0a5078
     }
0a5078
 
0a5078
     replica_unlock(r->repl_lock);
0a5078
@@ -2119,6 +2147,17 @@ _replica_init_from_config(Replica *r, Slapi_Entry *e, char *errortext)
0a5078
         r->tombstone_reap_interval = 3600 * 24; /* One week, in seconds */
0a5078
     }
0a5078
 
0a5078
+    if ((val = (char*)slapi_entry_attr_get_ref(e, type_replicaKeepAliveUpdateInterval))) {
0a5078
+        if (repl_config_valid_num(type_replicaKeepAliveUpdateInterval, val, REPLICA_KEEPALIVE_UPDATE_INTERVAL_MIN,
0a5078
+                                  INT_MAX, &rc, errormsg, &interval) != 0)
0a5078
+        {
0a5078
+            return LDAP_UNWILLING_TO_PERFORM;
0a5078
+        }
0a5078
+        r->keepalive_update_interval = interval;
0a5078
+    } else {
0a5078
+        r->keepalive_update_interval = DEFAULT_REPLICA_KEEPALIVE_UPDATE_INTERVAL;
0a5078
+    }
0a5078
+
0a5078
     r->tombstone_reap_stop = r->tombstone_reap_active = PR_FALSE;
0a5078
 
0a5078
     /* No supplier holding the replica */
0a5078
@@ -3646,6 +3685,26 @@ replica_set_tombstone_reap_interval(Replica *r, long interval)
0a5078
     replica_unlock(r->repl_lock);
0a5078
 }
0a5078
 
0a5078
+void
0a5078
+replica_set_keepalive_update_interval(Replica *r, int64_t interval)
0a5078
+{
0a5078
+    replica_lock(r->repl_lock);
0a5078
+    r->keepalive_update_interval = interval;
0a5078
+    replica_unlock(r->repl_lock);
0a5078
+}
0a5078
+
0a5078
+int64_t
0a5078
+replica_get_keepalive_update_interval(Replica *r)
0a5078
+{
0a5078
+    int64_t interval = DEFAULT_REPLICA_KEEPALIVE_UPDATE_INTERVAL;
0a5078
+
0a5078
+    replica_lock(r->repl_lock);
0a5078
+    interval = r->keepalive_update_interval;
0a5078
+    replica_unlock(r->repl_lock);
0a5078
+
0a5078
+    return interval;
0a5078
+}
0a5078
+
0a5078
 static void
0a5078
 replica_strip_cleaned_rids(Replica *r)
0a5078
 {
0a5078
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
0a5078
index 2c6d74b13..aea2cf506 100644
0a5078
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
0a5078
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
0a5078
@@ -438,6 +438,9 @@ replica_config_modify(Slapi_PBlock *pb,
0a5078
                 } else if (strcasecmp(config_attr, type_replicaBackoffMax) == 0) {
0a5078
                     if (apply_mods)
0a5078
                         replica_set_backoff_max(r, PROTOCOL_BACKOFF_MAXIMUM);
0a5078
+                } else if (strcasecmp(config_attr, type_replicaKeepAliveUpdateInterval) == 0) {
0a5078
+                    if (apply_mods)
0a5078
+                        replica_set_keepalive_update_interval(r, DEFAULT_REPLICA_KEEPALIVE_UPDATE_INTERVAL);
0a5078
                 } else if (strcasecmp(config_attr, type_replicaPrecisePurge) == 0) {
0a5078
                     if (apply_mods)
0a5078
                         replica_set_precise_purging(r, 0);
0a5078
@@ -472,6 +475,15 @@ replica_config_modify(Slapi_PBlock *pb,
0a5078
                     } else {
0a5078
                         break;
0a5078
                     }
0a5078
+                } else if (strcasecmp(config_attr, type_replicaKeepAliveUpdateInterval) == 0) {
0a5078
+                    int64_t interval = DEFAULT_REPLICA_KEEPALIVE_UPDATE_INTERVAL;
0a5078
+                    if (repl_config_valid_num(config_attr, config_attr_value, REPLICA_KEEPALIVE_UPDATE_INTERVAL_MIN,
0a5078
+                                              INT_MAX, returncode, errortext, &interval) == 0)
0a5078
+                    {
0a5078
+                        replica_set_keepalive_update_interval(r, interval);
0a5078
+                    } else {
0a5078
+                        break;
0a5078
+                    }
0a5078
                 } else if (strcasecmp(config_attr, attr_replicaType) == 0) {
0a5078
                     int64_t rtype;
0a5078
                     slapi_ch_free_string(&new_repl_type);
0a5078
diff --git a/ldap/servers/plugins/replication/repl5_tot_protocol.c b/ldap/servers/plugins/replication/repl5_tot_protocol.c
0a5078
index f67263c3e..4b2064912 100644
0a5078
--- a/ldap/servers/plugins/replication/repl5_tot_protocol.c
0a5078
+++ b/ldap/servers/plugins/replication/repl5_tot_protocol.c
0a5078
@@ -510,7 +510,7 @@ retry:
0a5078
         if (prp->replica) {
0a5078
             rid = replica_get_rid(prp->replica);
0a5078
         }
0a5078
-        replica_subentry_check(area_sdn, rid);
0a5078
+        replica_subentry_check(slapi_sdn_get_dn(area_sdn), rid);
0a5078
 
0a5078
         /* Send the subtree of the suffix in the order of parentid index plus ldapsubentry and nstombstone. */
0a5078
         check_suffix_entryID(be, suffix);
0a5078
@@ -531,7 +531,7 @@ retry:
0a5078
         if (prp->replica) {
0a5078
             rid = replica_get_rid(prp->replica);
0a5078
         }
0a5078
-        replica_subentry_check(area_sdn, rid);
0a5078
+        replica_subentry_check(slapi_sdn_get_dn(area_sdn), rid);
0a5078
 
0a5078
         slapi_search_internal_set_pb(pb, slapi_sdn_get_dn(area_sdn),
0a5078
                                      LDAP_SCOPE_SUBTREE, "(|(objectclass=ldapsubentry)(objectclass=nstombstone)(nsuniqueid=*))", NULL, 0, ctrls, NULL,
0a5078
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
0a5078
index ef2025dd9..8b178610b 100644
0a5078
--- a/ldap/servers/plugins/replication/repl_extop.c
0a5078
+++ b/ldap/servers/plugins/replication/repl_extop.c
0a5078
@@ -1176,7 +1176,7 @@ multimaster_extop_EndNSDS50ReplicationRequest(Slapi_PBlock *pb)
0a5078
                     /* now that the changelog is open and started, we can alos cretae the
0a5078
                      * keep alive entry without risk that db and cl will not match
0a5078
                      */
0a5078
-                    replica_subentry_check((Slapi_DN *)replica_get_root(r), replica_get_rid(r));
0a5078
+                    replica_subentry_check(slapi_sdn_get_dn(replica_get_root(r)), replica_get_rid(r));
0a5078
                 }
0a5078
 
0a5078
                 /* ONREPL code that dealt with new RUV, etc was moved into the code
0a5078
diff --git a/ldap/servers/plugins/replication/repl_globals.c b/ldap/servers/plugins/replication/repl_globals.c
0a5078
index 000777fdd..797ca957f 100644
0a5078
--- a/ldap/servers/plugins/replication/repl_globals.c
0a5078
+++ b/ldap/servers/plugins/replication/repl_globals.c
0a5078
@@ -89,6 +89,7 @@ const char *type_replicaReleaseTimeout = "nsds5ReplicaReleaseTimeout";
0a5078
 const char *type_replicaBackoffMin = "nsds5ReplicaBackoffMin";
0a5078
 const char *type_replicaBackoffMax = "nsds5ReplicaBackoffMax";
0a5078
 const char *type_replicaPrecisePurge = "nsds5ReplicaPreciseTombstonePurging";
0a5078
+const char *type_replicaKeepAliveUpdateInterval = "nsds5ReplicaKeepAliveUpdateInterval";
0a5078
 
0a5078
 /* Attribute names for replication agreement attributes */
0a5078
 const char *type_nsds5ReplicaHost = "nsds5ReplicaHost";
0a5078
diff --git a/src/cockpit/389-console/src/lib/replication/replConfig.jsx b/src/cockpit/389-console/src/lib/replication/replConfig.jsx
0a5078
index 1f0dc3ec5..3dffb8f1a 100644
0a5078
--- a/src/cockpit/389-console/src/lib/replication/replConfig.jsx
0a5078
+++ b/src/cockpit/389-console/src/lib/replication/replConfig.jsx
0a5078
@@ -48,6 +48,7 @@ export class ReplConfig extends React.Component {
0a5078
             nsds5replicaprotocoltimeout: Number(this.props.data.nsds5replicaprotocoltimeout) == 0 ? 120 : Number(this.props.data.nsds5replicaprotocoltimeout),
0a5078
             nsds5replicabackoffmin: Number(this.props.data.nsds5replicabackoffmin) == 0 ? 3 : Number(this.props.data.nsds5replicabackoffmin),
0a5078
             nsds5replicabackoffmax: Number(this.props.data.nsds5replicabackoffmax) == 0 ? 300 : Number(this.props.data.nsds5replicabackoffmax),
0a5078
+            nsds5replicakeepaliveupdateinterval: Number(this.props.data.nsds5replicakeepaliveupdateinterval) == 0 ? 3600 : Number(this.props.data.nsds5replicakeepaliveupdateinterval),
0a5078
             // Original settings
0a5078
             _nsds5replicabinddn: this.props.data.nsds5replicabinddn,
0a5078
             _nsds5replicabinddngroup: this.props.data.nsds5replicabinddngroup,
0a5078
@@ -59,6 +60,7 @@ export class ReplConfig extends React.Component {
0a5078
             _nsds5replicaprotocoltimeout: Number(this.props.data.nsds5replicaprotocoltimeout) == 0 ? 120 : Number(this.props.data.nsds5replicaprotocoltimeout),
0a5078
             _nsds5replicabackoffmin: Number(this.props.data.nsds5replicabackoffmin) == 0 ? 3 : Number(this.props.data.nsds5replicabackoffmin),
0a5078
             _nsds5replicabackoffmax: Number(this.props.data.nsds5replicabackoffmax) == 0 ? 300 : Number(this.props.data.nsds5replicabackoffmax),
0a5078
+            _nsds5replicakeepaliveupdateinterval: Number(this.props.data.nsds5replicakeepaliveupdateinterval) == 0 ? 3600 : Number(this.props.data.nsds5replicakeepaliveupdateinterval),
0a5078
         };
0a5078
 
0a5078
         this.onToggle = (isExpanded) => {
0a5078
@@ -275,7 +277,7 @@ export class ReplConfig extends React.Component {
0a5078
             'nsds5replicapurgedelay', 'nsds5replicatombstonepurgeinterval',
0a5078
             'nsds5replicareleasetimeout', 'nsds5replicaprotocoltimeout',
0a5078
             'nsds5replicabackoffmin', 'nsds5replicabackoffmax',
0a5078
-            'nsds5replicaprecisetombstonepurging'
0a5078
+            'nsds5replicaprecisetombstonepurging', 'nsds5replicakeepaliveupdateinterval',
0a5078
         ];
0a5078
         // Check if a setting was changed, if so enable the save button
0a5078
         for (const config_attr of config_attrs) {
0a5078
@@ -301,7 +303,7 @@ export class ReplConfig extends React.Component {
0a5078
             'nsds5replicapurgedelay', 'nsds5replicatombstonepurgeinterval',
0a5078
             'nsds5replicareleasetimeout', 'nsds5replicaprotocoltimeout',
0a5078
             'nsds5replicabackoffmin', 'nsds5replicabackoffmax',
0a5078
-            'nsds5replicaprecisetombstonepurging'
0a5078
+            'nsds5replicaprecisetombstonepurging', 'nsds5replicakeepaliveupdateinterval',
0a5078
         ];
0a5078
         // Check if a setting was changed, if so enable the save button
0a5078
         for (const config_attr of config_attrs) {
0a5078
@@ -451,6 +453,9 @@ export class ReplConfig extends React.Component {
0a5078
         if (this.state.nsds5replicabinddngroupcheckinterval != this.state._nsds5replicabinddngroupcheckinterval) {
0a5078
             cmd.push("--repl-bind-group-interval=" + this.state.nsds5replicabinddngroupcheckinterval);
0a5078
         }
0a5078
+        if (this.state.nsds5replicakeepaliveupdateinterval != this.state._nsds5replicakeepaliveupdateinterval) {
0a5078
+            cmd.push("--repl-keepalive-update-interval=" + this.state.nsds5replicakeepaliveupdateinterval);
0a5078
+        }
0a5078
         if (this.state.nsds5replicareleasetimeout != this.state._nsds5replicareleasetimeout) {
0a5078
             cmd.push("--repl-release-timeout=" + this.state.nsds5replicareleasetimeout);
0a5078
         }
0a5078
@@ -786,6 +791,29 @@ export class ReplConfig extends React.Component {
0a5078
                                         />
0a5078
                                     </GridItem>
0a5078
                                 </Grid>
0a5078
+                                
0a5078
+                                    title="The interval in seconds that the server will apply an internal update to get the RUV from getting stale. (nsds5replicakeepaliveupdateinterval)."
0a5078
+                                    className="ds-margin-top"
0a5078
+                                >
0a5078
+                                    <GridItem className="ds-label" span={3}>
0a5078
+                                        Refresh RUV Interval
0a5078
+                                    </GridItem>
0a5078
+                                    <GridItem span={9}>
0a5078
+                                        
0a5078
+                                            value={this.state.nsds5replicakeepaliveupdateinterval}
0a5078
+                                            min={60}
0a5078
+                                            max={this.maxValue}
0a5078
+                                            onMinus={() => { this.onMinusConfig("nsds5replicakeepaliveupdateinterval") }}
0a5078
+                                            onChange={(e) => { this.onConfigChange(e, "nsds5replicakeepaliveupdateinterval", 60) }}
0a5078
+                                            onPlus={() => { this.onPlusConfig("nsds5replicakeepaliveupdateinterval") }}
0a5078
+                                            inputName="input"
0a5078
+                                            inputAriaLabel="number input"
0a5078
+                                            minusBtnAriaLabel="minus"
0a5078
+                                            plusBtnAriaLabel="plus"
0a5078
+                                            widthChars={8}
0a5078
+                                        />
0a5078
+                                    </GridItem>
0a5078
+                                </Grid>
0a5078
                                 
0a5078
                                     title="Enables faster tombstone purging (nsds5replicaprecisetombstonepurging)."
0a5078
                                     className="ds-margin-top"
0a5078
diff --git a/src/cockpit/389-console/src/replication.jsx b/src/cockpit/389-console/src/replication.jsx
0a5078
index 28364156a..db9d030db 100644
0a5078
--- a/src/cockpit/389-console/src/replication.jsx
0a5078
+++ b/src/cockpit/389-console/src/replication.jsx
0a5078
@@ -553,6 +553,7 @@ export class Replication extends React.Component {
0a5078
                             nsds5replicaprotocoltimeout: 'nsds5replicaprotocoltimeout' in config.attrs ? config.attrs.nsds5replicaprotocoltimeout[0] : "",
0a5078
                             nsds5replicabackoffmin: 'nsds5replicabackoffmin' in config.attrs ? config.attrs.nsds5replicabackoffmin[0] : "",
0a5078
                             nsds5replicabackoffmax: 'nsds5replicabackoffmax' in config.attrs ? config.attrs.nsds5replicabackoffmax[0] : "",
0a5078
+                            nsds5replicakeepaliveupdateinterval: 'nsds5replicakeepaliveupdateinterval' in config.attrs ? config.attrs.nsds5replicakeepaliveupdateinterval[0] : "3600",
0a5078
                         },
0a5078
                         suffixSpinning: false,
0a5078
                         disabled: false,
0a5078
@@ -695,6 +696,11 @@ export class Replication extends React.Component {
0a5078
                             nsds5replicaprotocoltimeout: 'nsds5replicaprotocoltimeout' in config.attrs ? config.attrs.nsds5replicaprotocoltimeout[0] : "",
0a5078
                             nsds5replicabackoffmin: 'nsds5replicabackoffmin' in config.attrs ? config.attrs.nsds5replicabackoffmin[0] : "",
0a5078
                             nsds5replicabackoffmax: 'nsds5replicabackoffmax' in config.attrs ? config.attrs.nsds5replicabackoffmax[0] : "",
0a5078
+                            nsds5replicakeepaliveupdateinterval: 'nsds5replicakeepaliveupdateinterval' in config.attrs ? config.attrs.nsds5replicakeepaliveupdateinterval[0] : "3600",
0a5078
+                            clMaxEntries: "",
0a5078
+                            clMaxAge: "",
0a5078
+                            clTrimInt: "",
0a5078
+                            clEncrypt: false,
0a5078
                         }
0a5078
                     }, this.loadLDIFs);
0a5078
 
0a5078
diff --git a/src/lib389/lib389/cli_conf/replication.py b/src/lib389/lib389/cli_conf/replication.py
0a5078
index 0048cd09b..450246b3d 100644
0a5078
--- a/src/lib389/lib389/cli_conf/replication.py
0a5078
+++ b/src/lib389/lib389/cli_conf/replication.py
0a5078
@@ -33,6 +33,7 @@ arg_to_attr = {
0a5078
         'repl_backoff_min': 'nsds5replicabackoffmin',
0a5078
         'repl_backoff_max': 'nsds5replicabackoffmax',
0a5078
         'repl_release_timeout': 'nsds5replicareleasetimeout',
0a5078
+        'repl_keepalive_update_interval': 'nsds5replicakeepaliveupdateinterval',
0a5078
         # Changelog
0a5078
         'cl_dir': 'nsslapd-changelogdir',
0a5078
         'max_entries': 'nsslapd-changelogmaxentries',
0a5078
@@ -1278,6 +1279,9 @@ def create_parser(subparsers):
0a5078
                                                             "while waiting to acquire the consumer. Default is 3 seconds")
0a5078
     repl_set_parser.add_argument('--repl-release-timeout', help="A timeout in seconds a replication supplier should send "
0a5078
                                                                 "updates before it yields its replication session")
0a5078
+    repl_set_parser.add_argument('--repl-keepalive-update-interval', help="Interval in seconds for how often the server will apply "
0a5078
+                                                                          "an internal update to keep the RUV from getting stale. "
0a5078
+                                                                          "The default is 1 hour (3600 seconds)")
0a5078
 
0a5078
     repl_monitor_parser = repl_subcommands.add_parser('monitor', help='Display the full replication topology report')
0a5078
     repl_monitor_parser.set_defaults(func=get_repl_monitor_info)
0a5078
@@ -1289,7 +1293,7 @@ def create_parser(subparsers):
0a5078
     repl_monitor_parser.add_argument('-a', '--aliases', nargs="*",
0a5078
                                      help="Enables displaying an alias instead of host:port, if an alias is "
0a5078
                                           "assigned to a host:port combination. The format: alias=host:port")
0a5078
-#
0a5078
+
0a5078
     ############################################
0a5078
     # Replication Agmts
0a5078
     ############################################
0a5078
-- 
0a5078
2.37.1
0a5078