locked
Some records are not downloaded in filtered scope RRS feed

  • Question

  • Hi,

    My app looks like this: Server: SQL-Server, clients using SQL Server CE. The sync is done with a WCF-sync service hosted in IIS. I am using Sync Framework 2.1

    My app has three scopes: 1) Download: data shared among all users, 2) Download: Filtered data for the specific user 3) Upload: new data (orders) created by the user.

    The SQL-DB receives it's data from an Import of XML-Files on a daily basis. Recently there have been many switches of records from one user to another. (E.g. a customer formerly belonging to user "12345" now belongs to "54321")

    The problem I am experiencing is in #2, where some users don't receive all records that are stored in the SQL-DB. Most of the users receive all of their records (as expected), but some not. I wonder what the reason for that can be?

    Can this be linked to the changes made to values in the column used to filter the data for the users?

    I tried to start with a blank client CE-Database, same result. (BTW, is that what is called reinitialize the client, or does reintialize the client mean something else?)

    Can the reason for that be, that I have not yet implemented Metadata Cleanup? As far as I understand Metadata Cleanup (http://msdn.microsoft.com/en-us/library/ee617373.aspx) this is only relevant for deleted records. As in my setup records are never deleted (instead I use a column to mark the record as deleted) I thought that Metadata Cleanup makes no sense. Is that right or did I misunderstand the concept of Metadata Cleanup?

    Thanks
    Christian
    Wednesday, January 25, 2012 10:16 AM

Answers

  • Sync Framework doesnt support "partition re-alignment" or rows going in and out of scope.

    in your example, a customer which was previously with user 12345 and then changed to user 54321 will not be received by user 54321. while the metadata reflects that this row is updated, even if the change is detected, the application of the row to 54321 will fail because there is no row to update on the client anyway. likewise, the previously downloaded row to user 12345 will remain with the client since the update will not be cascaded to user 12345 because the row is now out of the filter for user 12345. so your user 12345 will have that customer even though its already with 54321.

    if there's only a handful of these rows, try deleting and reinserting them.

    • Marked as answer by chl-h Friday, January 27, 2012 10:58 AM
    Wednesday, January 25, 2012 2:32 PM

All replies

  • Sync Framework doesnt support "partition re-alignment" or rows going in and out of scope.

    in your example, a customer which was previously with user 12345 and then changed to user 54321 will not be received by user 54321. while the metadata reflects that this row is updated, even if the change is detected, the application of the row to 54321 will fail because there is no row to update on the client anyway. likewise, the previously downloaded row to user 12345 will remain with the client since the update will not be cascaded to user 12345 because the row is now out of the filter for user 12345. so your user 12345 will have that customer even though its already with 54321.

    if there's only a handful of these rows, try deleting and reinserting them.

    • Marked as answer by chl-h Friday, January 27, 2012 10:58 AM
    Wednesday, January 25, 2012 2:32 PM
  • Hi JuneT,

    thanks very much for your answer.

    So on the server side I would do check if a user for a record has changed, and if so I delete that record (and all records in related tables) and then reinsert that record.

    What could I do on the client side for the orphaned records (the ones that now belong to another user)?

    Will the delete on the server side be picked up from the client and the record is deleted on the next sync automatically?

    I also assume that in this scenario MetaData Cleanup should be implemented.

    Thanks
    Christian
    Wednesday, January 25, 2012 5:41 PM
  • the delete will be picked up and will be applied to the client when it syncs thus removing the out-of-scope row from the client.

    yes, you should implement metadata cleanup.

    btw, is the filter column the PK?

    Thursday, January 26, 2012 2:25 AM
  • Hi JuneT,

    >> the delete will be picked up and will be applied to the client when it syncs thus removing the out-of-scope row from the client.

    Very good, I was hoping for that!

    >> yes, you should implement metadata cleanup.

    Lets say I can assume that the users sync at least once a month so I would set the retention days to 30 and will not run into exception of type DbOutdatedSyncException. Or otherwise I should add error handling for that type of exception. 

    >> btw, is the filter column the PK?

    NO.

    thanks

    Christian

    Thursday, January 26, 2012 9:46 AM
  • if you're not doing that much deletes, i would even set the metadata retention higher.
    Friday, January 27, 2012 12:56 AM
  • Hi JuneT,

    Thanks again for your help. I will set set the retention days to something like 90.

    Christian

     

    Friday, January 27, 2012 10:58 AM