Skip to content

Je/cloudant lib pt1 - #29

Merged
nickpell merged 14 commits into
dimagi:jsonobjectfrom
emord:je/cloudant-lib-pt1
Nov 21, 2017
Merged

Je/cloudant lib pt1#29
nickpell merged 14 commits into
dimagi:jsonobjectfrom
emord:je/cloudant-lib-pt1

Conversation

@emord

@emord emord commented Nov 20, 2017

Copy link
Copy Markdown
Contributor

@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

@emord emord mentioned this pull request Nov 20, 2017
@nickpell
nickpell merged commit db08de1 into dimagi:jsonobject Nov 21, 2017
@emord
emord deleted the je/cloudant-lib-pt1 branch November 21, 2017 20:26
Comment thread couchdbkit/client.py
res = self.res.put(docid1, payload=doc1,
**params).json_body
except ResourceConflict:
couch_doc.save()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have a solution to this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants