Ticket #47809 - find a way to remove replication plugin errors messages "changelog iteration code returned a dummy entry with csn %s, skipping ..."

Description:
1) Can't locate CSN %s in the changelog (DB rc=%d).
   Print the message once per one missing CSN.
2) changelog iteration code returned a dummy entry with csn %s, skipping ...
   Downgrade the log level to replication log level (SLAPI_LOG_REPL).

https://fedorahosted.org/389/ticket/47809

Reviewed by rmeggins@redhat.com (Thanks, Rich!)
(cherry picked from commit 6a1b10db6d41be9e3aadf6f7cbb18aaf4d00e87b)
Ticket 47815 - Add operations rejected by betxn plugins remain in cache

Bug Description:  When an add operation is rejected by a betxn post plugin
                  the "adding" entry is removed the cache(previously added
                  tentatively), it gets re-added back to the entry cache
                  when we call betxn post plugins just before the abort.

Fix Description:  Remove the entry from the cache when the 2nd run of
                  the betxn postop plugins fails(just before we abort
                  the transaction).

https://fedorahosted.org/389/ticket/47815

valgrind: passed
jenkins: passed

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit fe81bda5f2f2cef647cedadf9ba442f8b7851973)
Ticket 47817 - The error result text message should be obtained just prior to sending result

Bug Description:  We do not get pblock result message after the betxn postop plugins
                  are called.  If a betxn plugin modified the ldap result message, then
                  when the backend returns the results it does an invalid read on the
                  old pointer of the old result message.

Fix Description:  Get the result message after we call the betxn postop plugins.

https://fedorahosted.org/389/ticket/47817

jenkins: passed

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit 68e766891d1067b2b86bd48bfa16d0837fa5a737)
Ticket 47815 - add lib389 test

Description:  Add a lib389 test for ticket 47815

https://fedorahosted.org/389/ticket/47815

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit b3aae6b16bb99eec56d2bda84ac8fc9a979b354e)
Ticket #47831 - server restart wipes out index config if there is a default index

https://fedorahosted.org/389/ticket/47831
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.3.2
Fix Description: In ldbm_instance_index_config_enable_index(), only call
the function ldbm_index_parse_entry() if the index does not exist.  Instead,
get the name of the index from the "cn" attribute of the entry, and use
ainfo_get() to get the index.  If this returns NULL, then call
ldbm_index_parse_entry() to create and parse the index.
Platforms tested: Fedora 20
Flag Day: no
Doc impact: no

(cherry picked from commit 5c5c9603946ecb89fb17df665a95aa3ce75e01de)
Ticket 47821 - deref plugin cannot handle complex acis

Bug Description:  the deref plugin does not return attributes if
			the access depends on rules requireing
			the entry

Fix Description:   do the access check after the entry is retrieved

https://fedorahosted.org/389/ticket/47821

Reviewed by: mark, thanks
Ticket #47750 - Creating a glue fails if one above level is a conflict or missing

Bug description: https://fedorahosted.org/389/ticket/47750#comment:16

Fix description: The logic in slapi_is_special_rdn to check if the
RDN is a tombstone or not had a problem.  Even if the first part of
RDN is not nsuniqueid=<UNIQUE_ID>, it was returning true.  In this
patch, code to check the case is added and it returns false if the
first part of RDN is not  nsuniqueid=<UNIQUE_ID>.

Reviewed by mreynolds@redhat.com and rmeggins@redhat.com (Thank you,
Mark and Rich!!)
(cherry picked from commit 286559dac7a968faa0102f0165ba56892795b269)
Ticket #47750 - Creating a glue fails if one above level is a conflict or missing

Description: This commit accidentally removed the code to decrementing
the reference count for the backend instance.
  Commit: 160cb3f686e433c01532d28770b2977ec957e73e
  Ticket #47750 - Creating a glue fails if one above level is a conflict or missing;
Thanks to mreynolds@redhat.com for finding this out.
(cherry picked from commit 788a48fa98bb33a6601d7a198aa63b46d12ad78d)
Ticket #47763 - winsync plugin modify is broken

Description: Thanks to Carsten Grzemba for the patch.  Made minimum
changes such as replacing the direct access to the bv_len in Slapi_Value
with slapi_value_get_length.

Note: Regarding attr_compare_equal, since there is no strong reason
to switch to this new attr_compare_equal, we continue using the original
code.  The newly provided code is in "#if 0".

https://fedorahosted.org/389/ticket/47763

Reviewed by rmeggins@redhat.com (Thanks, Rich!)

(cherry picked from commit b6b7199470671315d693ddec8db7c4ffbc4a1ee8)
Ticket #47750 - Creating a glue fails if one above level is a conflict or missing

Description: This commit accidentally removed the code to add entry
back to cache if it was replaced:
  Commit: 160cb3f686e433c01532d28770b2977ec957e73e
  Ticket #47750 - Creating a glue fails if one above level is a conflict or missing;

Note: This is the cause of Ticket #47830 - usn tombstone entry not properly created
(cherry picked from commit 98cf4246b6e5c8a99a1e9063eca9aad9560185bd)
Bump version to 1.3.2.18
Ticket #47839 - 389-ds production segfault: __memcpy_sse2_unaligned...

Bug description: modrdn2reple (retrocl_po.c) sets the given mods
to the changelog entry with "changes" attribute type if it includes
modifiersname, modifytimestamp, creatorsname, createtimestamp. When
the modrdn is internally initiated and passed mods do not include
the attributes (modifiersname, etc.), make_changes_string returns
empty lenstr.  There were 2 issues:
1) there was nothing to add if lenstr was empty, but it was added.
2) there was a bug to set the length +1 even though the length was 0.

Fix description:
1) If there is nothing to add to the change attribute, skip calling
   slapi_entry_add_values.
2) Remove adding "+1" for '\0' from the value length: val.bv_len.

https://fedorahosted.org/389/ticket/47839

Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
(cherry picked from commit 46a32692a8dd2b770e038b6418a8ba32c0099b8a)
Ticket 47779 - Potential deadlock after startup if a dna configuration change is made

Bug Description:  DNA delays the shared server configuration creation
                  until 30 seconds after startup to allow other plugins
                  to start (replication and retro cl).  This delayed config
                  event starts a transaction while holding the read lock
                  which can lead to a deadlock.

Fix Description:  Make a one time copy of the shared server config for
                  the config update event so we don't need to hold any
                  locks while starting the backend transaction.

https://fedorahosted.org/389/ticket/47779

valgrind: passed
jenkins: passed

Reviewed by: rmeggins(Thanks!)

(cherry picked from commit badd35439b8ec5e7ccac070e5c8ef66565f75866)
Bump version to 1.3.2.19
Ticket 47781 - Server deadlock if online import started while
 server is under load

Bug Description:  Online import of ldif containing repl data deadlocks server.

Fix Description:  Replace the replica lock(PRLock) with a PRMonitor reentrant lock.

https://fedorahosted.org/389/ticket/47781

jenkins: passed

Reviewed by: nhosoi(Thanks!)

(cherry picked from commit 0e11f7182a3b8f42f90ec8335936965b88a11336)
Ticket #47692 single valued attribute replicated ADD does not work

https://fedorahosted.org/389/ticket/47692
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.3.2
Fix Description: Previous fix was incomplete - needed to move the
deleted attribute to the present attribute list.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no

(cherry picked from commit 4b54366593e50d71239588343f532eab39ef56e0)
Ticket #47834 - Tombstone_to_glue: if parents are also converted to glue, the target entry's DN must be adjusted.

Bug description: tombstone_to_glue resolves parents recursively if
they are also a tombstone entry, which may change the DN of the
target entry, but the DN change was not adjusted.

Fix description: Added a new argument newparentdn to tombstone_to_
glue_resolve_parent to return the new parent DN if it has been updated.
If a new parent DN is returned, set it to the target DN.

This patch also adds a cache debugging function: check_entry_cache,
which is disabled by default (in #ifdef CACHE_DEBUG)

Note: this bug is a left over of ticket #47750.

https://fedorahosted.org/389/ticket/47834

Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
(cherry picked from commit 708a56b8d524131362e2d71b7fbc2eb257075e14)
Ticket 47797 - DB deadlock when two threads (on separated backend) try to record changes in retroCL

Bug Description:
	The DB is opened so that if a db lock can not be granted it does not wait and returns DB_DEADLOCK
	In some part of code, the server just loops retrying where it should abort the txn (and release the locks
	it may hold) and retry with a different txn

Fix Description:
	If DB_LOCK_DEADLOCK is returned, the correct course of action is to abort the (possibly nested) transaction
	and retry the database operation
		file:///usr/share/doc/db4-devel-4.7.25/gsg_txn/C/lockingsubsystem.html

		Resolving Deadlocks

		When DB determines that a deadlock has occurred, it will select a thread of control to
		resolve the deadlock and then return DB_LOCK_DEADLOCK to that thread.
		If a deadlock is detected, the thread must:
		    Cease all read and write operations.
		    Close all open cursors.
		    Abort the transaction.
		    Optionally retry the operation. If your application retries deadlocked operations, the new attempt must be made using a new transaction.

https://fedorahosted.org/389/ticket/47797

Reviewed by: Rich and Mark (Thanks)

Platforms tested: F17/F20 (ipa unit tests)

Flag Day: no

Doc impact: no
Ticket 47797 - fix the indentation

Bug Description:
	Indentation of some parts of the fix was 8 spaces rather than 4

Fix Description:

https://fedorahosted.org/389/ticket/47797

Reviewed by: Mark Reynolds

Platforms tested: f17

Flag Day: no

Doc impact: no
Ticket #47834 - Tombstone_to_glue: if parents are also converted to glue, the target entry's DN must be adjusted.

Description: commit 708a56b8d524131362e2d71b7fbc2eb257075e14 breaks
the CI testcase 47808.  Undo the change made in op_shared_add (add.c).

https://fedorahosted.org/389/ticket/47834#comment:9
(cherry picked from commit 6d38125d0e848e43788d2b7e4f5b85613b60448c)