[ 
https://issues.apache.org/jira/browse/COUCHDB-1651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13579774#comment-13579774
 ] 

Benoit Chesneau commented on COUCHDB-1651:
------------------------------------------

Initial version wasn't using the process dictionary but was added because some 
didn't want to have an extra header.

I don't think this is the problem there, correctly handling the routes 
resolving is the path to go. Say instead of doing (in pseudo code):

    handle_request(Req) ->

       if path =:= "_rewrite" ->
          handle_rewrite(Req)
       else
          do something

    handle_rewrite(Req) ->
       NewReq = handle_routes(Req),
       handle_request(NewReq).


we could have:

   handle_rewrite(Req) ->
       Path = Req#path,
       NewPath = resolve_route(Path, []),


   resolve_route(Path, Resolved) ->
       Rules = get_rules(Path),
       NewPath = bind_path(Path, Rules),

       if need_rewrite(NewPath) ->
           if is_member(NewPath, Resolved) ->
              throw({infinite_loop, ...})
           else
              resolve_route(Path, [NewPath | Resolved])
       else:
           Path

Of course we can here calculate the recursion count and see if we get over the 
limit etc. 
      
    
   
                
> Server responds 400 "Exceeded rewrite recursion limit" indefinitely
> -------------------------------------------------------------------
>
>                 Key: COUCHDB-1651
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1651
>             Project: CouchDB
>          Issue Type: Bug
>          Components: HTTP Interface
>            Reporter: Paul Frazee
>         Attachments: resolve_spurious_rewrite_limit_errors.patch
>
>
> Running 1.2.1 on Windows 7 as a service.
> hosts file includes "127.0.0.1 grimwire.local"
> CouchDB conf includes vhosts entries:
> grimwire.local:5984            /grimwire/_design/grimwire/_rewrite
> grimwire.local:5984/local      /grimwire/_design/local/_rewrite
> 'grimwire' design doc rewrites:
> [
>       {
>               "from": "",
>               "to": "index.html",
>               "method": "GET"
>       },
>       {
>               "from": "*",
>               "to": "*"
>       }
> ]
> 'local' design doc rewrites:
> [
>       {
>               "from":"",
>               "to":"index.html",
>               "method":"GET"
>       },
>       {
>               "from":"/posts",
>               "to":"_list/wallpost/wallpost-by-created_at",
>               "method":"GET"
>       },
>       {
>               "from":"/posts",
>               "to":"_update/wallpost",
>               "method":"POST"
>       },
>       {
>               "from":"/posts/:id",
>               "to":"_show/wallpost/:id",
>               "method":"GET"
>       },
>       {
>               "from":"/posts/:id",
>               "to":"_update/wallpost/:id",
>               "method":"PUT"
>       },
>       {
>               "from":"*",
>               "to":"*"
>       }
> ]
> Problem:
> The requests work as expected for some unknown period, then begin to respond 
> with a 400 status and the "Exceeded rewrite recursion limit" error message. 
> Changing the rewrites rules for both applications, including setting them to 
> empty arrays, had no effect.
> The problem was solved by restarting the CouchDB service.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to