hyperledger / fabric

Hyperledger Fabric is an enterprise-grade permissioned distributed ledger framework for developing solutions and applications. Its modular and versatile design satisfies a broad range of industry use cases. It offers a unique approach to consensus that enables performance at scale while preserving privacy.
https://wiki.hyperledger.org/display/fabric
Apache License 2.0
15.56k stars 8.79k forks source link

Couchdb database does not exist and peer panic #4314

Open bh4rtp2023 opened 12 months ago

bh4rtp2023 commented 12 months ago

Description

I am using fabric-2.5.3 on SUSE Linux Enterprise Server. Couchdb keeps printing

[notice] 2023-07-12T01:57:58.129825Z nonode@nohost <0.829.0> -------- chttpd_auth_cache changes listener died because the _users database does not exist. Create the database to silence this notice. [error] 2023-07-12T01:57:58.130301Z nonode@nohost emulator -------- Error in process <0.3577.0> with exit value: {database_does_not_exist,[{mem3_shards,load_shards_from_db,"_users",[{file,"src/mem3_shards.erl"},{line,430}]},{mem3_shards,load_shards_from_disk,1,[{file,"src/mem3_shards.erl"},{line,405}]},{mem3_shards,load_shards_from_disk,2,[{file,"src/mem3_shards.erl"},{line,434}]},{mem3_shards,for_docid,3,[{file,"src/mem3_shards.erl"},{line,100}]},{fabric_doc_open,go,3,[{file,"src/fabric_doc_open.erl"},{line,39}]},{chttpd_auth_cache,ensure_auth_ddoc_exists,2,[{file,"src/chttpd_auth_cache.erl"},{line,214}]},{chttpd_auth_cache,listen_for_changes,1,[{file,"src/chttpd_auth_cache.erl"},{line,160}]}]}

To avoid _users not created error, I set [couchdb] single_node=true in my local.ini to turn on single node setup and make couchdb create _users, _replicator and _global_changes itself. This time couchdb will not tell any error as above. But peer will panic with following logs:

2023-07-12 10:39:00.069 CST 000b INFO [ledgermgmt] NewLedgerMgr -> Initializing LedgerMgr
2023-07-12 10:39:00.281 CST 000c WARN [couchdb] handleRequest -> Attempt 1 of 11 returned error: Get "http://couchdb0:5984/": dial tcp 10.0.1.17:5984: connect: connection refused. Retrying couchdb request in 125ms
...
2023-07-12 10:40:04.173 CST 0015 WARN [couchdb] handleRequest -> Attempt 10 of 11 returned error: Get "http://couchdb0:5984/": dial tcp 10.0.1.17:5984: connect: connection refused. Retrying couchdb request in 1m4s
2023-07-12 10:41:08.175 CST 0016 WARN [couchdb] handleRequest -> Attempt 11 of 11 returned error: Get "http://couchdb0:5984/": dial tcp 10.0.1.17:5984: connect: connection refused. Retries exhausted
panic: Error in instantiating ledger provider: Get "http://couchdb0:5984/": dial tcp 10.0.1.17:5984: connect: connection refused
http error calling couchdb
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.(*couchInstance).handleRequest
    /go/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go:1714
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.(*couchInstance).verifyCouchConfig
    /go/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go:353
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.createCouchInstance
    /go/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdbutil.go:88
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb.NewVersionedDBProvider
    /go/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go:56
github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/privacyenabledstate.NewDBProvider
    /go/src/github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/privacyenabledstate/db.go:66
github.com/hyperledger/fabric/core/ledger/kvledger.(*Provider).initStateDBProvider
    /go/src/github.com/hyperledger/fabric/core/ledger/kvledger/kv_ledger_provider.go:234
github.com/hyperledger/fabric/core/ledger/kvledger.NewProvider
    /go/src/github.com/hyperledger/fabric/core/ledger/kvledger/kv_ledger_provider.go:118
github.com/hyperledger/fabric/core/ledger/ledgermgmt.NewLedgerMgr
    /go/src/github.com/hyperledger/fabric/core/ledger/ledgermgmt/ledger_mgmt.go:71
github.com/hyperledger/fabric/internal/peer/node.serve
    /go/src/github.com/hyperledger/fabric/internal/peer/node/start.go:445
github.com/hyperledger/fabric/internal/peer/node.glob..func6
    /go/src/github.com/hyperledger/fabric/internal/peer/node/start.go:130
github.com/spf13/cobra.(*Command).execute
    /go/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:852
github.com/spf13/cobra.(*Command).ExecuteC
    /go/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:960
github.com/spf13/cobra.(*Command).Execute
    /go/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:897
main.main
    /go/src/github.com/hyperledger/fabric/cmd/peer/main.go:56
runtime.main
    /usr/local/go/src/runtime/proc.go:250
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:1598
unable to connect to CouchDB, check the hostname and port

goroutine 1 [running]:
github.com/hyperledger/fabric/core/ledger/ledgermgmt.NewLedgerMgr(0xc000497a28)
    /go/src/github.com/hyperledger/fabric/core/ledger/ledgermgmt/ledger_mgmt.go:85 +0x605
github.com/hyperledger/fabric/internal/peer/node.serve({0x15f3ac0?, 0xc000497d30?, 0xc000497d08?})
    /go/src/github.com/hyperledger/fabric/internal/peer/node/start.go:445 +0x2409
github.com/hyperledger/fabric/internal/peer/node.glob..func6(0x26a91a0?, {0x273e458?, 0x0?, 0x0?})
    /go/src/github.com/hyperledger/fabric/internal/peer/node/start.go:130 +0x56
github.com/spf13/cobra.(*Command).execute(0x26a91a0, {0x273e458, 0x0, 0x0})
    /go/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:852 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0x26a9ba0)
    /go/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:960 +0x39d
github.com/spf13/cobra.(*Command).Execute(...)
    /go/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:897
main.main()
    /go/src/github.com/hyperledger/fabric/cmd/peer/main.go:56 +0x352

However, I test connect couchdb0 with command: $ curl http://admin:adminpw@couchdb0:5984/ It does work.

Steps to reproduce

No response

harsha7696 commented 10 months ago

If you're able to successfully connect to CouchDB using the curl command with the provided credentials and URL (http://admin:adminpw@couchdb0:5984/), then it indicates that CouchDB is reachable and the credentials are correct.

Given this information, it's possible that the issue lies within the Hyperledger Fabric setup or configuration Ensure that your Hyperledger Fabric configuration is correctly pointing to the CouchDB instance. This includes the settings in your core.yaml or related configuration files. Double-check the host, port, credentials, and database names.

Sometimes, containers might have cached configurations that are causing issues. Try stopping and removing the existing Hyperledger Fabric containers, and then recreate them. This can help ensure that the containers start with fresh configurations.

you can use this code snippet: docker stop docker rm