Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-188

_bulk_docs fails when deleting and adding a doc with the same id

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 0.9
    • 1.3
    • Database Core
    • None
    • CouchDB revision 730414.

    • Regular Contributors Level (Easy to Medium)

    Description

      CouchDB returns a "412 Precondition Failed" when the list of changes sent to _bulk_docs deletes a document and later creates a document with the same id as the deleted document:

      {"docs": [

      {"_id": "docid", "_rev": "<rev>", "_deleted": true}

      ,

      {"_id": "docid"}

      ]}

      Once fixed, the response JSON document will return the same docid twice in the list but it's presumably ordered consistently with the request data so any client should be able to understand the response.

      Demonstrating the problem using curl is easy enough:

      $ curl -X PUT http://localhost:5984/test

      {"ok":true}

      $ curl -X PUT -d "{}" http://localhost:5984/test/docid

      {"ok":true,"id":"docid","rev":"4140747751"}

      $ curl -X POST -d '{"docs": [

      {"_id": "docid", "_rev": "4140747751", "_deleted": true}

      ,

      {"_id": "docid"}

      ]}' http://localhost:5984/test/_bulk_docs

      {"error":"conflict","reason":"Document update conflict."}

      Note: this is likely related to COUCHDB-172.

      Attachments

        Activity

          People

            fdmanana Filipe David Borba Manana
            emgee Matt Goodall
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: