MB-10921 Release fds properly for views with reduce queries

View group file descriptors are reference counted by the number of callers.
When refcount becomes zero, fd is internally closed by the refcounter.

Interested callers acquire view_group using request_group() and refcount for
the fd is autoincremented. The caller who has acquired the view_group should
call release_group() explicitly to decrement the refcount or the caller process
should die to get refcount decremented.

For reduce enabled views, fd reference count is not decremented correctly
after the query path discards that fd. The http server implementation spawns
one worker process per connection. If a connection is reused, queries served
through that connection is processed by the same erlang process.
A missing fd decrement after use of requested group causes fd leaks in
the case of keep-alive connections used for queries.

The leak can be reproduced by using the following steps:
1. Create a view with reduce function and build the view with sufficient data
2. Send the following http request through netcat and keep the netcat open to
   simulate reuse of connection.

$ nc localhost 8092
GET /default/_design/test/_view/test?stale=update_after HTTP/1.1

3. Now trigger manual compaction
4. $ echo beam | xargs -n1 pgrep | xargs -n1 -r -- lsof -n -p  | grep deleted
beam.smp 27922 ubuntu   41r      REG     202,1  2054213    167136 /home/ubuntu/couchbase-2.5/ns_server/data/n_0/data/.delete/5d79134a257d5866532ddef4d9827780 (deleted)

Change-Id: I20a74202587198da46b81e2e722dcbf9821d7b08
Reviewed-on: http://review.couchbase.org/40679
Reviewed-by: Sarath Lakshman <sarath@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Reviewed-by: Sriram Melkote <siri@couchbase.com>