I have a merge replication and I am worried that the cleanup of metadata might not be enough. I have a retention period of 60 days and I can see thet the metadatacleanup-job do remove rows i msmege_genhistory that are older but only for rows that has the right guid in pubid. most of the rows, about 1,6 million, has the value NULL in pubid and I cannot figure out why. does anybody know why there is so many null-values?
I have found out that since i use anonymous subscribers the publication will take ownership of all changes and it will not set a pubid for its changes. the only row that the subscriber adds is a row with artnick = 0. So if the subscriber adds changes the subscriber will only have one row and it will have a valid guid for the publication but the row does not point to any changes. instead the publication will add the changes as if the originated there.
The problem with the metadata cleanup was not related to the null values, it was orphaned subscriptions. If an anonymous subscription is created from one of our handheld devices and is not synced, it caused the cleanup to exclude generations. This is added with sp2 in sql2012 and the cleanup creates a list of excluded generations that are "active" the problem is that if a subscription in sysmergesubscriptions has null in last_local_sentgen it will add all generations between 1 and sentgen to the exclude-list and the metadata does not get cleaned. I have tried to remove these subscriptions in my test environment and now i can see the cleaning is being run properly. I can also see that this can also happen if a subscription-creation does timeout. The subscription can be created but the database in the handheld is not downloaded the subscription becomes orphaned and never synced.
Hope this helps someone.