You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/02/04 01:35:02 UTC

[GitHub] [couchdb] kocolosk commented on issue #3911: ETags support for views

kocolosk commented on issue #3911:
URL: https://github.com/apache/couchdb/issues/3911#issuecomment-1029559631


   Here's a sketch. It's unfortunately kind of scattered all over the codebase, but I would look to do something like this on the `3.x` branch:
   
   1. Check for the presence of an `If-Match` header containing a DB sequence on the incoming request in `chttpd_view`
   2. Pass that sequence into `fabric:query_view/7` if it's present
   3. Inside `query_view` call `fabric:changes/4` passing in the sequence from the header with limit=1 and see if any rows are returned.
   4. If no rows are returned, invoke the `Callback` function with a new message like `cache_hit` instead of dropping down into the `fabric_view_map` or `fabric_view_reduce` coordinators.
   5. Chase down all the callback functions in the `chttpd` app (possibly just `couch_mrview_http:view_cb/2`) to add a clause to handle `cache_hit` and return 304 when that happens. 
   
   Step 3 is really the key extra bit of logic that validates the freshness of the ETag. Of course we also have to generate the ETag inside `fabric_view_map` / `fabric_view_reduce` and send it with every respoonse. Here I'd be looking for something like
   
   1. Inside the `fabric_view` stack, make it so that `update_seq = true` is the only mode of operation, which will ensure that `couch_mrview:make_meta/3` always includes the update sequence in the view metadata sent from each shard. We should verify that the sequence here is really the sequence of the view index and not the database. I'm pretty sure that's the case.
   2. Update all the callback functions (again, maybe just `couch_mrview_http:view_cb/2` ?) to extract the `update_seq` from the `{meta, Meta}` message and report it in the ETag header. This will require a small bit of refactoring as the code currently blindly starts a response with no extra response headers.
   
   The work to do this on `main` is going to be fairly similar but not so simple as a `cherry-pick`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org