それでもやっぱりレプリケーション走らせるとお亡くなりになる。

それはともかく、proxy を介して、リモートDBとローカルDBをレプリケーションすると、、、無限ループに陥るようだ(笑。%2Fの問題かなーと思ったんだが、無限ループというのはさすがにひどいと思うので調査。

以下、ログです。

POST /_replicage
{ source : "/test_suite_db_a", target: "test_suite_db_b"}

の場合はOK。couchdb.log に残るのは以下(infoレベルの場合)。

[Sun, 31 May 2009 07:26:16 GMT] [info] [<0.99.0>] starting new replication "6fd26cc178f84ae2021160dd7e7a3647" at <0.105.0>

[Sun, 31 May 2009 07:26:16 GMT] [info] [<0.105.0>] recording a checkpoint at source update_seq 18

[Sun, 31 May 2009 07:26:16 GMT] [info] [<0.99.0>] 192.168.1.130 - - 'POST' /_replicate 200

updated_seq をローカルのDBで取得してやるだけなので、こうなります。

ところが、POST時にリモートDBっぽく見せかけて、

POST /_replicage
{ source : "/test_suite_db_a", target: "http://relax.webjourney.org/test_suite_db_b"}

のように、target をURI指定にする(リモートDB)と駄目になる。リモートDBの場合は、CouchDB(のErlang)からHTTPを発行してリモートDBの情報を取りに行く。

[Sun, 31 May 2009 06:49:29 GMT] [info] [<0.116.0>] 192.168.1.130 - - 'POST' /_replicate 200
[Sun, 31 May 2009 06:50:51 GMT] [info] [<0.282.0>] 192.168.1.11 - - 'GET' /test_suite_db_b/ 200
[Sun, 31 May 2009 06:50:51 GMT] [info] [<0.286.0>] 192.168.1.11 - - 'GET' /test_suite_db_b/_local%2Fbc749aa69e7e5401b31256320ed95bbe 404
[Sun, 31 May 2009 06:50:51 GMT] [info] [<0.181.0>] starting new replication "bc749aa69e7e5401b31256320ed95bbe" at <0.283.0>
[Sun, 31 May 2009 06:50:51 GMT] [error] [emulator] Error in process <0.289.0> with exit value: {{nocatch,{invalid_json,<<181 bytes>>}},[{mochijson2,decode,1},{couch_rep,get_missing_revs,2},{couch_rep,enum_docs_since,4}]}

感じで、ここで止まってくれればまだいいのに、なぜか無限ループ(笑。

nginx 側。

192.168.1.11 - - [31/May/2009:15:34:09 +0900] "GET /test_suite_db_b/_local%2Fbc749aa69e7e5401b31256320ed95bbe HTTP/1.1" 404 41 "-" "-"
192.168.1.11 - - [31/May/2009:15:34:09 +0900] "POST /test_suite_db_b/_missing_revs HTTP/1.1" 411 181 "-" "-"
192.168.1.11 - - [31/May/2009:15:34:09 +0900] "POST /test_suite_db_b/_missing_revs HTTP/1.1" 411 181 "-" "-"
192.168.1.11 - - [31/May/2009:15:34:09 +0900] "POST /test_suite_db_b/_missing_revs HTTP/1.1" 411 181 "-" "-"
192.168.1.11 - - [31/May/2009:15:34:09 +0900] "POST /test_suite_db_b/_missing_revs HTTP/1.1" 411 181 "-" "-"
192.168.1.11 - - [31/May/2009:15:34:09 +0900] "POST /test_suite_db_b/_missing_revs HTTP/1.1" 411 181 "-" "-"

という感じで、空のまま _missing_revs にPOSTしているのが問題。411 とか初めて見た。_local%2F... というのはレプリケーションの履歴データ。