Tangerine-Community / Tangerine

Digitize your offline data collection. Create your Forms online with Tangerine Editor, conduct them offline with the Tangerine Android App. All results you collect can be exported as a CSV file, easy for processing in a spreadsheet. Tangerine has been used in over 1 million assessments and surveys in over 60 countries and in 100 languages.
http://www.tangerinecentral.org/
GNU General Public License v3.0
50 stars 29 forks source link

Couchdb 2.2 replication issues using Tangerine start scripts for Tangerine data collections #1135

Open chrisekelley opened 6 years ago

chrisekelley commented 6 years ago

I'm trying to do some debugging of the reporting app and would like to replicate some docs from an external database. The remote db is running Couchdb 2.2. When I run the following command:

curl -H 'Content-Type: application/json' -X POST -d '{"source":"http://user:pass@remote:5984/foo","target":"bar","doc_ids":["testdoc"]}' http://user:pass@localhost/db/_replicate

I get the following error:

{"error":"replication_auth_error","reason":"{session_request_unauthorized,\"http://remote:5984/_session\",\"admin\"}"}

I followed the advice in this couchdb issue report - https://github.com/apache/couchdb/issues/1550 -

As a temporary workaround, you can disable the new _session support in the replicator by setting:

[replicator]
auth_plugins = couch_replicator_auth_noop

After rebooting the couchdb docker instance, I got some other errors:

{"error":"nxdomain","reason":"could not resolve http://any:5984/foo/"}

The solution was to docker exec into the couchdb instance and run the curl command from there.

rjcorwin commented 5 years ago

I think this was a bug in CouchDB that is now fixed.

jamesmfriedman commented 5 years ago

I just hit this, doesn't appear to be fixed

Getting...

session_request_failed
replication_auth_error
{conn_failed,{error,nxdomain}}
Aftabalamrana commented 5 years ago

I think this was a bug in CouchDB that is now fixed.

it seems issue is still there i am still getting this error:

{
    "error": "nxdomain",
    "reason": "could not resolve http://any:5984/mydb/"
}

Apache CouchDB: v. 2.3.1

rjcorwin commented 5 years ago

Hi @jamesmfriedman and @Aftabalamrana: Thanks for chiming in on this issue. What is the CouchDB versions of both the source and destination CouchDB installations?

Aftabalamrana commented 5 years ago

couchDB 2.3.1 (using in docker) i want to copy data from one database to another database for backup purpose (on local machine)

rjcorwin commented 5 years ago

I think I understand. Just to confirm, you are trying to replicate between databases on the same CouchDB installation? If so, try having the CouchDB installation address itself at http://localhost:5984 as opposed to http://any:5984.

Also, I'm not familiar with the http://any convention as a loopback address, is that something you added to your /etc/hosts file on your host machine?

rjcorwin commented 5 years ago

Example:

Screen Shot 2019-09-03 at 9 06 35 AM
Aftabalamrana commented 5 years ago

I think i am missing something here

got following response with status code 500:

{
    "error": "replication_auth_error",
    "reason": "{session_request_failed,\"http://127.0.0.1:32816/_session\",\"comhar\",\n                        {conn_failed,{error,econnrefused}}}"
}
Aftabalamrana commented 5 years ago

Tried UI as well though i want it using api only

Screenshot 2019-09-03 at 2 14 52 PM Screenshot 2019-09-03 at 2 15 44 PM

rjcorwin commented 5 years ago

From inside the container created using the installation process for Tangerine outlined here, the port to address CouchDB is 5984 as opposed to 32816. That's strange that using the UI would fail there.

rjcorwin commented 5 years ago

@Aftabalamrana Is this a CouchDB installation you are hoping to use as the database for a Tangerine installation?

Aftabalamrana commented 5 years ago

i mapped port 5984 to 32816 in docker compose couchdb is available at localhost:32816 and both source and target dbs

rjcorwin commented 5 years ago

We don't currently use Docker Compose to start Tangerine. Are you trying to use CouchDB with Tangerine? If so, give the scripts we wrote a try as detailed in our documentation.

Aftabalamrana commented 5 years ago

Tangerine

no i am not using Tangerine

rjcorwin commented 5 years ago

I think you are looking for the CouchDB issue queue :) . https://github.com/apache/couchdb

chrisekelley commented 4 years ago

I hit this same issue again this weekend!

root@70abfedfee92:/# curl -X POST http://admin:password@127.0.0.1:5984/_replicate  -d '{"source":"group-8575d794-c3fc-45b8-ac1c-f335f1584e82", "target":"http://admin:password@127.0.0.1:5984/group-58093841-eaeb-4e51-8675-29757d71fd35", "doc_ids": [ "_design/shared_conflicts" ]}' -H "Content-Type: application/json"

{"error":"replication_auth_error","reason":"{session_request_failed,\"http://any:5984/_session\",\"admin\",\n                        {conn_failed,{error,nxdomain}}}"}

Removing doc_ids let it pass, but did not replicate the _design docs:

root@70abfedfee92:/# curl -X POST http://admin:password@127.0.0.1:5984/_replicate  -d '{"source":"http://admin:password@localhost:5984/group-8575d794-c3fc-45b8-ac1c-f335f1584e82", "target":"http://admin:password@127.0.0.1:5984/group-58093841-eaeb-4e51-8675-29757d71fd35"}' -H "Content-Type: application/json"

{"ok":true,"no_changes":true,"session_id":"52a5e1253c8ba70d9a628771e1c09fa0","source_last_seq":"6-g1AAAAIXeJyV0UEOgjAQBdAKJurCM-gRWkBaVnITnWZKkGC7UNd6E72J3kRvgsWaIBoS3EyTSf9Lf1oSQsa5j2SqjTaoUm1ys9uXdu0BkbOqqorch8HWLkYYByAp_77cEZdzO-WyJYTRIsg47SuktbB6C8QJCcooZkgmB40q22iFXel1nT620oktoBjvkdZDO8nJHhY4Nw04hIxy0bOBUy5OudaK91IEQgig_lJuTrk3bRRXAmjQu83DCZ8_miEK9vOO4gmSVKMD","replication_id_version":4,"history":[{"session_id":"52a5e1253c8ba70d9a628771e1c09fa0","start_time":"Sat, 08 Feb 2020 01:09:01 GMT","end_time":"Sat, 08 Feb 2020 01:09:04 GMT","start_last_seq":0,"end_last_seq":"6-g1AAAAIXeJyV0UEOgjAQBdAKJurCM-gRWkBaVnITnWZKkGC7UNd6E72J3kRvgsWaIBoS3EyTSf9Lf1oSQsa5j2SqjTaoUm1ys9uXdu0BkbOqqorch8HWLkYYByAp_77cEZdzO-WyJYTRIsg47SuktbB6C8QJCcooZkgmB40q22iFXel1nT620oktoBjvkdZDO8nJHhY4Nw04hIxy0bOBUy5OudaK91IEQgig_lJuTrk3bRRXAmjQu83DCZ8_miEK9vOO4gmSVKMD","recorded_seq":"6-g1AAAAIXeJyV0UEOgjAQBdAKJurCM-gRWkBaVnITnWZKkGC7UNd6E72J3kRvgsWaIBoS3EyTSf9Lf1oSQsa5j2SqjTaoUm1ys9uXdu0BkbOqqorch8HWLkYYByAp_77cEZdzO-WyJYTRIsg47SuktbB6C8QJCcooZkgmB40q22iFXel1nT620oktoBjvkdZDO8nJHhY4Nw04hIxy0bOBUy5OudaK91IEQgig_lJuTrk3bRRXAmjQu83DCZ8_miEK9vOO4gmSVKMD","missing_checked":6,"missing_found":0,"docs_read":0,"docs_written":0,"doc_write_failures":0}]}

I also got the mysterious "any" ip:

root@70abfedfee92:/# curl -X POST http://admin:password@127.0.0.1:5984/_replicate  -d '{"source":"group-8575d794-c3fc-45b8-ac1c-f335f1584e82", "target":"http://admin:password@127.0.0.1:5984/group-58093841-eaeb-4e51-8675-29757d71fd35", "doc_ids": [ "_design/shared_conflicts" ]}' -H "Content-Type: application/json"

{"error":"replication_auth_error","reason":"{session_request_failed,\"http://any:5984/_session\",\"admin\",\n                        {conn_failed,{error,nxdomain}}}"}

We may have been hitting some various Couchdb 2.0 issues, which may be ameliorated in Couchdb 3.0, which was recently released. Here is an issue that may be related: https://github.com/apache/couchdb/issues/2440

Kipsanga-Gregory commented 3 years ago

I am hitting this same issue several times lately, I have same docker instace of couchdb installed on several raspberry pi devices, each should be replicating to a master db hosted at IBM, however it works pretty well in most devices but fails in a few

Error: {session_request_failed,"https://xxxxx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-bluemix.cloudantnosqldb.appdomain.cloud/_session", "a24a020c-fcf1-48ad-b253-68fcb8750371-bluemix", {conn_failed,{error,nxdomain}}}

'xx-xxx-xxx' being my identifier at ibm cloudant