manufont opened a new issue #2139: Conflict when adding a previously deleted 
document
URL: https://github.com/apache/couchdb/issues/2139
 
 
   I'm getting a "Document update conflict" when adding a previously deleted 
document.
   ## Description
   ```
   $ curl http://localhost:5984/mydb/mydocument
   {"error":"not_found","reason":"deleted"}
   $ curl http://localhost:5984/mydb/mydocument -X PUT --data-binary '{}'
   {"error":"conflict","reason":"Document update conflict."}
   ```
   ## Expected Behaviour
   ```
   $ curl http://localhost:5984/mydb/mydocument
   {"error":"not_found","reason":"deleted"}
   $ curl http://localhost:5984/mydb/mydocument -X PUT --data-binary '{}'
   {"ok":true,"id":"mydocument","rev":"723-..."}
   ```
   ​
   The reason I'm creating this issue is that I can't find a single case where 
this situation could occur. I've searched the documentation, stackoverflow & 
github and couldn't find a similar case. If the winning revision is a deleted 
leaf, then why is there a conflict when I try to add a new document with same 
ID ?
   I suspect a _purge of the 3 last revisions of this document might be the 
origin of this problem, but I couldn't reproduce it with other documents.
   ​
   Is there a way to manually resolve conflicts for deleted documents ? I've 
tried the flags `conflicts=true` & `deleted_conflicts=true` flag, but it didn't 
work.
   
   ​
   The only way I could find to resolve this conflict was the following:
   ​
   1. get the last revision id
   ```
   $ curl 
http://localhost:5984/mydb/_changes?filter=_doc_ids&doc_ids=["mydocument";]
   
{"results":[{"seq":"234234-...","id":"mydocument","changes":[{"rev":"722-46b..."}],"deleted":true}],"last_seq":"123123-...","pending":345345}
   ```
   2. update the deleted document
   ```
   $ curl http://localhost:5984/mydb/mydocument -X PUT --data-binary '{"_id": 
"mydocument", "_rev":"722-46b...", "_deleted": true}'
   {"ok":true,"id":"mydocument","rev":"723-..."}
   ```
   3. adding it again
   ```
   $ curl http://localhost:5984/mydb/mydocument -X PUT --data-binary '{}'
   {"ok":true,"id":"mydocument","rev":"724-..."}
   ```
   
   Another odd behaviour caught my attention: I can get 2 other revisions hash 
for this document:
   ```
   $ curl http://localhost:5984/mydb/mydocument?rev=722-46b...&revs=true
   
{"_id":"mydocument","_rev":"722-46b...","_deleted":true,"_revisions":{"start":722,"ids":["46b...","63b..","3de..."]}}
   ```
   But when I try getting them (with every possible revision index), I only get 
"missing" errors...
   ​
   ## Your Environment
   
{"couchdb":"Welcome","version":"2.3.1","git_sha":"c29...","uuid":"fc3...","features":["pluggable-storage-engines","scheduler"],"vendor":{"name":"The
 Apache Software Foundation"}}
   There's one "server" couch, configured with a 2-way replication to a dozen 
of Pouchdb "clients".
   To limit conflicts, the documents are updated server-side only.
   The _revs_limit value of all databases is set to 3, as we've got storage 
constraints on pouchdb clients.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to