Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow duplicate uniqueKeyPolicy in DocumentCollection #41608

Merged

Conversation

FabianMeiswinkel
Copy link
Member

@FabianMeiswinkel FabianMeiswinkel commented Aug 22, 2024

Description

This PR address a customer-reported issue of a transient error - I haven't been able to reproduce this myself - but the change is extremely low risk and can help making the Java SDK/Spark connector more robust.

Reported exception:

2024-08-19 12:11:41,861 ERROR Executor [Executor task launch worker for task 3.0 in stage 26.0 (TID 23809)]: Exception in task 3.0 in stage 26.0 (TID 23809)
java.lang.IllegalArgumentException: Unable to parse JSON {"id":"COLLECTIONNAME","indexingPolicy":{"indexingMode":"consistent","automatic":true,"includedPaths":[{"path":"/*"}],"excludedPaths":[{"path":"/\"_etag\"/?"}],"spatialIndexes":[{"path":"/*","types":["Point","LineString","Polygon","MultiPolygon"]}]},"partitionKey":{"paths":["/pk"],"kind":"Hash","systemKey":false},"defaultTtl":2764800,"conflictResolutionPolicy":{"mode":"LastWriterWins","conflictResolutionPath":"/_ts","conflictResolutionProcedure":""},"geospatialConfig":{"type":"Geography"},"_rid":"RID","_ts":1587070752,"_self":"dbs/DBRID/colls/COLLECTIONRID/","_etag":"\"ETAG\"","_docs":"docs/","_sprocs":"sprocs/","_triggers":"triggers/","_udfs":"udfs/","_conflicts":"conflicts/","uniqueKeyPolicy":{},"uniqueKeyPolicy":{}}
	at azure_cosmos_spark.com.azure.cosmos.implementation.JsonSerializable.fromJson(JsonSerializable.java:645)
	at azure_cosmos_spark.com.azure.cosmos.implementation.JsonSerializable.<init>(JsonSerializable.java:84)
	at azure_cosmos_spark.com.azure.cosmos.implementation.Resource.<init>(Resource.java:83)
	at azure_cosmos_spark.com.azure.cosmos.implementation.DocumentCollection.<init>(DocumentCollection.java:81)
	at azure_cosmos_spark.com.azure.cosmos.models.CosmosContainerProperties.<init>(CosmosContainerProperties.java:66)
	at azure_cosmos_spark.com.azure.cosmos.models.CosmosContainerProperties$1.create(CosmosContainerProperties.java:414)
	at azure_cosmos_spark.com.azure.cosmos.SparkBridgeInternal$.getContainerPropertiesFromCollectionCache(SparkBridgeInternal.scala:102)
	at com.azure.cosmos.spark.CosmosWriterBase.<init>(CosmosWriterBase.scala:58)
	at com.azure.cosmos.spark.CosmosWriter.<init>(CosmosWriter.scala:34)
	at com.azure.cosmos.spark.ItemsDataWriteFactory.createWriter(ItemsDataWriteFactory.scala:51)
	at org.apache.spark.sql.execution.datasources.v2.DataWritingSparkTask$.run(WriteToDataSourceV2Exec.scala:439)
	at org.apache.spark.sql.execution.datasources.v2.V2TableWriteExec.$anonfun$writeWithV2$2(WriteToDataSourceV2Exec.scala:390)
	at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
	at org.apache.spark.scheduler.Task.run(Task.scala:136)
	at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:548)
	at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1504)
	at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:551)
	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:750)

The duplicated "uniqueKeyPolicy":{},"uniqueKeyPolicy":{} is unexpected.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copy link
Member

@tvaron3 tvaron3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@xinlian12 xinlian12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - spark

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - spark

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@FabianMeiswinkel FabianMeiswinkel merged commit 30e6467 into Azure:main Aug 23, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants