couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filipe Manana (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COUCHDB-1340) Replication: Invalid JSON reported
Date Thu, 17 Nov 2011 14:14:51 GMT

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

Filipe Manana commented on COUCHDB-1340:
----------------------------------------

Alex, that's great news :)
I found that the problem is mochiweb (our http server) doesn't allow request lines to exceed
8192 characters. We were accounting for this, but ignoring the extra characters account by
"GET " and the trailing " HTTP/1.1\r\n" in the first request line. So my final patch is now
this:

http://friendpaste.com/1TWqKb1Ac2hmKYh7VgNMLO


Index: src/couchdb/couch_rep_reader.erl
===================================================================
--- src/couchdb/couch_rep_reader.erl	(revision 1177549)
+++ src/couchdb/couch_rep_reader.erl	(working copy)
@@ -177,7 +177,7 @@
     hd(State#state.opened_seqs).
 
 split_revlist(Rev, {[CurrentAcc|Rest], BaseLength, Length}) ->
-    case Length+size(Rev)+3 > 8192 of
+    case Length+size(Rev)+3 >= 8192 of
     false ->
         {[[Rev|CurrentAcc] | Rest], BaseLength, Length+size(Rev)+3};
     true ->
@@ -214,7 +214,9 @@
     %% MochiWeb into multiple requests
     BaseQS = [{revs,true}, {latest,true}, {att_encoding_info,true}],
     BaseReq = DbS#http_db{resource=encode_doc_id(DocId), qs=BaseQS},
-    BaseLength = length(couch_rep_httpc:full_url(BaseReq) ++ "&open_revs=[]"),
+    BaseLength = length(
+        "GET " ++ couch_rep_httpc:full_url(BaseReq) ++
+        "&open_revs=[]" ++ " HTTP/1.1\r\n"),
 
     {RevLists, _, _} = lists:foldl(fun split_revlist/2,
         {[[]], BaseLength, BaseLength}, couch_doc:revs_to_strs(Revs)),


Thanks for testing and helping debug it. 
                
> Replication: Invalid JSON reported
> ----------------------------------
>
>                 Key: COUCHDB-1340
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1340
>             Project: CouchDB
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 1.1.1
>         Environment: CentOS 5.6 x86_64, Couchdb 1.1.1 (Patched for COUCHDB-1333), spidermonkey
1.8.5, curl 7.21, erlang 14b03
>            Reporter: Alex Markham
>              Labels: invalid, json
>         Attachments: 9c94ed0e23508f4ec3d18f8949c06a5b replicaton from wireshark cut.txt,
replication error wireshark.txt, source couch error.log, target couch error.log
>
>
> It seems our replication has stopped, reporting an error
> [emulator] Error in process <0.21599.306> {{nocatch,{invalid_json,<<0 bytes>>}},[{couch_util,json_decode,1},{couch_rep_reader,'-open_doc_revs/3-lc$^1/1-1-',1},{couch_rep_reader,'-open_doc_revs/3-lc$^1/1-1-',1},{couch_rep_reader,open_doc_revs,3},{couch_rep_reader,'-spawn_document_request/4-fun-0-'...

> It was all working until we upgraded some other couches in our replication "web" from
couch 1.0.3 to couch 1.1.1. We then set of database and view compactions, and sometime overnight
some of the replication links stopped.
> I have curled the command myself, both as a multipart message and a single json response
(with header "Accept:application/json" ) and it can be parsed correctly by Python simplejson
- I have attached it here aswell - called "troublecurl-redacted.txt" - though it is 18.8mb.
The request takes about 6 seconds.
> I don't quite understand why it is reported as invalid JSON? Other reports similar to
this that I googled mentioned blank document ids, but I can't see any of these.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message