Lab3 - panic: runtime error: invalid memory address or nil pointer dereference

Hi,
The network works fine in Lab 2, with both peers for Org1 running fine. However, when I add couchDb container for the peer0 I get the following error when trying to start the network.
With this command in the ./bootstrap.sh:
docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com couchdbOrg1Peer0 peer0.org1.example.com
I post two errors below, the first is from the CLI, the second from the peer0 container logs. I believe the error in CLI derives due to the error in the peer0 container, which automatically exists after trying to start.
Anyone know why the container for peer0 has an runtime error, after adding couchDb to the yaml file? The yaml file is copy-paste from course folder, so should not be any errors related to code.
The following error occur in the CLI when starting the network:
Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c allarewelcome -f /etc/hyperledger/configtx/allarewelcome.tx
2019-11-22 14:39:38.531 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-22 14:39:38.551 UTC [cli.common] readBlock -> INFO 002 Received block: 0
Join peer0.org1.example.com to the channel.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel join -b allarewelcome.block
2019-11-22 14:39:38.824 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: proposal failed (err: rpc error: code = Unavailable desc = transport is closing)
The following error is from the peer0 container logs:
2019-11-22 14:39:20.308 UTC [nodeCmd] registerDiscoveryService -> INFO 023 Discovery service activated
2019-11-22 14:39:20.309 UTC [nodeCmd] serve -> INFO 024 Starting peer with ID=[name:"peer0.org1.example.com" ], network ID=[dev], address=[peer0.org1.example.com:7051]
2019-11-22 14:39:20.309 UTC [nodeCmd] serve -> INFO 025 Started peer with ID=[name:"peer0.org1.example.com" ], network ID=[dev], address=[peer0.org1.example.com:7051]
2019-11-22 14:39:38.828 UTC [endorser] callChaincode -> INFO 026 [][e229996d] Entry chaincode: name:"cscc"
2019-11-22 14:39:38.829 UTC [ledgermgmt] CreateLedger -> INFO 027 Creating ledger [allarewelcome] with genesis block
2019-11-22 14:39:38.831 UTC [fsblkstorage] newBlockfileMgr -> INFO 028 Getting block information from block storage
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xcecbb6]
goroutine 160 [running]:
github.com/hyperledger/fabric/core/chaincode/shim.(Handler).triggerNextState(0xc000241da0, 0x0, 0xc00009f560)
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/handler.go:35 +0x26
github.com/hyperledger/fabric/core/chaincode/shim.(Handler).handleTransaction.func1.1(0xc000241da0, 0xc00036deb0, 0xc00009f560)
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/handler.go:247 +0x42
panic(0x106e340, 0x1e32280)
/opt/go/src/runtime/panic.go:513 +0x1b9
github.com/hyperledger/fabric/core/ledger/kvledger.(Provider).openInternal(0xc00014c780, 0xc000459d80, 0xd, 0x0, 0x0, 0x0, 0x27)
/opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/kv_ledger_provider.go:157 +0xf5
github.com/hyperledger/fabric/core/ledger/kvledger.(Provider).Create(0xc00014c780, 0xc000083700, 0x27, 0xc00036d7a8, 0x1, 0x1)
/opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/kv_ledger_provider.go:117 +0x102
github.com/hyperledger/fabric/core/ledger/ledgermgmt.CreateLedger(0xc000083700, 0x0, 0x0, 0x0, 0x0)
/opt/gopath/src/github.com/hyperledger/fabric/core/ledger/ledgermgmt/ledger_mgmt.go:97 +0x17b
github.com/hyperledger/fabric/core/peer.CreateChainFromBlock(0xc000083700, 0x1378f60, 0xc00013e890, 0x1383c80, 0xc0003412c0, 0x1, 0x1)
/opt/gopath/src/github.com/hyperledger/fabric/core/peer/peer.go:436 +0x7b
github.com/hyperledger/fabric/core/scc/cscc.joinChain(0xc0004598e0, 0xd, 0xc000083700, 0x1378f60, 0xc00013e890, 0x1383c80, 0xc0003412c0, 0x0, 0x0, 0x0, ...)
/opt/gopath/src/github.com/hyperledger/fabric/core/scc/cscc/configure.go:236 +0x79
github.com/hyperledger/fabric/core/scc/cscc.(PeerConfiger).InvokeNoShim(0xc0003417c0, 0xc0004232c0, 0x2, 0x2, 0xc0000be0a0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/opt/gopath/src/github.com/hyperledger/fabric/core/scc/cscc/configure.go:164 +0x692
github.com/hyperledger/fabric/core/scc/cscc.(PeerConfiger).Invoke(0xc0003417c0, 0x1390b60, 0xc0001fc210, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/opt/gopath/src/github.com/hyperledger/fabric/core/scc/cscc/configure.go:120 +0x29b
github.com/hyperledger/fabric/core/chaincode/shim.(Handler).handleTransaction.func1(0xc000241da0, 0xc00009f560, 0xc0002cc300)
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/handler.go:273 +0x4eb
created by github.com/hyperledger/fabric/core/chaincode/shim.(Handler).handleTransaction
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/handler.go:242 +0x53
Comments
-
However, after the network has started and peer0 container exited, I can start the container manually with docker-compose command. But, when I then go into the peer0 container and run: channel list
I receive the same error in CLI:
nik@nik-ThinkPad-T470s:~/Desktop/fabric-samples/startFiles$ docker exec -it peer0.org1.example.com bash
root@25ac5fb30d1f:/opt/gopath/src/github.com/hyperledger/fabric# ls
allarewelcome.block
root@25ac5fb30d1f:/opt/gopath/src/github.com/hyperledger/fabric# peer channel list
2019-11-22 15:29:13.499 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: Failed sending proposal, got rpc error: code = Unavailable desc = transport is closing0 -
Anyone that could know what the issue here is?
0 -
This is the log from inside the peer 0 container:
root@25ac5fb30d1f:/opt/gopath/src/github.com/hyperledger/fabric# export CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp
root@25ac5fb30d1f:/opt/gopath/src/github.com/hyperledger/fabric# peer channel fetch oldest allarewelcome.block -c allarewelcome --orderer orderer.example.com:7050
2019-11-26 09:04:06.486 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-26 09:04:06.488 UTC [cli.common] readBlock -> INFO 002 Received block: 0
root@25ac5fb30d1f:/opt/gopath/src/github.com/hyperledger/fabric# peer channel list
2019-11-26 09:04:17.446 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: Failed sending proposal, got rpc error: code = Unavailable desc = transport is closing
root@25ac5fb30d1f:/opt/gopath/src/github.com/hyperledger/fabric# peer channel join -b allarewelcome.block
2019-11-26 09:04:52.416 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: proposal failed (err: rpc error: code = Unavailable desc = transport is closing)0 -
After error testing for several hours I believe this has to be the specific error, this is from peer0 container which exists right after the network starts. Orderer node log say nothing about any errors. this is the peer0 log:
2019-11-26 10:29:00.236 UTC [ledgermgmt] CreateLedger -> INFO 021 Creating ledger [allarewelcome] with genesis block
2019-11-26 10:29:00.238 UTC [fsblkstorage] newBlockfileMgr -> INFO 022 Getting block information from block storage
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xcecbb6]goroutine 156 [running]:
github.com/hyperledger/fabric/core/chaincode/shim.(Handler).triggerNextState(0xc001dd2180, 0x0, 0xc0001b5440)
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/handler.go:35 +0x26
github.com/hyperledger/fabric/core/chaincode/shim.(Handler).handleTransaction.func1.1(0xc001dd2180, 0xc000343eb0, 0xc0001b5440)
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim/handler.go:247 +0x42
panic(0x106e340, 0x1e32280)
/opt/go/src/runtime/panic.go:513 +0x1b9
github.com/hyperledger/fabric/core/ledger/kvledger.(Provider).openInternal(0xc000442880, 0xc001e8aff0, 0xd, 0x0, 0x0, 0x0, 0x27)
/opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/kv_ledger_provider.go:157 +0xf5
github.com/hyperledger/fabric/core/ledger/kvledger.(Provider).Create(0xc000442880, 0xc001da8a40, 0x27, 0xc0003437a8, 0x1, 0x1)
/opt/gopath/src/github.com/hyperledger/fabric/core/ledger/kvledger/kv_ledger_provider.go:117 +0x102
github.com/hyperledger/fabric/core/ledger/ledgermgmt.CreateLedger(0xc001da8a40, 0x0, 0x0, 0x0, 0x0)0 -
This is the error I receive in the couchdb container logs:
[info] 2019-11-26T10:28:38.398968Z nonode@nohost <0.195.0> -------- Apache CouchDB has started on http://any:5986/
[info] 2019-11-26T10:28:38.399538Z nonode@nohost <0.7.0> -------- Application couch started on node nonode@nohost
[info] 2019-11-26T10:28:38.399838Z nonode@nohost <0.7.0> -------- Application ets_lru started on node nonode@nohost
[info] 2019-11-26T10:28:38.428548Z nonode@nohost <0.7.0> -------- Application rexi started on node nonode@nohost
[info] 2019-11-26T10:28:38.441617Z nonode@nohost <0.201.0> -------- open_result error {not_found,no_db_file} for _nodes
[warning] 2019-11-26T10:28:38.441655Z nonode@nohost <0.271.0> -------- creating missing database: _nodes
[info] 2019-11-26T10:28:38.470566Z nonode@nohost <0.201.0> -------- open_result error {not_found,no_db_file} for _dbs
[warning] 2019-11-26T10:28:38.470600Z nonode@nohost <0.285.0> -------- creating missing database: _dbs
[warning] 2019-11-26T10:28:38.470639Z nonode@nohost <0.284.0> -------- creating missing database: _dbs
[info] 2019-11-26T10:28:38.478597Z nonode@nohost <0.7.0> -------- Application mem3 started on node nonode@nohost
[info] 2019-11-26T10:28:38.478957Z nonode@nohost <0.7.0> -------- Application fabric started on node nonode@nohost
[info] 2019-11-26T10:28:38.529437Z nonode@nohost <0.7.0> -------- Application chttpd started on node nonode@nohost
[notice] 2019-11-26T10:28:38.553132Z nonode@nohost <0.322.0> -------- chttpd_auth_cache changes listener died database_does_not_exist at mem3_shards:load_shards_from_db/6(line:395) <= mem3_shards:load_shards_from_disk/1(line:370) <= mem3_shards:load_shards_from_disk/2(line:399) <= mem3_shards:for_docid/3(line:86) <= fabric_doc_open:go/3(line:38) <= chttpd_auth_cache:ensure_auth_ddoc_exists/2(line:187) <= chttpd_auth_cache:listen_for_changes/1(line:134)
[error] 2019-11-26T10:28:38.555361Z nonode@nohost emulator -------- Error in process <0.323.0> with exit value:
{database_does_not_exist,[{mem3_shards,load_shards_from_db,"_users",[{file,"src/mem3_shards.erl"},{line,395}]},{mem3_shards,load_shards_from_disk,1,[{file,"src/mem3_shards.erl"},{line,370}]},{mem3_shards,load_shards_from_disk,2,[{file,"src/mem3_shards.erl"},{line,399}]},{mem3_shards,for_docid,3,[{file,"src/mem3_shards.erl"},{line,86}]},{fabric_doc_open,go,3,[{file,"src/fabric_doc_open.erl"},{line,38}]},{chttpd_auth_cache,ensure_auth_ddoc_exists,2,[{file,"src/chttpd_auth_cache.erl"},{line,187}]},{chttpd_auth_cache,listen_for_changes,1,[{file,"src/chttpd_auth_cache.erl"},{line,134}]}]}0 -
What is the CORE_PEER_ADDRESS environment variable set to? If incorrect, or not set, this can lead to the error you're seeing...
1 -
@btaadmin said:
What is the CORE_PEER_ADDRESS environment variable set to? If incorrect, or not set, this can lead to the error you're seeing...Hi @btaadmin ,
I checked both compose-yaml and the env variables in container itself, seems all fine. Also the couchDB is running as expected. Here is additional information, as I am very unsure about what the issue migth be.
core.yml:
ledger:
blockchain:
state:
# stateDatabase - options are "goleveldb", "CouchDB"
# goleveldb - default state database stored in goleveldb.
# CouchDB - store state database in CouchDB
stateDatabase: CouchDB
# Limit on the number of records to return per query
totalQueryLimit: 100000
couchDBConfig:
# It is recommended to run CouchDB on the same server as the peer, and
# not map the CouchDB container port to a server port in docker-compose.
# Otherwise proper security must be provided on the connection between
# CouchDB client (on the peer) and server.
couchDBAddress: 127.0.0.1:5984
# This username must have read and write authority on CouchDB
username:
# The password is recommended to pass as an environment variable
# during start up (eg LEDGER_COUCHDBCONFIG_PASSWORD).
# If it is stored here, the file must be access control protected
# to prevent unintended users from discovering the password.
password:
# Number of retries for CouchDB errors
maxRetries: 3
# Number of retries for CouchDB errors during peer startup
maxRetriesOnStartup: 12
# CouchDB request timeout (unit: duration, e.g. 20s)
requestTimeout: 35s
# Limit on the number of records per each CouchDB query
# Note that chaincode queries are only bound by totalQueryLimit.
# Internally the chaincode may execute multiple CouchDB queries,
# each of size internalQueryLimit.
internalQueryLimit: 1000
# Limit on the number of records per CouchDB bulk update batch
maxBatchUpdateSize: 1000
# Warm indexes after every N blocks.
# This option warms any indexes that have been
# deployed to CouchDB after every N blocks.
# A value of 1 will warm indexes after every block commit,
# to ensure fast selector queries.
# Increasing the value may improve write efficiency of peer and CouchDB,
# but may degrade query response time.
warmIndexesAfterNBlocks: 1
# Create the _global_changes system database
# This is optional. Creating the global changes database will require
# additional system resources to track changes and maintain the database
createGlobalChangesDB: falsedocker-compose.yml:
peer0.org1.example.com:
container_name: peer0.org1.example.com
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org1.example.com
- FABRIC_LOGGING_SPEC=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=startFiles_basic
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdbOrg1Peer0:5984
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=peer0.Org1
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=password
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
# command: peer node start --peer-chaincodedev=true
ports:
- 7051:7051
- 7053:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.example.com
- couchdbOrg1Peer0
networks:
- basiccouchdbOrg1Peer0:
container_name: couchdbOrg1Peer0
image: hyperledger/fabric-couchdb
environment:
- COUCHDB_USER=peer0.Org1
- COUCHDB_PASSWORD=password
ports:
- "5984:5984"
networks:
- basicFrom the CLI logs
user:~/Desktop/fabric-samples$ curl http://127.0.0.1:5984/
{"couchdb":"Welcome","version":"2.2.0","git_sha":"2a16ec4","features":["pluggable-storage-engines","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}user:docker exec -it peer0.org1.example.com bashroot@ba0c7f2796b6:/opt/gopath/src/github.com/hyperledger/fabric# printenv
CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdbOrg1Peer0:5984
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
CORE_CHAINCODE_LOGGING_LEVEL=info
CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=password
FABRIC_LOGGING_SPEC=info
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/opt/gopath/src/github.com/hyperledger/fabric
CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=startFiles_basic
CORE_PEER_ID=peer0.org1.example.com
SHLVL=1
HOME=/root
FABRIC_CFG_PATH=/etc/hyperledger/fabric
CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=peer0.Org1
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
CORE_LEDGER_STATE_STATEDATABASE=CouchDB
_=/usr/bin/printenv0 -
Is anyone actually getting their questions answered in this forum, I've been stuck for several days and my posts never get approved. I want a refund!
1 -
Hi, I found the solution:
CouchDB has done an upgrade that is not compatible with the old fabric docker images. Please delete old peer image and pull down the new one to version 1.4.4 - latest, then re-create the network. It works now as expected.0 -
Hi, I've the same issue. I've pulled the latest couchdb image but still the error persists. Can someone help?
0 -
@Brintha18 said:
Hi, I've the same issue. I've pulled the latest couchdb image but still the error persists. Can someone help?Hi @Brintha18 , what version is currently latest? Since Fabric has upgraded to version 2, it might be that the latest couchdb image is adapted to that. This course uses Fabric version 1.4, so I would recommend to try the couchdb version 1.4.4. Let me know how it goes.
0
Categories
- All Categories
- 51 LFX Mentorship
- 104 LFX Mentorship: Linux Kernel
- 576 Linux Foundation IT Professional Programs
- 304 Cloud Engineer IT Professional Program
- 125 Advanced Cloud Engineer IT Professional Program
- 53 DevOps Engineer IT Professional Program
- 61 Cloud Native Developer IT Professional Program
- 5 Express Training Courses
- 5 Express Courses - Discussion Forum
- 2K Training Courses
- 19 LFC110 Class Forum
- 7 LFC131 Class Forum
- 27 LFD102 Class Forum
- 157 LFD103 Class Forum
- 20 LFD121 Class Forum
- 1 LFD137 Class Forum
- 61 LFD201 Class Forum
- 1 LFD210 Class Forum
- LFD210-CN Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum
- LFD237 Class Forum
- 23 LFD254 Class Forum
- 611 LFD259 Class Forum
- 105 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- 1 LFD273 Class Forum
- 2 LFS145 Class Forum
- 24 LFS200 Class Forum
- 739 LFS201 Class Forum
- 1 LFS201-JP クラス フォーラム
- 11 LFS203 Class Forum
- 75 LFS207 Class Forum
- 300 LFS211 Class Forum
- 54 LFS216 Class Forum
- 47 LFS241 Class Forum
- 41 LFS242 Class Forum
- 37 LFS243 Class Forum
- 11 LFS244 Class Forum
- 36 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 140 LFS253 Class Forum
- LFS254 Class Forum
- 1.1K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 93 LFS260 Class Forum
- 132 LFS261 Class Forum
- 33 LFS262 Class Forum
- 80 LFS263 Class Forum
- 15 LFS264 Class Forum
- 11 LFS266 Class Forum
- 18 LFS267 Class Forum
- 17 LFS268 Class Forum
- 23 LFS269 Class Forum
- 203 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- LFS281 Class Forum
- 235 LFW211 Class Forum
- 172 LFW212 Class Forum
- 7 SKF100 Class Forum
- SKF200 Class Forum
- 902 Hardware
- 219 Drivers
- 74 I/O Devices
- 44 Monitors
- 115 Multimedia
- 209 Networking
- 101 Printers & Scanners
- 85 Storage
- 763 Linux Distributions
- 88 Debian
- 66 Fedora
- 15 Linux Mint
- 13 Mageia
- 24 openSUSE
- 142 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 357 Ubuntu
- 479 Linux System Administration
- 41 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 95 Linux Security
- 78 Network Management
- 108 System Management
- 49 Web Management
- 68 Mobile Computing
- 23 Android
- 30 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 537 Off Topic
- 131 Introductions
- 217 Small Talk
- 21 Study Material
- 826 Programming and Development
- 278 Kernel Development
- 514 Software Development
- 928 Software
- 260 Applications
- 184 Command Line
- 3 Compiling/Installing
- 76 Games
- 316 Installation
- 62 All In Program
- 62 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)