nickva commented on issue #4640:
URL: https://github.com/apache/couchdb/issues/4640#issuecomment-1593507302

   Thanks for creating the issue @jcoglan !
   
   > to the captured seq value returns results out of order
   
   How did we determine they are out of order? Is that based on the `N-...` 
first part of the sequence number?
   
   > The descending value of the numeric part of the seq value looked curious 
to me so I ran these values through a parser tool and obtained:
   ```
   original: 
'30-g1AAAAKVeJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rgzmRJRcowJ6alGySlmqJTQMeY5IUgGSSPcykDKYUBtbigpzMErCZpslJZmbmBqSa6QAyMx5qJgPYJAPLRAsjcwtSTUoAmVRPVdflsQBJhgYgBTR2PshcNjRzzUxTTSzMU8gydwHE3P0InxsZJ5obmpuSZdoBiGn3qe3KBxBz_5NobhYAREXOrQ',
     parsed: [
       [ 'couchdb@localhost-00000000-1fffffff', 4 ],
       [ 'couchdb@localhost-20000000-3fffffff', 4 ],
       [ 'couchdb@localhost-40000000-5fffffff', 0 ],
       [ 'couchdb@localhost-60000000-7fffffff', 4 ],
       [ 'couchdb@localhost-80000000-9fffffff', 6 ],
       [ 'couchdb@localhost-a0000000-bfffffff', 0 ],
       [ 'couchdb@localhost-c0000000-dfffffff', 6 ],
       [ 'couchdb@localhost-e0000000-ffffffff', 6 ]
     ]
   ```
   ```
     original: 
'23-g1AAAAKBeJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rgzmRJRcowJ6alGySlmqJTQMeY5IUgGSSPdQkBohJQGMMTA1INckBZFI8ikkGlokWRuYWpJqUADKpHmoSI9ikREtTU_OkJBJNymMBkgwNQApo2HyQaWwZTCkMrMUFOZklYHPNTFNNLMxTyDJ3AcTc_Qj_Ghknmhuam5Jl2gGIafep7coHEHP_k2huFgBjZMkL',
     parsed: [
       [ 'couchdb@localhost-00000000-1fffffff', 4 ],
       [ 'couchdb@localhost-20000000-3fffffff', 0 ],
       [ 'couchdb@localhost-40000000-5fffffff', 0 ],
       [ 'couchdb@localhost-60000000-7fffffff', 1 ],
       [ 'couchdb@localhost-80000000-9fffffff', 6 ],
       [ 'couchdb@localhost-a0000000-bfffffff', 0 ],
       [ 'couchdb@localhost-c0000000-dfffffff', 6 ],
       [ 'couchdb@localhost-e0000000-ffffffff', 6 ]
     ]
   ```
   
   I think the parser tools is ignoring an important `split` marker and just 
shows the sequence number. Let's see what it's hiding:
   
   ```
   
fabric_view_changes:decode_seq(<<"30-g1AAAAKVeJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rgzmRJRcowJ6alGySlmqJTQMeY5IUgGSSPcykDKYUBtbigpzMErCZpslJZmbmBqSa6QAyMx5qJgPYJAPLRAsjcwtSTUoAmVRPVdflsQBJhgYgBTR2PshcNjRzzUxTTSzMU8gydwHE3P0InxsZJ5obmpuSZdoBiGn3qe3KBxBz_5NobhYAREXOrQ">>).
   [{couchdb@localhost,[0,536870911],
                       {4,<<"ebc4fe9">>,couchdb@localhost}},
    {couchdb@localhost,[536870912,1073741823],
                       {4,{split,<<"5cb6670">>},couchdb@localhost}},
    {couchdb@localhost,[1073741824,1610612735],
                       {0,<<"09a8278">>,couchdb@localhost}},
    {couchdb@localhost,[1610612736,2147483647],
                       {4,{split,<<"5cb6670">>},couchdb@localhost}},
    {couchdb@localhost,[2147483648,2684354559],
                       {6,{split,<<"65e487d">>},couchdb@localhost}},
    {couchdb@localhost,[2684354560,3221225471],
                       {0,<<"23a7175">>,couchdb@localhost}},
    {couchdb@localhost,[3221225472,3758096383],
                       {6,{split,<<"65e487d">>},couchdb@localhost}},
    {couchdb@localhost,[3758096384,4294967295],
                       {6,{split,<<"65e487d">>},couchdb@localhost}}]
   ```
   
   We notice how `{4,{split,<<"5cb6670">>},couchdb@localhost}}` looks a bit 
different than `{0,<<"09a8278">>,couchdb@localhost}}`. Specifically the 
`{split,<<"5cb6670">>}` part. That part shows a split "marker", that it looks 
that particular range was likely the result of a split from the original 
sequence with (Q=2) with original since seq node uuid for the now missing 
(split) range. The `4` part shows the original sequence from the Q=2 sequence.
   
   In general looking at the `N-....` is not too helpful. To make the sequences 
look "nicer" we could avoid adding the sequence to the total sum when computing 
`N` if the sequence is a split marker. That would make the `N-` value increment 
"nicer". But that value is effectively meaningless and it is thrown away when 
we parse the sequence.
   
   It would still be a nice minor ergonomic fix but so far nothing here 
violates correctness, we're not throwing changes away or returning them out of 
order.
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to