Bug 2057929

Summary: "dsconf replication restore-changelog" does not work in RHDS11
Product: Red Hat Directory Server Reporter: kyoneyama <kyoneyam>
Component: 389-ds-baseAssignee: LDAP Maintainers <ldap-maint>
Status: CLOSED CURRENTRELEASE QA Contact: RHDS QE <ds-qe-bugs>
Severity: high Docs Contact: Marc Muehlfeld <mmuehlfe>
Priority: unspecified    
Version: 11.3CC: bsmejkal, ldap-maint, mreynolds, tbordaz
Target Milestone: ---   
Target Release: dirsrv-11.6   
Hardware: x86_64   
OS: Linux   
Whiteboard: sync-to-jira
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-03 15:45:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description kyoneyama 2022-02-24 08:16:26 UTC
Description of problem:

To recreate changelogdb, I tried exporting changelogdb to LDIF and then importing it per documents.

  - https://access.redhat.com/documentation/en-us/red_hat_directory_server/11/html/administration_guide/exporting-up-the-replication-changelog
  - https://access.redhat.com/documentation/en-us/red_hat_directory_server/11/html/administration_guide/importing-the-replication-changelog-from-an-ldif-formatted-changelog-dump


I was able to run the commands without error, but the restore does not succeed.
"dsconf ... restore-changelog" command only exports the changelogdb, but does not seem to recreate the changelogdb.



Version-Release number of selected component (if applicable):

- Red Hat Enterprise Linux 8
- Red Hat Directory Server 11
- 389-ds-base-1.4.3.27-2.module+el8dsrv+12690+c6df6d1b.x86_64
- python3-lib389-1.4.3.27-2.module+el8dsrv+12690+c6df6d1b.noarch
- libdb-5.3.28-42.el8_4.x86_64


How reproducible:

  Always

Steps to Reproduce:

1. Get the replica-root and replica-name.

  # ldapsearch ... -LLL -b cn=config objectClass=nsds5Replica nsds5ReplicaRoot
  dn: cn=replica,cn=dc\3Dad\2Cdc\3Dexample\2Cdc\3Dcom,cn=mapping tree,cn=config
  nsds5ReplicaRoot: dc=ad,dc=example,dc=com

  # ldapsearch ... -LLL -b cn=config objectClass=nsds5Replica nsds5ReplicaName
  dn: cn=replica,cn=dc\3Dad\2Cdc\3Dexample\2Cdc\3Dcom,cn=mapping tree,cn=config
  nsds5ReplicaName: 03976a03-741611ec-b0489357-92c04aa1

2. Dump changelogdb to LDIF file.

  # dsconf rhds11 replication dump-changelog > /tmp/changelog.ldif

3. Prepare the file in advance to avoid errors.

  # touch /var/lib/dirsrv/slapd-rhds11/changelogdb/03976a03-741611ec-b0489357-92c04aa1.ldif
  # chown dirsrv:dirsrv /var/lib/dirsrv/slapd-rhds11/changelogdb/03976a03-741611ec-b0489357-92c04aa1.ldif

4. Restore changelogdb from LDIF file

  # dsconf rhds11 replication restore-changelog from-ldif -r "dc=ad,dc=example,dc=com" /tmp/changelog.ldif 

5. Make sure that the db file in the changelogdb directory is updated.

  # ls -l /var/lib/dirsrv/slapd-rhds11/changelogdb


Actual results:

The changelogdb won't be recreated.

When "dsconf ... restore-changelog" is executed, the LDIF export is performed by "cl2ldif" task.

  -- errors --
  [22/Feb/2022:17:06:39.819473308 +0900] - INFO - NSMMReplicationPlugin - replica_execute_cl2ldif_task - Beginning changelog export of replica "03976a03-741611ec-b0489357-92c04aa1"
  [22/Feb/2022:17:06:39.831641891 +0900] - INFO - NSMMReplicationPlugin - replica_execute_cl2ldif_task - Finished changelog export of replica "03976a03-741611ec-b0489357-92c04aa1"

Expected results:

The changelogdb will be recreated.


Additional info:

After I investigated the source code, restore_changelog() method only sets "cl2ldif" task at the end and it completes.
I expect that it has to do the "ldif2cl" task to import it.

  -- /usr/lib/python3.6/site-packages/lib389/cli_conf/replication.py --
  1102 def restore_cl_ldif(inst, basedn, log, args):
  :
  1124     replicas.restore_changelog(replica_roots=args.replica_root, log=log)
  1125     os.remove(target_ldif)
  1126     if target_ldif_exists:
  1127         os.rename(f'{target_ldif}.backup', target_ldif)


  -- /usr/lib/python3.6/site-packages/lib389/replica.py --
  1737     def restore_changelog(self, replica_roots, log=None):
  :
  1759         # Dump the changelog for the replica
  1760         for repl_root in replica_roots:
  :
  1766 
  1767             if changelog_ldif:
  1768                 replica.begin_task_cl2ldif()
  1769             elif changelog_ldif_done:
  1770                 ldif_done_file = os.path.join(cl_dir, changelog_ldif_done[0])
  1771                 ldif_file = os.path.join(cl_dir, f"{replica_name}.ldif")
  1772                 ldif_file_exists = os.path.exists(ldif_file)
  1773                 if ldif_file_exists:
  1774                     copy_with_permissions(ldif_file, f'{ldif_file}.backup')
  1775                 copy_with_permissions(ldif_done_file, ldif_file)
  1776                 replica.begin_task_cl2ldif()
  1777                 os.remove(ldif_file)
  1778                 if ldif_file_exists:
  1779                     os.rename(f'{ldif_file}.backup', ldif_file)
  1780             else:
  1781                 log.error(f"Changelog LDIF for '{repl_root}' was not found")
  1782                 continue
  1783 

  1605     def begin_task_cl2ldif(self):
  1606         """Begin the changelog to ldif task
  1607         """
  1608         self.replace('nsds5task', 'cl2ldif')
  1609