Bug 1951537

Summary: Import reports "successful" even if entries could not be added and import was incomplete
Product: Red Hat Directory Server Reporter: Marc Muehlfeld <mmuehlfe>
Component: 389-ds-baseAssignee: LDAP Maintainers <ldap-maint>
Status: CLOSED ERRATA QA Contact: RHDS QE <ds-qe-bugs>
Severity: unspecified Docs Contact: Marc Muehlfeld <mmuehlfe>
Priority: unspecified    
Version: 11.2CC: bsmejkal, jachapma, ldap-maint, mreynolds, sgouvern, vashirov
Target Milestone: DS11.3   
Target Release: dirsrv-11.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: redhat-ds-11-8050020210827183202.d3df4063 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-10-25 06:36:13 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:
Attachments:
Description Flags
example.ldif
none
errors log none

Description Marc Muehlfeld 2021-04-20 11:45:51 UTC
Created attachment 1773735 [details]
example.ldif

Description of problem:
The "dsconf backend import" command returns "The import task has finished successfully" even if some entries could not be added (for example, because of a missing parent entry).


Version-Release number of selected component (if applicable):
389-ds-base-1.4.3.13-1.module+el8dsrv+8334+69a46a2e.x86_64


How reproducible:
Always


Steps to Reproduce:
1. Try to import the attached LDIF file:
   # dsconf -D "cn=Directory Manager" ldap://server.example.com backend import userroot /var/lib/dirsrv/slapd-instance_name/ldif/example.ldif


Actual results:
The command shows: "The import task has finished successfully"


Expected results:
The command should show an error that the import was incomplete.

The error log correctly shows that an entry was skipped. However, admin will not check the log for errors if the command returns that the import was successful.


Additional info:
* BZ#1627645 does not solve this problem.
I also tried the import on Fedora 34 with the nightly build from corp repo (389-ds-base-2.0.3-20210407gitf1f7ff126.fc34.x86_64) and the import also incorrectly reports that it was successful.

Comment 1 Marc Muehlfeld 2021-04-20 11:46:23 UTC
Created attachment 1773736 [details]
errors log

Comment 2 Viktor Ashirov 2021-04-20 12:15:28 UTC
I tried to import the same file over and over and every time I get a different message:

[root@server-f33 ds]# dsconf standalone1 backend import userRoot /var/lib/dirsrv/slapd-standalone1/ldif/syntax_err2.ldif
The import task has finished successfully
[root@server-f33 ds]# dsconf standalone1 backend import userRoot /var/lib/dirsrv/slapd-standalone1/ldif/syntax_err2.ldif
The import task has finished successfully
[root@server-f33 ds]# dsconf standalone1 backend import userRoot /var/lib/dirsrv/slapd-standalone1/ldif/syntax_err2.ldif
The import task has finished successfully, with warning code 8, check the logs for more detail
[root@server-f33 ds]# dsconf standalone1 backend import userRoot /var/lib/dirsrv/slapd-standalone1/ldif/syntax_err2.ldif
The import task has finished successfully, with warning code 8, check the logs for more detail
[root@server-f33 ds]# dsconf standalone1 backend import userRoot /var/lib/dirsrv/slapd-standalone1/ldif/syntax_err2.ldif
The import task has finished successfully


After adding this snippet from import_producer https://github.com/389ds/389-ds-base/pull/4476/files#diff-5e506a7236cddc035908095afb6a8a7b9a40a5062c0b4c3860352915ff915bc0 to import_foreman it seems to be always produce a warning.

Comment 3 mreynolds 2021-04-20 14:12:50 UTC
This is a duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=1627645

Viktor, that diff shows the old change.  Did you "remove" it from the producer into the foreman, or just copy it to the foreman?

Comment 4 Viktor Ashirov 2021-04-20 15:10:22 UTC
(In reply to mreynolds from comment #3)
> This is a duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=1627645
I don't think it's a duplicate, but rather a missed corner case.

> 
> Viktor, that diff shows the old change.  Did you "remove" it from the
> producer into the foreman, or just copy it to the foreman?

This is the diff, but I'm not sure if this is the right fix. But at least I'm getting a consistent warning when there are skipped entries.

diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import_threads.c b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import_threads.c
index b02b17f49..d0dd4a69f 100644
--- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import_threads.c
+++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_import_threads.c
@@ -2767,6 +2767,11 @@ import_foreman(void *param)
         if (job->flags & FLAG_ABORT) {
             goto error;
         }
+        /* capture skipped entry warnings for this task */
+        if((job) && (job->skipped)) {
+            slapi_task_set_warning(job->task, WARN_SKIPPED_IMPORT_ENTRY);
+        }
+
     }
 
     slapi_pblock_destroy(pb);

Comment 5 Jamie Chapman 2021-04-22 22:11:06 UTC
Hi Viktor,

Your fix is 100% correct.

The initial commit that addressed an ldif import with skipped entries and no warning message focused on attribute syntax and schema violation, not a missing parent entry. The import_producer thread parses the import files, checking for schema and syntax violations, while the import_foreman thread catches a missing parent entry.

I will commit your change and cherry pick it to the required branches.

Thanks

Comment 9 bsmejkal 2021-09-03 11:23:38 UTC
Build tested:
389-ds-base-1.4.3.26-1.module+el8dsrv+12420+cb9f0071.x86_64

# dsconf -D "cn=Directory Manager" ldap://localhost:389 backend import userroot /var/lib/dirsrv/slapd-localhost/ldif/example.ldif
Enter password for cn=Directory Manager on ldap://localhost:389: 
The import task has finished successfully, with warning code 8, check the logs for more detail

A warning is displayed, marking as VERIFIED.

Comment 11 errata-xmlrpc 2021-10-25 06:36:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Low: redhat-ds:11 security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:3955