You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "Jonathan Hall (JIRA)" <ji...@apache.org> on 2017/04/02 22:51:41 UTC
[jira] [Created] (COUCHDB-3353) _bulk_docs incorrectly creates
missing documents instead of returning conflict
Jonathan Hall created COUCHDB-3353:
--------------------------------------
Summary: _bulk_docs incorrectly creates missing documents instead of returning conflict
Key: COUCHDB-3353
URL: https://issues.apache.org/jira/browse/COUCHDB-3353
Project: CouchDB
Issue Type: Bug
Reporter: Jonathan Hall
If I attempt to update a missing document via the _bulk_docs endpoint with curl, using a single doc, everything works as expected:
curl -v -X POST http://admin:abc123@localhost:6001/foo/_bulk_docs -H "Content-Type: application/json" -d '{"docs":[{"_id":"bogus","_rev":"4-asb"}]}'
returns:
[{"id":"bogus","error":"conflict","reason":"Document update conflict."}]
But if I include a second valid doc (creating one in this example):
curl -v -X POST http://admin:abc123@localhost:6001/foo/_bulk_docs -H "Content-Type: application/json" -d '{"docs":[{"name":"Bob"},{"_id":"bogus","_rev":"4-asb"}]}'
I occasionally get the expected result:
[{"ok":true,"id":"0b7b7e409a37ccb8dcf89165ee74e429","rev":"1-5a26fa4b20e40bc9e2d3e47b168be460"},{"id":"bogus","error":"conflict","reason":"Document update conflict."}]
And I occasionally get that _both_ docs are created (!!!):
[{"ok":true,"id":"0b7b7e409a37ccb8dcf89165ee760150","rev":"1-5a26fa4b20e40bc9e2d3e47b168be460"},{"ok":true,"id":"bogus","rev":"5-19d41415e604c9e24813778b745f9407"}]
I noticed this while unit testing, where it was failing more often than succeeding, but I'm able to reproduce from the command line if I repeat the command quickly enough.
This makes me think there's some kind of race condition--if an early iteration hasn't finished (doing something), a repeated query may result in the document being erroneously created.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)