Skip to content

Instantly share code, notes, and snippets.

@stefankoegl
Last active December 17, 2015 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefankoegl/5520119 to your computer and use it in GitHub Desktop.
Save stefankoegl/5520119 to your computer and use it in GitHub Desktop.
Weirdness when deleting CouchDB replication document
$ curl http://127.0.0.1:5984/
{"couchdb":"Welcome","uuid":"39ca13ed778fa8a6376ed7affee79b06","version":"1.3.0","vendor":{"version":"1.3.0","name":"The Apache Software Foundation"}}
$ curl http://127.0.0.1:5984/_replicator/mygpo_categories
{"_id":"mygpo_categories","_rev":"5-35ceab198cf3edc63865dcb081551ae8","source":"mygpo","target":"http://127.0.0.1:5984/mygpo_categories","create_target":true,"user_ctx":{"name":"stefan","roles":["admin"]},"filter":"generic/is_type","query_params":{"doc_type":"Category"},"owner":"stefan","_replication_state":"completed","_replication_state_time":"2013-04-29T08:09:53+00:00","_replication_id":"cd589cae67f2f59ec6bf274fa35ec32b","_replication_stats":{"revisions_checked":1994,"missing_revisions_found":1994,"docs_read":1994,"docs_written":1994,"doc_write_failures":0,"checkpointed_source_seq":232955728}}
# using the _rev from the GET above
$ curl -X DELETE "http://stefan:***********@127.0.0.1:5984/_replicator/mygpo_categories?rev=5-35ceab198cf3edc63865dcb081551ae8"
{"error":"conflict","reason":"Document update conflict."}
[Sun, 05 May 2013 08:11:34 GMT] [info] [<0.29753.56>] 127.0.0.1 - - DELETE /_replicator/mygpo_categories?rev=5-35ceab198cf3edc63865dcb081551ae8 409
>>> import couchdb
>>> db = couchdb.Database('http://stefan:***********@127.0.0.1:5984/_replicator')
>>> del db['mygpo_categories']
[Sun, 05 May 2013 08:13:19 GMT] [info] [<0.30842.56>] 127.0.0.1 - - HEAD /_replicator/mygpo_categories 304
[Sun, 05 May 2013 08:13:19 GMT] [info] [<0.30842.56>] 127.0.0.1 - - DELETE /_replicator/mygpo_categories?rev=5-c47b02b467c00042a9c0a1abcd5040c4 200
# this used a different _rev, but still a 5-something. conflict?
$ curl http://127.0.0.1:5984/_replicator/mygpo_categories
[Sun, 05 May 2013 08:13:31 GMT] [error] [<0.31068.56>] function_clause error in HTTP request
[Sun, 05 May 2013 08:13:31 GMT] [info] [<0.31068.56>] Stacktrace: [{couch_replicator_manager,
strip_credentials,
[undefined],
[{file,"src/couch_replicator_manager.erl"},
{line,695}]},
{couch_replicator_manager,after_doc_read,
2,
[{file,"src/couch_replicator_manager.erl"},
{line,683}]},
{couch_db,open_doc_int,3,
[{file,"couch_db.erl"},{line,1203}]},
{couch_db,open_doc,3,
[{file,"couch_db.erl"},{line,141}]},
{couch_httpd_db,couch_doc_open,4,
[{file,"couch_httpd_db.erl"},{line,802}]},
{couch_httpd_db,db_doc_req,3,
[{file,"couch_httpd_db.erl"},{line,498}]},
{couch_httpd_db,do_db_req,2,
[{file,"couch_httpd_db.erl"},{line,234}]},
{couch_httpd,handle_request_int,5,
[{file,"couch_httpd.erl"},{line,331}]}]
[Sun, 05 May 2013 08:13:31 GMT] [info] [<0.31068.56>] 127.0.0.1 - - GET /_replicator/mygpo_categories 500
[Sun, 05 May 2013 08:13:31 GMT] [error] [<0.31068.56>] httpd 500 error response:
{"error":"unknown_error","reason":"function_clause"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment