imranmomin/Hangfire.AzureDocumentDB

Support for partitioned collection

Closed this issue · 8 comments

Since non-partitioned collections is deprecated, support for partitioning is now needed.

We lowered the minimum throughput for partitioned containers to 400 RU/s, removing the only drawback partitioned containers had.

We are planning to deprecate ability to create non-partitioned containers, as they do not allow you to scale elastically. If for some reason you still need a container without partition key, you can use our SDKs to create one.

I made a local fork half a year ago, and if I recall correctly, it was only minor things that required changes to enable partitioning support. The most obvious is the error you get when using a partitioned collection (with partition "/type"):

Upserts for scripts in collections with multiple partitions are not supported

Is this something that is planned?

No plans yet. But open to PR. Can you submit the PR

@hjalle
I was facing this partition issue today while I was trying to connect Hangfire to a collection I defined upfront in the Azure Portal.

The only way to get Hangfire up and running was to let Hangfire do the setup of the DB/collection.

Nevertheless I ran into a problem when I tried to access the dashboard. #35

@hjalle @erikpaperik I have merged the #35 pull-request. I have released the package on nuget

Please use the nuget package

PM> Install-Package Hangfire.AzureDocumentDB -Version 3.0.1-develop-1

Let me know how it goes, so I can publish the final release 3.0.1

@hjalle @erikpaperik how did the testing go.

Also should we pass FeedOption with EnableCrossPartitionQuery wherever I'm using QueryText instead of LINQ

@imranmomin

Thx for your fast response!
I'm not sure if I can test the develop-1 NuGet this week but I'll definitly write you within the upcomming week.

Best
Erik

@imranmomin

I've just tried the develop-1 NuGet Version in Azure and everything worked as expected!

Best regards
Erik

@erikpaperik thanks for taking time to test.

So should we also send the FeedOption wherever I'm using the RAW sql for query

private long GetNumberOfJobsByStateName(string state)
{
SqlQuerySpec sql = new SqlQuerySpec
{
QueryText = "SELECT TOP 1 VALUE COUNT(1) FROM doc WHERE doc.type = @type AND doc.state_name = @state",
Parameters = new SqlParameterCollection
{
new SqlParameter("@state", state),
new SqlParameter("@type", DocumentTypes.Job)
}
};
return storage.Client.CreateDocumentQuery<long>(storage.CollectionUri, sql)
.ToQueryResult()
.FirstOrDefault();
}

@erikpaperik @hjalle thanks for reporting the issue. I have released the 3.0.1

Also, would you guys like to be collaborator for the project.