-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Deleted documents end up returning view results. If include_docs=true is used the emitted documents is returned as null. This may be related to #3381
View results return:
{"id":"doc660","key":9,"value":[9,"649-1393896c61576b7b80d086f4f3858e78",2935760,122458],"doc":null}
and yet:
curl 'foo:bar@localhost:15984/db1/doc660'
{"error":"not_found","reason":"deleted"}
Reproducer script (thanks to @rnewson)
#!/usr/bin/env python
import random
import requests
import threading
url='http://127.0.0.1:15984/db1/'
def thread_fun():
s = requests.Session()
s.auth = ('foo', 'bar')
while True:
doc_id = random.randrange(1, 100)
doc = {"foo": random.randrange(1,1000000)}
r = s.get('{}/doc{}'.format(url, doc_id))
if r.status_code == 200:
doc['_rev'] = r.json()['_rev']
if random.random() > 0.5:
doc['_deleted'] = True
s.put('{}/doc{}'.format(url, doc_id), json = doc)
if __name__ == "__main__":
s = requests.Session()
s.auth = ('foo', 'bar')
s.delete(url)
s.put(url)
s.put('{}/_design/foo'.format(url), data = '{"views":{"bar":{"map":"function (doc) { emit(doc.foo, doc.foo); }"}}}')
for x in range(10):
t = threading.Thread(target=thread_fun)
t.start()