Bug 1044153

Summary: mods optimizer
Product: Red Hat Enterprise Linux 7 Reporter: Nathan Kinder <nkinder>
Component: 389-ds-baseAssignee: Rich Megginson <rmeggins>
Status: CLOSED ERRATA QA Contact: Viktor Ashirov <vashirov>
Severity: unspecified Docs Contact:
Priority: low    
Version: 7.0CC: amsharma, mreynolds, nhosoi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 389-ds-base-1.3.3.1-1.el7 Doc Type: Bug Fix
Doc Text:
Cause: a Consequence: Fix: Result:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 09:31:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nathan Kinder 2013-12-17 21:30:36 UTC
This bug is created as a clone of upstream ticket:
https://fedorahosted.org/389/ticket/411

Comparing the following 2 mods in one modify, the first one is much faster.
Tested wit 10K values, the first case took 23 sec. vs. the second 80 sec.
{{{
mods[0].mod_op: LDAP_MOD_ADD
mods[0].mod_type: uniqueMember
mods[0].mod_values: <value_0>
                    <value_1>
                       ...
                    <value_N>

mods[0].mod_op: LDAP_MOD_ADD
mods[0].mod_type: uniqueMember
mods[0].mod_values: <value_0>
mods[1].mod_op: LDAP_MOD_ADD
mods[1].mod_type: uniqueMember
mods[1]mod_values: <value_1>
         ...
mods[N].mod_op: LDAP_MOD_ADD
mods[N].mod_type: uniqueMember
mods[N]mod_values: <value_N>
}}}

We may be able to introduce mods optimizer for some cases like the above.

Note: there are some operations which should not be optimized/cancelled.
For instance, mods could be used for check-and-increment as follows.  In the example, if foo=1 does not exist, the modify should fail and the next add should not happen.
{{{
mods[0].mod_op: LDAP_MOD_DELETE
mods[0].mod_type: foo
mods[0].mod_values: 1
mods[1].mod_op: LDAP_MOD_ADD
mods[1].mod_type: foo
mods[1]mod_values: 2
}}}

Comment 3 mreynolds 2014-10-23 18:17:30 UTC
Verification Steps

[1]  Install DS
[2]  Enable "audit" logging

# ldapmodify ...
dn: cn=config
changetype: modify
replace: nsslapd-auditlog-logging-enabled
nsslapd-auditlog-logging-enabled: on

[3] Add an entry:

dn: uid=user,dc=example,dc=com
uid: user
givenName: user
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetorgperson
sn: user
cn: user
description: 1
description: 2
description: 3

[4]  Remove each description attribute separately

# ldapmodify ...
dn: uid=user,dc=example,dc=com
changetype: modify
delete: description
description: 1
-
delete: description
description: 2
-
delete: description
description: 3

Internally it will get converted to the following format - which is much more efficient:

dn: uid=user,dc=example,dc=com
changetype: modify
delete: description
description: 1
description: 2
description: 3

[5]  Verify that this is how the modify operation appears in the audit log:

------------------------------------------
time: 20141023140935
dn: uid=user,dc=example,dc=com
changetype: modify
delete: description
description: 1
description: 2
description: 3
-
replace: modifiersname
modifiersname: cn=directory manager
-
replace: modifytimestamp
modifytimestamp: 20141023180935Z
-
------------------------------------------

Comment 4 Amita Sharma 2015-01-07 07:25:39 UTC
[root@dhcp201-126 export]# ldapmodify -a -p 389 -h localhost -D "cn=Directory Manager" -w Secret123 << EOF> dn: cn=config
> changetype: modify
> replace: nsslapd-auditlog-logging-enabled
> nsslapd-auditlog-logging-enabled: on
> EOF
modifying entry "cn=config"

[root@dhcp201-126 export]# ldapmodify -a -p 389 -h localhost -D "cn=Directory Manager" -w Secret123 << EOF
> dn: uid=user,dc=example,dc=com
> uid: user
> givenName: user
> objectClass: top
> objectClass: person
> objectClass: organizationalPerson
> objectClass: inetorgperson
> sn: user
> cn: user
> description: 1
> description: 2
> description: 3
> EOF
adding new entry "uid=user,dc=example,dc=com"

[root@dhcp201-126 export]# ldapmodify -a -p 389 -h localhost -D "cn=Directory Manager" -w Secret123 << EOF
> dn: uid=user,dc=example,dc=com
> changetype: modify
> delete: description
> description: 1
> -
> delete: description
> description: 2
> -
> delete: description
> description: 3
> EOF
modifying entry "uid=user,dc=example,dc=com"

[root@dhcp201-126 export]# tail -f /var/log/dirsrv/slapd-dhcp201-126/audit
description: 2
description: 3
-
replace: modifiersname
modifiersname: cn=directory manager
-
replace: modifytimestamp
modifytimestamp: 20150107072453Z
-

Marking as VERIFIED.

Comment 6 errata-xmlrpc 2015-03-05 09:31:43 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, 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://rhn.redhat.com/errata/RHSA-2015-0416.html