Skip to content

View results return deleted documents in main #3382

@nickva

Description

@nickva

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 pythonimport random
import requests
import threadingurl='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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions