0
votes

While trying to register for cosmos db changefeed, ChangeFeedEventHost is throwing and error "java.lang.UnsupportedOperationException: PartitionKey value must be supplied for this operation."

https://github.com/Azure/azure-documentdb-changefeedprocessor-java/blob/master/samples/README.md

I am trying to follow this code to register for changefeed. Here is the complete stacktrace

java.lang.UnsupportedOperationException: PartitionKey value must be supplied for this operation. at com.microsoft.azure.documentdb.DocumentClient.addPartitionKeyInformation(DocumentClient.java:3346) at com.microsoft.azure.documentdb.DocumentClient.deleteDocument(DocumentClient.java:1047) at com.microsoft.azure.documentdb.changefeedprocessor.services.DocumentServices.deleteDocument(DocumentServices.java:248) at com.microsoft.azure.documentdb.changefeedprocessor.internal.documentleasestore.DocumentServiceLeaseManager.initialize(DocumentServiceLeaseManager.java:116) at com.microsoft.azure.documentdb.changefeedprocessor.ChangeFeedEventHost.initializeIntegrations(ChangeFeedEventHost.java:165) at com.microsoft.azure.documentdb.changefeedprocessor.ChangeFeedEventHost.start(ChangeFeedEventHost.java:143) at com.microsoft.azure.documentdb.changefeedprocessor.ChangeFeedEventHost.lambda$registerObserverFactory$0(ChangeFeedEventHost.java:133) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

2
Hi,does my answer helps you? - Jay Gong
Is your Leases collection partitioned or within a Shared Throughput database? - Matias Quaranta
@JayGong thanks for your response, creating aux-collection/lease collection with no partition key fixed the issue - user3023658

2 Answers

0
votes

PartitionKey value must be supplied for this operation.

The error claims that you need to provide partition key to connect with document db change feed if your collection is partitioned.

You could set the partition key range id in the ChangeFeedOptions class.

 ChangeFeedOptions changeFeedOptions = new ChangeFeedOptions();
 changeFeedOptions.setPartitionKeyRangeId();

As I know, Changefeed works at a PartitionKey Range level.

What are partition key ranges?

Document Db currently has 10 GB Physical partitions. The partition key that you specify in the portal is the Logical Partition Key. Document Db internally maps this logical partition key to a Physical Partition using a hash. So its possible that a bunch of logical partitions are sharing the same physical partition. So a physical partition is assigned for a range of these hashes.

The minimum grain that is allowed to read from changefeed would be Partition key ranges. So for the you would have to query the partition key range id for the partition that you are interested in.

This link explains this in good detail: https://docs.microsoft.com/en-us/azure/cosmos-db/partition-data#partitioning-in-azure-cosmos-db

0
votes

The reason for this failure is because that old version of the Change Feed Processor for Java does not support partitioned leases collections.

If you want to use that version of the Change Feed Processor, you need to create your leases collection as a Fixed / no partition key collection.