Azure-docs: Unable to get the bulk delete call, to delete anything at all. The comments in the code say that partitionkey isn't a mandate but an optimization, but it doesn't work.

Created on 26 Sep 2019  Â·  11Comments  Â·  Source: MicrosoftDocs/azure-docs

[Enter feedback here]


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 assigned-to-author cosmos-dsvc cosmosdb-sqsubsvc product-question triaged

All 11 comments

@Ambuj-K Please take a look at the samples here if you haven't already.

Posting your code here will help in debugging further.

I began from the samples, actually.

libraryDependencies += "com.microsoft.azure" % "documentdb-bulkexecutor" % "2.6.0"

Problem 1, in version 2.6 the overloaded methods deleteAll(query) and deleteAll(query, partitionKey), don't exist, which makes the sample a direct fallacy (compile error).
It expects a, deleteAll(List> pkIdPairsToDelete).

Talk about backward compatibility or keeping the git/samples updated!??

Second problem

First I had to do this, to even make it work.
libraryDependencies += "com.microsoft.azure" % "documentdb-bulkexecutor" % "2.4.0"

 val client_cosmo = new DocumentClient("xxxxxx",
  "xxxxxxx", new ConnectionPolicy(), ConsistencyLevel.Session)
client_cosmo.getConnectionPolicy.getRetryOptions.setMaxRetryWaitTimeInSeconds(30)
client_cosmo.getConnectionPolicy.getRetryOptions.setMaxRetryAttemptsOnThrottledRequests(9)
val collection = client_cosmo.readCollection("xxxx", null).getResource()
val offerThroughput = 100

val bulkExecutorBuilder = DocumentBulkExecutor.builder().from(client_cosmo, "propertydb",
  "core", collection.getPartitionKey(), offerThroughput)

try {
  val bulkExecutor = bulkExecutorBuilder.build()
  try { // Set retries to 0 to pass control to bulk executor
    client_cosmo.getConnectionPolicy.getRetryOptions.setMaxRetryWaitTimeInSeconds(0)
    client_cosmo.getConnectionPolicy.getRetryOptions.setMaxRetryAttemptsOnThrottledRequests(0)
    val totalWatch = Stopwatch.createUnstarted
    // Execute bulk delete API
    var query = """SELECT * FROM c where c.country = "Australia" and c.sourceMetadata.sourceSystem ="MRI" """
    System.out.println(query)
    // If a partition key is present in the query above, adding RequestOptions also containing the value of the partition key
    // for which the query is being issued to delete documents, will optimize performance.
    // If a partition key filter is not present in the query, only including the query in the 'deleteAll' call below, will suffice.
    val requestOptions = new RequestOptions()
    //requestOptions.setPartitionKey(new PartitionKey("2"))
    totalWatch.start
    val bulkDeleteResponse = bulkExecutor.deleteAll(query)
    totalWatch.stop

That's all the code there is to it.
Fairly straightforward.
Doesn't delete nada.

Here's the response.

SELECT * FROM c where c.country = "Australia" and c.sourceMetadata.sourceSystem ="MRI"

#

Number of documents deleted: 0
Time taken to delete documents specified by the query: 1396
Time request units consumed by the bulk delete operation: 0.0
Average RUs/second consumed by bulk delete batch: 0.0
Average #Deletes/second in this checkpoint: 0.0

#

2 4 0 DeleteAll

2.4.0 DeleteAll overloaded signatures

2 6 0 DeleteAll Fallacy

2.6.0 DeleteAll non-overloaded compile failing signature

DeleteAll NO delete

Non Delete Output

@Ambuj-K We are checking this with our author for further help.
@tknandu Please look into the issues raised by user and please correct if needed.

So, it has been a month, and as an Organisation we are a Azure Enterprise customer.
Should we expect a response on this?

@SnehaGunda Can you please check this.

Apologies for the long delay, I dropped an email to @abinav2307 and @tknandu to further debug.

Hi all,

Sincere apologies for the delay here. The Bulk Executor has a replacement in our V3 SDK, where bulk and batch operations are integrated within the SDK (without having to maintain another library only for bulk operations).

With the V3 Bulk API, any point operation can be executed in bulk, which applies to creates, replaces, upserts and deletes. Here is a sample detailing the usage of V3 for bulk https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos.Samples/Usage/BulkSupport/Program.cs#L106

The highlighted line does point inserts, but the CreateItemsAsync can be replaced with deletes to perform bulk deletes instead.

Here is an additional repo that shows samples using the V3 SDK for bulk operations that need transactional support (here the bulk operations are local to a specific partition key and hence can promise transactions for the bulk) - https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos.Samples/Usage/TransactionalBatch/Program.cs

"The Bulk Executor has a replacement in our V3 SDK" ---> Here you refer to the .NET SDK for SQL API, right?
What about the Java SDK for SQL API ? Is there a replacement too for the Bulk Executor?
Thank you!

Hello @zzebastien,

Yes we do have a replacement coming in for the Java SDK as well. We are currently working on a V4 SDK, which is slated for release by early Q2 of 2020. This SDK will have bulk APIs, with the same functionality as the bulk APIs in the V3 SDK links shared above.

Do let us know if this helps.

Hello @zzebastien Moving forward on this please subscribe to this issue below on the Java bulk executor repo. This is a better place to keep an eye on this issue than here on our docs repo.
https://github.com/Azure/azure-cosmosdb-bulkexecutor-java-getting-started/issues/6

Thanks for your patience on this.

Closing this docs issue.

please-close

Perfect, thanks for following up on that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spottedmahn picture spottedmahn  Â·  3Comments

Agazoth picture Agazoth  Â·  3Comments

paulmarshall picture paulmarshall  Â·  3Comments

spottedmahn picture spottedmahn  Â·  3Comments

Ponant picture Ponant  Â·  3Comments