Je/cloudant lib pt1 - #29
Conversation
Comment about the admin party
more cloudant Fix name fix variable
Fix full commit
half of save_doc clean up save_doc save_docs uses cloudant lib
| res = self.res.put(docid1, payload=doc1, | ||
| **params).json_body | ||
| except ResourceConflict: | ||
| couch_doc.save() |
There was a problem hiding this comment.
I just found a weird behavior change.
Prior to this change, if two processes open the same document, and concurrently one performs a save and one performs a delete, the delete operation always wins.
With this change, there exists an interleaving of operations where the save wins. You can reproduce this by loading the same doc in two different processes, and then first delete one doc, and then second save the other doc.
The cause of this issue is in how the cloudant library implements save:
https://github.com/cloudant/python-cloudant/blob/2.7.0/src/cloudant/document.py#L181-L182
If the document is not found, we create the document. In order to follow the previous behavior, we would need to atomically check for a deleted document and write if not deleted.
Maybe we can just call this part of Document.save to get similar behavior:
https://github.com/cloudant/python-cloudant/blob/2.7.0/src/cloudant/document.py#L184-L188
There was a problem hiding this comment.
I think I have a solution to this
@dimagi/py3 This moves almost the entire client to using the cloudant lib. the only thing left is the attachment endpoints and three other endpoints (e3c55dc)
Should be reviewable commit by commit