<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 05/06/2015 05:56 PM, Martin Babinsky
      wrote:<br>
    </div>
    <blockquote cite="mid:554A39BD.5060609@redhat.com" type="cite">On
      05/06/2015 04:25 PM, thierry bordaz wrote:
      <br>
      <blockquote type="cite">On 05/06/2015 03:19 PM, Martin Babinsky
        wrote:
        <br>
        <blockquote type="cite">Hello Thierry,
          <br>
          <br>
          replies are inline.
          <br>
          <br>
          On 05/06/2015 02:22 PM, thierry bordaz wrote:
          <br>
          <blockquote type="cite">On 05/06/2015 01:54 PM, Martin
            Babinsky wrote:
            <br>
            <blockquote type="cite">The attached patch tries to fix
              <br>
              <a class="moz-txt-link-freetext" href="https://fedorahosted.org/freeipa/ticket/4378">https://fedorahosted.org/freeipa/ticket/4378</a>
              <br>
              <br>
              After discussion with Thierry we concluded that while this
              issue is
              <br>
              more complex than it seems, the transition from REPLACE to
              DEL/ADD
              <br>
              operations when updating nsDS5ReplicaId should suffice for
              this ticket.
              <br>
              <br>
            </blockquote>
            Hello Martin,
            <br>
            <br>
            Few comments, you are using MOD_DEL 'replicaID' with None
            value. So this
            <br>
            is going to delete all previous values and it should be
            equivalent to a
            <br>
            MOD_REPL.
            <br>
            I was thinking you wanted to retrieve the id_value and call
            MOD_DEL
            <br>
            'replicaID' <current_value>. So that if by the time
            you fetched the
            <br>
            replicaId, an other replica updated the replicaId, the
            MOD_DEL/MOD_ADD
            <br>
            would fail and you need a new iteration.
            <br>
            <br>
          </blockquote>
          Sorry I didn't know you can MOD_DEL a particular value (I'm
          LDAP noob
          <br>
          I know). Will fix this.
          <br>
          <blockquote type="cite">If replicaId was multi-valued and you
            want to make it single valued, you
            <br>
            may want to do create a more complex MOD (e.g.
            (ldap.MOD_DELETE,
            <br>
            'nsDS5ReplicaId', str(value1), (ldap.MOD_DELETE,
            'nsDS5ReplicaId',
            <br>
            str(value2)...)
            <br>
            <br>
          </blockquote>
          AFAIK ReplicaId is single-valued (looking at the schema right
          now) so
          <br>
          this shouldn't be problem.
          <br>
          <blockquote type="cite">If it is updating successfully do you
            want to return 'retval' or
            <br>
            'retval+1' ?
            <br>
            <br>
            If several replicas try to update the replicaId of the
            master and the
            <br>
            current replicaId is 1000.
            <br>
            Replica1 successfully updates the replicaId and gets 1001 as
            the new
            <br>
            value.
            <br>
            Replica2 successfully updates the replicaId and gets 1002.
            <br>
            The final value on master will be 1002, but replica1 will
            assum it is
            <br>
            1001. Is it a problem ?
            <br>
            <br>
          </blockquote>
          I studied the code in the master branch and IIUC (and please
          correct
          <br>
          me if I got this wrong) nsDS5ReplicaId attribute in
          <br>
          'cn=replication,cn=etc,$SUFFIX' represents replicaID of the
          _next_
          <br>
          replica that will be installed.
          <br>
          <br>
          So if a replica is installed, it sets the current value of
          <br>
          nsDS5ReplicaId as its replica ID (the function returns
          'retval') and
          <br>
          then increments it in 'cn=replication,cn=etc,$SUFFIX' entry
          ('retval +
          <br>
          1' is written to master) so that the next installed replica
          fetches
          <br>
          this updated value.
          <br>
          <br>
          So the case you described should be the expected behavior. To
          change
          <br>
          it would require different patch IMHO.
          <br>
        </blockquote>
        <br>
        Thank for your precious explanations, in fact the value in
        <br>
        'cn=replication,cn=etc,SUFFIX' is the next available replicaId
        value and
        <br>
        is the centralized mechanism that assign unique replicaID.
        <br>
        <br>
        The risk was that several replica pick the same value. So yes it
        is
        <br>
        important that the MOD_DEL specifies the previously read value
        so that
        <br>
        the test/set will be atomic. If several replicas read the same
        value,
        <br>
        only the faster one will use it to install the replica.
        <br>
        <br>
        thanks
        <br>
        thierry
        <br>
        <blockquote type="cite">
          <blockquote type="cite">thanks
            <br>
            thierry
            <br>
          </blockquote>
          <br>
          <br>
        </blockquote>
        <br>
      </blockquote>
      <br>
      Attaching updated patch with fixed MOD_DELETE operation.
      <br>
      <br>
    </blockquote>
    <br>
    Hi Martin,<br>
    <br>
    The fix looks good to me except I think you need to do
    (ldap.MOD_DELETE, 'nsDS5ReplicaId', <b>str(</b>retval<b>)</b>)<br>
    <br>
    thanks<br>
    thierry<br>
  </body>
</html>