RangeOutOfOrderException using custom providers RRS feed

  • Question

  • Hi,

     I am using standard custom providers on client and server.

    In the GetChangeBatch method, I am getting a RangeOutOfOrderException on adding changes to the change batch.

    • Here are the two changes I am adding:

    AddChange id:[9f16cdcabf7446cd94e307d2face256c], createVersion: [1,201008301857254535], changeVersion:[1,201008301857254535] 

    AddChange id:[285c8a4c88544644bd518dc76ecdbb88], createVersion: [3,201008302138565115], changeVersion:[3,201008302138565115] 

    • Here is the error:

    ERROR: 2010-09-10 16:54:49:[ServerProvider] GetChangeBatch: Microsoft.Synchronization.RangeOutOfOrderException: Range was provided out of expected order. Ranges should be provided in increasing order. ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x8004100A

    • The destination sync batch parameters:

    Batch size=10; Current knowledge=[ReplicaKeyMap: [(0:7e927141a48d4687881fcd491d16455e)] ScopeRangeSet: [00000000000000000000000000000000:[(0:201009101843180297)]]]

    • The servers mapped knowledge:

    ReplicaKeyMap: [(0:e525984a905143ae9ef988b71015c6f3) (1:67986f6d59cc448f9dca4ab188b8e551) (2:049d805ff90747ae984884dd06212c77) (3:6c8a369cd4f0483886dec239337241c4) (4:326d7ffdf10a46c0afe864973545d87a) (5:7e927141a48d4687881fcd491d16455e)] ScopeRangeSet: [00000000000000000000000000000000:[(5:201009101843180297)]]

    Any help appreciated.







    Saturday, September 11, 2010 12:11 AM

All replies

  • Is it an OrderedBatch you are trying to add or an unordered batch?
    Tuesday, September 14, 2010 12:34 AM
  • Yes, I am using ordered group. The code is pretty much the standard way of GetChangeBatch, i.e.

    ChangeBatch changeBatch = new ChangeBatch(IdFormats, destinationKnowledge, ForgottenKnowledge);
    //Get the changes from source
    //Loop through and add items to change
    foreach (var item in changes)
    ItemChange itemChange = new ItemChange(IdFormats, ReplicaId, item.globalId, changeKind, item.createVersion, item.changeVersion);
    Tuesday, September 14, 2010 4:45 PM
  • Can you please make sure that the items are batched in increasing order of their globalId (i.e. every new batched item has an ID which is greater than any of the items already batched.



    Tuesday, September 14, 2010 7:30 PM
  •  My global ids are Guids, how do I impose ordering on Guids? I am adding to the batch using the increasing order of change versions.

    Tuesday, September 14, 2010 11:08 PM
  • I guess I found the answer...

    It's either by using the SyncGlobalId class (prefix + unique Guid), or by finding some way of generating a sequential Guid (either in .NET http://coderjournal.com/2010/04/creating-a-time-uuid-guid-in-net/, or by using SQL newsequentialguid )

    Is there any examples of how the prefix for SyncGlobalId is generated/used?


    Wednesday, September 15, 2010 5:38 PM
  • Hi, aryacjose.

    The prefix is a simple number (ulong). Unfortunately we do not have any specific example focused on the usage of the prefix parameter, but I think it is pretty streight forward. The only functionality of the prefix is to ensure a specific order of distinct instances of the SyncGlobalId class - items with a lower value of the prefix will be enumerated first.

    Now anyone can make distinct assumptions based on different ways they chose to implement this sorting mechanism.

    One example would be to be able to track the order in which the items have been created on a particular replica. You can have a counter (either for creates only, or just a generic one) which will always increase when an item is created. This way you will know that item with Id 555Guid1 has been created before item with Id 777Guid2  (assuming they have been created on the same replica).

    Another example would be to implement some kind of parent-child relationship between items. You will want the parent created first (so that it gets enumerated and applied first), to avoid failures (or constraint conflicts) when you try to apply children and the parent has not yet been applied.

    As a rule of thumb, if you want to use the prefix, you can use the replica's TickCount, which is an ever-increasing, positive number.


    Hope this helps. Please let me know if you encounter any issues or have any additional questions.


    Wednesday, September 22, 2010 11:06 PM