couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Dingwall (JIRA)" <j...@apache.org>
Subject [jira] [Created] (COUCHDB-1961) CouchDB Module Cache Misbehaving
Date Thu, 12 Dec 2013 16:50:06 GMT
James Dingwall created COUCHDB-1961:
---------------------------------------

             Summary: CouchDB Module Cache Misbehaving
                 Key: COUCHDB-1961
                 URL: https://issues.apache.org/jira/browse/COUCHDB-1961
             Project: CouchDB
          Issue Type: Bug
          Components: JavaScript View Server
            Reporter: James Dingwall


The module cache is breaking update functions which share a common module via require(). 
Disabling the caching by adding || true in main.js at line 1174 (CouchDB 1.5.0) resolves the
problem.  With this disabled then both curl commands in the example pass.

This code was introduced in https://issues.apache.org/jira/browse/COUCHDB-1075

Here is a complete test case design document which demonstrates the problem.

{
   "_id": "_design/ptest",
   "updates": {
       "two": "function(doc, req) {\n\trequire('views/lib/docUtil');\n\n\tif(!doc) {\n\t\tdoc
= {};\n\t}\n\n\tdoc._id = 'two';\n\n\tdoc.meta = docUtil.metaCreate();\n\n\treturn([doc, JSON.stringify(doc,
undefined, 2)]);\n}",
       "one": "function(doc, req) {\n\trequire('views/lib/docUtil');\n\n\tif(!doc) {\n\t\tdoc
= {};\n\t}\n\n\tdoc._id = 'one';\n\n\tdoc.meta = docUtil.metaCreate();\n\n\treturn([doc, JSON.stringify(doc,
undefined, 2)]);\n}"
   },
   "language": "javascript",
   "views": {
       "lib": {
           "docUtil": "(function(global) {\n\nvar _metaCreate = function() {\n\treturn({\n\t\ta:
'create',\n\t\tb: 'bbbb'\n\t});\n};\n\nvar _metaModify = function() {\n\treturn({\n\t\ta:
'modify',\n\t\tb: 'bbbb'\n\t});\n};\n\nglobal.docUtil = {\n\tmetaCreate: _metaCreate,\n\tmetaModify:
_metaModify\n};\n\nlog('require docUtil');\n\n})(exports.docUtil = this)"
       }
   },
   "type": "design/ptest"
}

Call the update functions like:
curl -X POST http://couchdb:5984/zydev/_design/ptest/_update/one - creates a document
curl -X POST http://couchdb:5984/zydev/_design/ptest/_update/two - fails




--
This message was sent by Atlassian JIRA
(v6.1.4#6159)

Mime
View raw message