Yep, for our batch processing, we handle each response.
This isn’t as bad as I first thought.
But… I can highlight a problem still.
Attached, please find a zip file containing 2 different versions of my test code. I don’t necessarily think this is a v2 vs v3 problem, but… Still some funny business in v3.
CouchbaseV2V3BulkComparison.zip (16.0 KB)
Now, the problem is caused by the key being too long. In 2.x one cannot create a document with a key that is too long, so the problem would actually never gets to the upsert, so this example really couldn’t happen with v2.
If you look at the code (as provided) for the 3x version, it fails all 3 documents:
class com.couchbase.client.core.error.ReplicaNotConfiguredException Not enough replicas configured on the bucket: Could not upsert document with Id: U:king_arthur_jr
class com.couchbase.client.core.error.CouchbaseException UpsertRequest failed with unexpected status code: Could not upsert document with Id: U:king_arthur_jr1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
class com.couchbase.client.core.error.RequestCanceledException UpsertRequest: Could not upsert document with Id: U:king_arthur
Key: U:king_arthur_jr Success: false
Key: U:king_arthur_jr1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 Success: false
Key: U:king_arthur Success: false
If the arthur_baby
entity with the very long key is commented out (lines 48-54), then it works as expected:
class com.couchbase.client.core.error.ReplicaNotConfiguredException Not enough replicas configured on the bucket: Could not upsert document with Id: U:king_arthur_jr
Key: U:king_arthur_jr Success: false
Key: U:king_arthur Success: true
But, I wouldn’t expect the class com.couchbase.client.core.error.CouchbaseException UpsertRequest failed
to force-cancel the “good” request (RequestCanceledException
)
EDIT: one more issue… If you add a null
-keyed value to the map, it totally breaks everything… Something like:
entities.put(null, arthur);
Again, this probably falls into a similar category (nobody should ever do this) but the code does just flat out fail in that case.