OrleansContrib/Orleans.Providers.MongoDB

CleanupDefunctSiloEntries broken for MultipleMembershipCollection

nkindberg opened this issue · 0 comments

We are using MongoDBMembershipStrategy.Muiltiple and noticed that we have a large number of defunct entries accumulating in the membership table which aren't getting cleaned-up as expected.

I believe this is related to DateTime vs. DateTimeOffset issues in the DeleteManyAsync call.

public Task CleanupDefunctSiloEntries(string deploymentId, DateTimeOffset beforeDate)
{
return Collection.DeleteManyAsync(x => x.DeploymentId == deploymentId && x.Status == (int)SiloStatus.Dead && x.Timestamp < beforeDate);
}

x.Timestamp is a DateTime while beforeDate is a DateTimeOffset. The comparison between the two results in an implicit conversion to DateTimeOffset and a query filter like this being generated:

{{ "DeploymentId" : "My-Deployment-Id", "Status" : 6, "Timestamp" : { "$lt" : [NumberLong("637852876860000000"), 0] } }}

Zero results will be returned by this query because the DateTimeOffset is being converted to an array which cannot be compared against the date-formatted Timestamp field.