Wednesday 15 August 2012

c# - "Unexpected Response Code for Operation: 0" when executing Azure Table Storage batch delete -



c# - "Unexpected Response Code for Operation: 0" when executing Azure Table Storage batch delete -

i'm using version 4.3.0 of windows azure storage libraries .net. in ats repository class, have couple of batch delete methods this:

public async task deleteasync(ienumerable<t> entities) { await executeasbatch(entities, (batch, entity) => batch.delete(entity)); } private async task executeasbatch(ienumerable<t> entities, action<tablebatchoperation, t> batchaction) { var bypartition = entities.groupby(x => x.partitionkey).tolist(); await bypartition.foreachparallel(async grouping => { // maximum of 100 actions allowed per batch job var segments = group.tolist().tosegmentedlist(100); await segments.foreachparallel(async segment => { var batch = new tablebatchoperation(); foreach (var entity in segment) { batchaction(batch, entity); } await table.executebatchasync(batch); }, 10); }, 10); }

in other places in code, deleteasync() method works correctly. however, in 1 particular place, error message when executing batch:

unexpected response code operation: 0

here's phone call site:

private async task mergeatsorganizationuserevents(int organizationid, ienumerable<customeruserevent> fromevents, customeruser to) { var todelete = (await fromevents.selectparallel(async fromevent => { var pkey = atsorganizationusereventbyminute.getpartitionkey(organizationid, fromevent.occurredon); var rkey = atsorganizationusereventbyminute.getrowkey(fromevent.occurredon, fromevent.customerusereventid); homecoming await ats.organizationusereventbyminute.findbypartitionrowasync(pkey, rkey); })).where(x => x != null).tolist(); var toinsert = todelete .select(x => atsorganizationusereventbyminute.frombase(x.organizationid, x.occurredon, x.cookieid, to.customeruserid, x)) .tolist(); seek { await ats.organizationusereventbyminute.upsertasync(toinsert); await ats.organizationusereventbyminute.deleteasync(todelete); } grab (exception ex) { _logger.error("unable merge {0} atsorganizationevents org {1}, client user {2}: {3}", toinsert.count, organizationid, to.customeruserid, ex.completemessage()); throw; } }

the upsertasync() method above succeeds, deleteasync() fails. note fails delete exactly same entities findbypartitionrowasync() retrieved table, can't quite imagine how have malformed entities or of ilk.

here's illustration of 1 of "todelete" objects (in json format):

{ "cookieid":null, "customeruserid":185766, "customerusereventid":3568687, "organizationid":4190, "eventname":"event1", "sessionid":null, "occurredon":"2014-10-20t18:17:09.9971379z", "urlid":null, "url":null, "referrerurlid":null, "referrerurl":null, "issynthetic":false, "ipaddress":null, "partitionkey":"4190.2014.10.20", "rowkey":"18.17.3568687", "timestamp":"2014-10-20t18:17:11.237+00:00", "etag":"w/\\" datetime'2014-10-20t18%3a17%3a11.237z'\\"" }

azure storage error messages notoriously , spectacularly unhelpful, , googling has returned nil batch deletes failing particular error.

this fails both when using local development storage , in production.

any thoughts?

'unexpected response code operation: 0' means first operation in batch failed. index of failed operation returned in error thrown makes easier users go , alter specific operation in batch failed.

you can more info request failed , error catching storageexception , checking:

exception.requestinformation.httpstatuscode exception.requestinformation.extendederrorinformation.errorcode exception.requestinformation.extendederrorinformation.errormessage

the same info available in operationcontext's lastly result if utilize operationcontext track request , utilize suitable method overloads take in operationcontext.

we @ changing error message in future less confusing. feedback!

c# windows-azure-storage

No comments:

Post a Comment