locked
Bug in Cleanup with more than 1 overlapping scope RRS feed

  • Question

  • Hello,

    I have found a bug when trying to perform metadata cleanup using ADO.NET (non-SQL-Server) providers.

    Situation: I have a table, one of its fields serves as a filter (say "country"). I have 'n' scopes (say 3), one per country.

    When I try to clean up the metadata, there are 3 scopes. The cleanup phase works as expected, however, when "Writing cleanup timestamp for scope using command", only one of the scopes is updated, and the others are not.

    I have traced this using Reflector into a bug in Microsoft.Synchronization.Data.DbSyncScopeHandler.WriteCleanupTimestampForOverlappingScopes. In short:

     

    bool flag = false;
    foreach (DictionaryEntry entry in cleanupTSForOverlappingScopes)
    {
     // ...
     while (!flag) {
      // execute command to update scope
      int count = ...;
      flag = count > 0;
     }
    }
    

     

    There are in fact two bugs in that code: if the count is 0, there's an infinite loop and the process never ends (I tested it!), and the second problem is, if flag is set to true after the first update, it is never reset, so the other scopes don't have even a chance to get updated!

    This is a serious bug for me, as my scopes don't get the "outdated" scope, and subsequent syncs lose changes! And it's as easy to solve as moving the "flag = false" sentence to *inside* the foreach!

    I'm using Sync Fx 2.1...  Any chance I can workaround this problem or get it fixed? Until then, I just cannot clean up the metadata of my whole database!

    Thanks in advance, and best regards, Fernando Nájera

    • Edited by fernandonajera Wednesday, March 16, 2011 10:18 AM Formatting the code again
    Wednesday, March 16, 2011 10:14 AM