About the sync strategy in couchdb clusters
Description
Hi CouchDB developers,
We're running into a problem when joining a new node to the existing cluster.
It seems when a node is joining into the existing cluster late. It can works as a data proxy for the previous datas before it joins.
Steps to Reproduce
for example
1.we have a existing cluster with 2 nodes.
curl -X GET "http://xxx:[email protected]:5984/_membership" {"all_nodes":["[email protected]","[email protected]"],"cluster_nodes":["[email protected]","[email protected]"]}
2.We create some databases in the clusters.
3.we join the third node into the clusters.
like create database "test0"
curl -X GET "http://xxx:[email protected]:5984/_membership" {"all_nodes":["[email protected]","[email protected]","[email protected]"],"cluster_nodes":["[email protected]","[email protected]","[email protected]"]}
- we stop the 2 couchdb nodes (xxx-01.gtlc.only.sap and xxx-02.gtlc.only.sap).
5.we visit the web UI page.
curl -X GET "http://xxx:[email protected]:5984/_utils
6.Then it show the error "This database failed to load."

7.When we turn to /var/log/couchdb/couch.log
[error] 2021-08-12T07:34:54.494893Z [email protected] <0.7099.5> f498a7c904 req_err(4070834315) internal_server_error : No DB shards could be opened. [<<"fabric_util:get_shard/4 L111">>,<<"fabric:get_security/2 L183">>,<<"chttpd_auth_request:db_authorization_check/1 L110">>,<<"chttpd_auth_request:authorize_request/1 L19">>,<<"chttpd:handle_req_after_auth/2 L321">>,<<"chttpd:process_request/1 L306">>,<<"chttpd:handle_request_int/1 L244">>,<<"mochiweb_http:headers/6 L150">>] [notice] 2021-08-12T07:34:54.495084Z [email protected] <0.7099.5> f498a7c904 sw360dev-03.gtlc.only.sap:5984 10.128.61.231 admin GET /test0 500 ok 1
8.I guess the root cause might be the data is only stored in node1 and node2, how can we copy that safely from node1 / node2 to node3 to make sure node3 can present the data though node 1 and node2 are both down.
Expected Behaviour
How can we make sure when a node joins the existing cluster, the previous data can also be synced to the disk on the third node machine? Then when the node1 and node2 is down, the node3 can also present the datas stored in node1 and node2.
Your Environment
- CouchDB version used: v3.1.1
- Browser name and version: safari
- Operating system and version: Redhat (Linux version 3.10.0-1160.36.2.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Thu Jul 8 02:53:40 UTC 2021)
Thank you very much!
Hi @zhangjingcat
Your guess about the root cause is correct, CouchDB does not automatically rebalance data on a new joined node, you'll need to update db's meta and sync shards manually, as described in shard management section of the documentation.
I realize that the process in the documentation is somehow involved, so I did a quick practical write up on the whole procedure: https://gist.github.com/eiri/2efc1b0ef401a21c51cd534871c20d30#file-readme-md
I hope it'll be helpful.
I realize that the process in the documentation is somehow involved, so I did a quick practical write up on the whole procedure: https://gist.github.com/eiri/2efc1b0ef401a21c51cd534871c20d30#file-readme-md
I hope it'll be helpful.
Hi Eiri,
Thank you a lot for your kind reply! The guide helped us a lot : )
@zhangjingcat Glad to hear that. I'm going to close this issue then.