I’m trying to save large document using async ops in python 3.9.
Almost 4 out 10 attempts fail to replace the document with fresh document and no error being logged. Is there any issue with the code?
Below code works perfectly for small docs but with documents with size >1MB it fails to update doc but still it shows as success.
I think the problem was that the “await” on collection.replace() was missing.
The create_cluster() didn’t return the cluster - i suspect this was just a typo.
The create_cluster() call in job() isn’t necessary.
That should work with no issue. How are you checking if the replace took place or not? Getting the doc with the kv api should show it. Getting with the query api would not show changes to indexed properties until they were indexed.
It’s an API that mutates the data and GET call to fetch the updated data.
We rarely use N1QL, its always kvops for all the data ops. Also, a few times the update would really succeed.
Would there be a way to know if there is an error while updating because I don’t see exceptions being caught?
I update some field values in the document using mutation request and when querying the same document it shows old data and this happens at least 7 out of 10 times. Since the exception is never caught we never noticed it very lately
Query will show the indexed data. So until the new data is indexed, you’ll see the old indexed data. If you retrieve the document by id in the kv-api (or the Bucket tab in the webconsole), it will have show the current data.
If the replace() fails there will be an exception and you will see it unless you specifically catch it and ignore it.
Hey hi, sorry for the delay. As I said the production code already has await in the code, however, I have pasted the updated code which is more look alike of the code running on the server.
This code never throws an exception or error but 7 out of 10 times if fails to update/replace docs that are more than 3 MB.
Insert 1000 documents of 3MB each of ‘0000…’, ‘1111…’; fetch and compare result,
Replace 1000 documents of 3MB each with ‘1111…’, ‘2222…’, fetch and compare result.
Replace “localhost” with your couchbase server,
Replace “company” with your bucket name,
Replace “password” with your password.
Replace “my_scope” with your scope.
Replace “my_collection” with your collection.
Run once.
Replace insert=True with insert=False.
Run again.