dapr / dapr/components-contrib
Cosmos DB: Query API not working if there's more than 1 partition
- Dominant language
- Go
- Stars
- 602
- Forks
- 580
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 6
Description
> This issue was reported by a user via Microsoft Support. The findings are reported below
It seems the issue occur when Cosmos DB has multi partitions.
(1) Create local Dapr environment and configure state store to cosmos db.
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.azure.cosmosdb
version: v1
metadata:
- name: url
value: https://something.documents.azure.com:443/
- name: masterKey
value: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: database
value: db
- name: collection
value: collection
```
(2) Configure Cosmos DB scale to use multiple partitions. Setting the throughput to Manual: 11000.

(3) After setting (2), wait about 30 minutes, as it takes time for the partitions to actually scale out.
(4) Then run dapr.
(5) Run the following API.
https://docs.dapr.io/reference/api/state_api/#query-state
You can see the following error.
```
PS C:\Users\toruita> Invoke-WebRequest -Method Post -Headers @{"Content-type"="application/json"} -Uri 'http://localhost:3500/v1.0-alpha1/state/statestore/query?metadata.contentType=application/json' -Body '{}'
Invoke-WebRequest : {"errorCode":"ERR_STATE_QUERY","message":"failed query in state store statestore: context canceled"}
???? ?:1 ??:1
+ Invoke-WebRequest -Method Post -Headers @{"Content-type"="application ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ([System.Net](http://system.net/).HttpWebRequest:HttpWebRequest) [Invoke-WebRequest]?WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand----```
Contributor guide
Assessment
This issue has not been assessed yet.