#51204 Issue 49300 - entryUSN is duplicated after memberOf operation
Closed by spichugi. Opened by spichugi.
spichugi/389-ds-base i49300  into  master

Download 51204.patch

Bug Description: When we assign a member to a group we have two
oprations - group modification and user modification.
As a result, they both have the same entryUSN because USN Plugin
assigns entryUSN value in bepreop but increments the counter
in the postop and a lot of things can happen in between.

Fix Description: Increment the counter in bepreop together with
entryUSN assignment. Also, decrement the counter in bepostop if
the failuer has happened.
Add test suite to cover the change.

https://pagure.io/389-ds-base/issue/49300

Reviewed by: ?

This check is done after two direct updates (and more nested). Why not doing the checking after each individual direct update.
After the first update mem1 != group1
after second update mem1 != mem2 != group1 != group2

The test is good. IMHO it could be extended if you do a successful update (a), then a failing one (b) then a successful update (c).
entryusn after (c) should be entryusn after(a) + 1. (no hole)

I think it should be also incremented in _usn_add_next_usn

In case of failure, counter is decrease in betxnpostop add/mod/modrdn/del

It is increased in bepreop mod/modrdn (_usn_mod_next_usn). I think it should also be increased in _usn_add_next_usn (betxnpreop add/del).

Note that only DEL creating a tombstone (SLAPI_PLUGIN_BE_TXN_PRE_DELETE_TOMBSTONE_FN) increases the counter (betxnpeop DEL). in case of failure we should decrease the counter only if DEL attempted to create a tombstone. It is corner case. At the moment I do not know an easy way to check that unless looking for SLAPI_ATTR_VALUE_TOMBSTONE in entry objectclass.

Except those remarks the overall patch looks very nice :)

rebased onto 1384e41bc32cfdd68af28d705f30cbb1e493da79

Very accurate feedback, thank you!
Please, check.

P.S. I am not sure if I fully understood the part with DEL.

rebased onto 735e162ea87fab50720f25a43ef5aeb411760213

As per IRC discussion, I've updated the delete part to decrement the counter only for TXN operation.

Thank you, Thierry!
Please, review.

The overall patch looks very good. I have a minor comment regarding the naming of the pblock field. In the patch it looks like a callback level while we just need a hack to transfer an information from preop to postop without adding a callback level.
I would suggest something like SLAPI_USN_INCREMENT_FOR_TOMBSTONE. It may be defined close to misc definitions like SLAPI_PAGED_RESULTS_COOKIE.

I would prefer to have this field in slapi_pblock_intop (similar to pb_paged_results_cookie)

rebased onto dc5fe10e4c4ae30aaed25023c9c89e6e653b482d

Sure, sounds good!
Fixed. Please, review.

I would prefer more systematic check. It is easier to understand the expected behavior (all USN should differ)
mem1!=mem2
mem1!=group1
mem1!=group2
mem2!=group1
mem2!=group2
group1!=group2

mem_1_usn and grp_1_usn are reassigned here (vs. the previous update). I would prefer you also check that the USN generated/stored (mem1/grp1) from the first update also differs from the USN generated/stored (mem1/grp1) during the second update.

Thanks @spichugi for the patch. Except those minor comments for testcase asserts the patch looks good. Feel free to push it without additional review. ACK

rebased onto ffda491f1738bde7691703369268ec1fadaadb18

Thanks! Done.

Pull-Request has been merged by spichugi

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/4257

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

Metadata