You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Fabrício Dias (JIRA)" <ji...@apache.org> on 2012/11/14 20:42:12 UTC

[jira] [Commented] (COUCHDB-1605) Fail to Add Document to _replicator

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

Fabrício Dias commented on COUCHDB-1605:
----------------------------------------

I believe the fault is in the validation of the document "_design / _replicator" but I can not identify the exact problem.
                
> Fail to Add Document to _replicator
> -----------------------------------
>
>                 Key: COUCHDB-1605
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1605
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 1.2
>         Environment: uname -a
> Linux ORALNX 2.6.39-200.32.1.el6uek.x86_64 #1 SMP Wed Sep 26 23:11:38 PDT 2012 x86_64 x86_64 x86_64 GNU/Linux
> curl -X GET http://admin:password@127.0.0.1:5984;
> {"couchdb":"Welcome","version":"1.2.0"}
> ### SETUP - JS 1.8.5
> yum install -y wget gcc-c++ autoconf213 zip
> cd /tmp
> wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
> tar xvf js185-1.0.0.tar.gz
> cd /tmp/js-1.8.5/js/src
> autoconf-2.13
> ./configure
> make && make install
> #### SETUP - CouchDB
> yum install -y gcc autoconf automake make libicu-devel curl-devel erlang erlang-ibrowse erlang-mochiweb erlang-oauth openssl-devel libtool which
> cd /tmp
> wget http://apache.mirror.pop-sc.rnp.br/apache/couchdb/releases/1.2.0/apache-couchdb-1.2.0.tar.gz
> tar zxfv apache-couchdb-1.2.0.tar.gz
> cd /tmp/apache-couchdb-1.2.0
> ./configure --prefix=/opt --with-erlang=/usr/lib64/erlang/usr/include --with-js-lib=/usr/local/lib/ --with-js-include=/usr/local/include/js/
> make && make install
> #### START - CouchDB
> ln -s /opt/etc/rc.d/couchdb /etc/init.d/couchdb;
> chkconfig --add couchdb;
> chkconfig --level 345 couchdb on;
> service couchdb stop;
> sleep 3;
> service couchdb start;
> sleep 3;
> curl -X GET http://admin:password@127.0.0.1:5984/;
> {"couchdb":"Welcome","version":"1.2.0"}
>            Reporter: Fabrício Dias
>            Priority: Critical
>
> # Now I try to create a replica:
> [root@ORALNX couchdb]# curl -X GET http://admin:password@127.0.0.1:5984/syd_global_couchapp;
> {"db_name":"syd_global_couchapp","doc_count":3,"doc_del_count":0,"update_seq":4,"purge_seq":0,"compact_running":false,"disk_size":2379878,"data_size":2358489,"instance_start_time":"1352921020564400","disk_format_version":6,"committed_update_seq":4}
> [root@ORALNX couchdb]# curl -X POST http://admin:password@127.0.0.1:5984/_replicator -H "content-type: application/json" -d \
> '{
>  "_id":"reply1",
>  "source":"syd_global_couchapp",
>  "target":"syd_global_couchapp_copy",
>  "create_target":true,
>  "continuous":true
> }';
> {"error":"{bad_return_value,{os_process_error,{exit_status,127}}}","reason":"{gen_server,call,
>             [couch_query_servers,
>              {get_proc,{doc,<<\"_design/_replicator\">>,
>                             {7,
>                              [<<63,207,130,209,42,66,129,178,15,48,222,32,110,
>                                 60,239,52>>,
>                               <<124,51,106,90,72,50,181,32,225,86,125,33,30,34,
>                                 213,185>>,
>                               <<115,129,44,182,171,22,108,111,73,61,111,140,98,
>                                 211,86,183>>,
>                               <<19,237,37,141,211,255,51,86,82,227,32,169,66,
>                                 75,147,202>>,
>                               <<124,39,146,76,233,174,78,63,55,135,118,148,221,
>                                 110,241,51>>,
>                               <<141,251,167,195,125,83,96,188,172,13,211,92,
>                                 251,86,210,229>>,
>                               <<91,250,44,153,238,254,43,46,180,150,45,181,
>                                 10,163,207,212>>]},
>                             {[{<<\"language\">>,<<\"javascript\">>},
>                               {<<\"validate_doc_update\">>,
>                                <<\"
>     function(newDoc, oldDoc, userCtx) {
>         function reportError(error_msg) {
>             log('Error writing document `' + newDoc._id +
>                 '\\\\' to the replicator database: ' + error_msg);
>             throw({forbidden: error_msg});
>         }
>         function validateEndpoint(endpoint, fieldName) {
>             if ((typeof endpoint !== 'string') &&
>                 ((typeof endpoint !== 'object') || (endpoint === null))) {
>                 reportError('The `' + fieldName + '\\\\' property must exist' +
>                     ' and be either a string or an object.');
>             }
>             if (typeof endpoint === 'object') {
>                 if ((typeof endpoint.url !== 'string') || !endpoint.url) {
>                     reportError('The url property must exist in the `' +
>                         fieldName + '\\\\' field and must be a non-empty string.');
>                 }
>                 if ((typeof endpoint.auth !== 'undefined') &&
>                     ((typeof endpoint.auth !== 'object') ||
>                         endpoint.auth === null)) {
>                     reportError('`' + fieldName +
>                         '.auth\\\\' must be a non-null object.');
>                 }
>                 if ((typeof endpoint.headers !== 'undefined') &&
>                     ((typeof endpoint.headers !== 'object') ||
>                         endpoint.headers === null)) {
>                     reportError('`' + fieldName +
>                         '.headers\\\\' must be a non-null object.');
>                 }
>             }
>         }
>         var isReplicator = (userCtx.roles.indexOf('_replicator') >= 0);
>         var isAdmin = (userCtx.roles.indexOf('_admin') >= 0);
>         if (oldDoc && !newDoc._deleted && !isReplicator &&
>             (oldDoc._replication_state === 'triggered')) {
>             reportError('Only the replicator can edit replication documents ' +
>                 'that are in the triggered state.');
>         }
>         if (!newDoc._deleted) {
>             validateEndpoint(newDoc.source, 'source');
>             validateEndpoint(newDoc.target, 'target');
>             if ((typeof newDoc.create_target !== 'undefined') &&
>                 (typeof newDoc.create_target !== 'boolean')) {
>                 reportError('The `create_target\\\\' field must be a boolean.');
>             }
>             if ((typeof newDoc.continuous !== 'undefined') &&
>                 (typeof newDoc.continuous !== 'boolean')) {
>                 reportError('The `continuous\\\\' field must be a boolean.');
>             }
>             if ((typeof newDoc.doc_ids !== 'undefined') &&
>                 !isArray(newDoc.doc_ids)) {
>                 reportError('The `doc_ids\\\\' field must be an array of strings.');
>             }
>             if ((typeof newDoc.filter !== 'undefined') &&
>                 ((typeof newDoc.filter !== 'string') || !newDoc.filter)) {
>                 reportError('The `filter\\\\' field must be a non-empty string.');
>             }
>             if ((typeof newDoc.query_params !== 'undefined') &&
>                 ((typeof newDoc.query_params !== 'object') ||
>                     newDoc.query_params === null)) {
>                 reportError('The `query_params\\\\' field must be an object.');
>             }
>             if (newDoc.user_ctx) {
>                 var user_ctx = newDoc.user_ctx;
>                 if ((typeof user_ctx !== 'object') || (user_ctx === null)) {
>                     reportError('The `user_ctx\\\\' property must be a ' +
>                         'non-null object.');
>                 }
>                 if (!(user_ctx.name === null ||
>                     (typeof user_ctx.name === 'undefined') ||
>                     ((typeof user_ctx.name === 'string') &&
>                         user_ctx.name.length > 0))) {
>                     reportError('The `user_ctx.name\\\\' property must be a ' +
>                         'non-empty string or null.');
>                 }
>                 if (!isAdmin && (user_ctx.name !== userCtx.name)) {
>                     reportError('The given `user_ctx.name\\\\' is not valid');
>                 }
>                 if (user_ctx.roles && !isArray(user_ctx.roles)) {
>                     reportError('The `user_ctx.roles\\\\' property must be ' +
>                         'an array of strings.');
>                 }
>                 if (!isAdmin && user_ctx.roles) {
>                     for (var i = 0; i < user_ctx.roles.length; i++) {
>                         var role = user_ctx.roles[i];
>                         if (typeof role !== 'string' || role.length === 0) {
>                             reportError('Roles must be non-empty strings.');
>                         }
>                         if (userCtx.roles.indexOf(role) === -1) {
>                             reportError('Invalid role (`' + role +
>                                 '\\\\') in the `user_ctx\\\\'');
>                         }
>                     }
>                 }
>             } else {
>                 if (!isAdmin) {
>                     reportError('The `user_ctx\\\\' property is missing (it is ' +
>                        'optional for admins only).');
>                 }
>             }
>         } else {
>             if (!isAdmin) {
>                 if (!oldDoc.user_ctx || (oldDoc.user_ctx.name !== userCtx.name)) {
>                     reportError('Replication documents can only be deleted by ' +
>                         'admins or by the users who created them.');
>                 }
>             }
>         }
>     }
> \">>}]},
>                             [],false,[]},
>                        {<<\"_design/_replicator\">>,
>                         <<\"7-3fcf82d12a4281b20f30de206e3cef34\">>}},
>              infinity]}"}
> [root@ORALNX couchdb]#

--
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