You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "Ondřej Novák (JIRA)" <ji...@apache.org> on 2017/04/21 11:50:04 UTC

[jira] [Created] (COUCHDB-3388) queryserver protocol violation - add_fun used incorrectly

Ondřej Novák created COUCHDB-3388:
-------------------------------------

             Summary: queryserver protocol violation - add_fun used incorrectly
                 Key: COUCHDB-3388
                 URL: https://issues.apache.org/jira/browse/COUCHDB-3388
             Project: CouchDB
          Issue Type: Bug
          Components: Database Core
            Reporter: Ondřej Novák


In relation COUCHDB-3387, there is another serious issue with the query server protocol violation.

Just look into the following log:

{noformat}
[debug] 2017-04-21T06:48:46.000000Z couchdb@localhost <0.7374.0> -------- OS Process #Port<0.7565> Input  :: ["reset",{"reduce_limit":true,"timeout":5000}]
[debug] 2017-04-21T06:48:46.001000Z couchdb@localhost <0.7374.0> -------- OS Process #Port<0.7565> Output :: true
[debug] 2017-04-21T06:48:46.001000Z couchdb@localhost <0.7374.0> -------- OS Process #Port<0.7565> Input  :: ["add_fun","function(doc) {emit(doc._id,doc._rev);}"]
[debug] 2017-04-21T06:48:46.003000Z couchdb@localhost <0.7374.0> -------- OS Process #Port<0.7565> Output :: true
[debug] 2017-04-21T06:48:46.004000Z couchdb@localhost <0.7374.0> -------- OS Process #Port<0.7565> Input  :: ["add_fun","function(keys,values,rereduce) {if (rereduce) return sum(values); else return values.length;}"]
[debug] 2017-04-21T06:48:46.007000Z couchdb@localhost <0.7374.0> -------- OS Process #Port<0.7565> Output :: true
{noformat}

As you can see, the third input line sends *reduce function* to  *add_fun*. This is against the rules. According to the documentation:
(http://docs.couchdb.org/en/2.0.0/query-server/protocol.html#add-fun), the rgument of this command is: *Map function source code.*.

Why it is called with a *reduce function* ?

I can guess the reason. The couchDb core uses queryserver's *add_fun* to check, whether the string contains a valid function. This is not ordinary bug in code, this is very bad decision which may result to a lot of confusions.

I suggest to use the "ddoc/new" command instead the "add_fun" (http://docs.couchdb.org/en/2.0.0/query-server/protocol.html#ddoc) to check whether the design document is valid. The query server can eventually validate every function in it including the shared code ("lib" section). 

This is the serious bug for me now. Fixing this bug also resolves  COUCHDB-3387 issue.  However, leaving this unfixed prevent me to upgrade to the CouchDB 2.0.
 
Ondřej Novak



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)