dotnet / dotnet/orleans

CosmosDB containers created without support for large PartitionKeys

Open
#9,690 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
10.9k
Forks
2.1k
Avg merge
14h 42m
Merged PRs (30d)
354

Description

Hey there,

We are currently facing an issue with the following Orleans Cosmos providers:

- Orleans.Reminders.Cosmos.CosmosReminderTable
- Orleans.Persistence.Cosmos.CosmosGrainStorage
- Orleans.Clustering.Cosmos.CosmosMembershipTable (same issue, though we don’t currently use large PartitionKeys there)

These classes create Cosmos DB containers using ContainerProperties, but for some reason `ContainerProperties.PartitionKeyDefinitionVersion` is set to null. This causes the containers to be created without support for large PartitionKeys.

Our application heavily relies on large keys, for example:
`source-mapping-state-2bb871b4-6623-40ed-998d-630a74ed5960~0postman~0account~089930a15-fd03-4616-99e7-7646d5e01067`
~`acmeincomingintegratorbuffer/8fdd4ae0-5803-4890-a385-4f4dee6a5b57/acme/partner/sourceId-3ed79f93-0c93-41f5-b453-f1f703b12010`~

Since we also store reminders in Cosmos DB, those keys can become large as well. As a result, queries to fetch reminders fan out across partitions (as far as I understand) and eventually time out because the full key was not used correctly. This happens very easily on containers with provisioned throughput set to 400 RU.

In the same solution, we also use the Microsoft Azure Cosmos SDK (v3.52.1.0) directly in a custom persistence project. There, we do not set PartitionKeyDefinitionVersion explicitly, yet large PartitionKeys work out of the box.

**Request**:
Could you either:
1. Provide a way to specify PartitionKeyDefinitionVersion (e.g., via a property on CosmosOptions), or
2. Ensure large PartitionKey support is enabled by default

Thanks a lot for looking into this!

**ContainerProperties**

Image

In our internal library (used in the same silo / Orleans project):

Image

**Edit**: Forget the part about reminders, as I just recognized that there is no way to influence the construction of the partition key for reminders and they look fine `MyApp__7DB51703`. But the request still upholds as we still face the issues with the GrainStorage (Container for the grain states).

Contributor guide

Open the contributing guide

Research direction

Start with CosmosReminderTable, CosmosGrainStorage, and CosmosMembershipTable where ContainerProperties is constructed, then trace how CosmosOptions reaches those entry points. Done means the applicable containers support large PartitionKeys by default or through the requested option, with the relevant Cosmos provider tests covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.