Fabric錯誤場景

常見Fabric錯誤場景

1. Error: error getting endorser client for channel: endorser client failed to connect to orderer.rabbit.com:8051: failed to create new connection: context deadline exceeded

緣由:CORE_PEER_ADDRESS=orderer.rabbit.com:8051 地址不對或peer節點未啓動git

2. Error: proposal failed (err: bad proposal response 500: access denied for [JoinChain][testc2]: [Failed verifying that proposal's creator satisfies local MSP principal during channelless check policy with policy [Admins]: [This identity is not an admin]])

緣由:CORE_PEER_MSPCONFIGPATH=crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp msp地址未設置,或設置的地址不是admingithub

3. Error: failed to create deliver client: orderer client failed to connect to 192.168.127.129:7050: failed to create new connection: context deadline exceeded

緣由:orderer節點地址不對,或orderer節點未啓動golang

4. Error: got unexpected status: BAD_REQUEST -- error authorizing update: error validating ReadSet: readset expected key [Group] /Channel/Application at version 0, but got version 1

緣由:通道已建立docker

5. got unexpected status: BAD_REQUEST -- error authorizing update: error validating DeltaSet: policy for [Group] /Channel/Application not satisfied: Failed to reach implicit threshold of 1 sub-policies, required 1 remaining

緣由:一般表示頻道建立事務的簽名者沒有其中一個聯盟組織的管理員權限
最多見的緣由是:
a) 該身份不在組織的管理員列表中。
b) 組織證書未由組織CA鏈有效簽署。
c) 定貨人不知道身份的組織。shell

其餘一些不太可能的可能性由於您使用的是對等二進制而不是自定義代碼
a) 簽名與標識或有符號字節不匹配。
b) 身份是畸形的。數組

6. Cannot run peer because error when setting up MSP of type bccsp from directory /home/wff/jaderabbit/echain1/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp: could not initialize BCCSP Factories: Failed initializing BCCSP.: Could not initialize BCCSP SW [Failed to initialize software key store: An invalid KeyStore path provided. Path cannot be an empty string.] Could not find default SW BCCSP

緣由:老版viper不會報錯,這是因爲你是用的最新版本的viper。若是你必定要使用最新版本的viper(我也想用),這裏也能夠提供一個不太正式的修改方案。
新版viper修改方法:github.com/hyperledger/fabric/peer/common/common.go服務器

// SetBCCSPKeystorePath sets the file keystore path for the SW BCCSP provider // to an absolute path relative to the config file func SetBCCSPKeystorePath() { if path := config.GetPath("peer.BCCSP.SW.FileKeyStore.KeyStore"); path != "" { viper.Set("peer.BCCSP.SW.FileKeyStore.KeyStore", path) } } 

7. resource temporarily unavailable

緣由:打開了相同的leveldb併發

8. error getting default signer: error obtaining the default signing identity: this MSP does not possess a valid default signing identity

緣由:未初始化MSP,能夠試試調用這個命令進行初始化less

common.InitCmd(nil,[]string{}) 

9. proposal failed (err: bad proposal response 500: cannot create ledger from genesis block: LedgerID already exists)

緣由:重複加入channelide

10. error getting endorser and deliver clients: no endorser clients retrieved - this might indicate a bug

獲取endorser客戶端時,peerAddresses是空數組,須是元素爲空串,長度爲1的數組

11. Bad configuration detected: Received AliveMessage from a peer with the same PKI-ID as myself: tag:EMPTY alive_msg:<membership:<pki_id:"\206\0367dH\361\312\347\300l\035@1v\356\030\003\233*\355\241\234\262zf\352\264\367w\007\302\226" > timestamp:<inc_num:1554097615134317977 seq_num:539 > >

使用了相同的msp證書

12. error: chaincode fingerprint mismatch: data mismatch

安裝鏈代碼時,基本流程的工做方式以下:

  1. 考慮到包括傳遞在內的全部依賴關係,它被打包到存檔文件中
  2. 使用golang環境在docker容器內複製並在那裏編譯
  3. 若是我沒有弄錯,下一個peer會創建新的chaincode容器並移動已編譯的二進制文件 /usr/bin/local/chaincode
    如今,問題在於$GOPATH您的計算機中極可能存在差別,所以在不一樣的計算機上安裝相同的鏈代碼會帶來不一樣的依賴關係,最終會產生不一樣的手指結果。
    您須要作的是將您的鏈代碼打包在一個地方並分發包以安裝它。
peer chaincode package -n name -v 1.0 -p path_to_your_chaincode 

13. Got error while committing(unexpected Previous block hash. Expected PreviousHash =

通道創始塊配置文件和orderer裏的創始塊配置不匹配

14. error: Error constructing Docker VM Name. 'dev1-trembling--human--rabbit_02-1.0-f21065c44f48dc8183241105b2a4dac241d062f17f6678c851c9d6989df58c71' breaks Docker's repository naming rules

core.yaml中的peer.id有特殊字符

15. Error: error endorsing chaincode: rpc error: code = Unknown desc = access denied: channel [syschannel] creator org [Org1MSP]

沒加入syschannel通道

  1. error Entry not found in index
    查詢的數據不存在。最直觀的可能就是你所查詢的數據是髒數據,源數據已經被清除,再查詢時,就會報這個錯誤

  2. 鏈碼間調用無力吐槽之一,chaincode裏面調用另外的chaincode時,錯誤是放在payload裏面的。

     
    InvokeChaincode.png

    解決方法:

     

args, channelID := [][]byte{[]byte(tee.MethodQueryDataByID), []byte(notificationID)}, stub.GetChannelID() response := stub.InvokeChaincode(tee.ChaincodeName, args, channelID) if response.Status != shim.OK { return nil, fmt.Errorf("error invoking chaincode %s[%s] to query notification in channel: %s, error: %v", tee.ChaincodeName, tee.MethodQueryDataByID, channelID, string(response.Payload)) } 
  1. 鏈碼間調用無力吐槽之二,不能併發調用同一個channel上的鏈碼(ps:到底怎麼想的?),由於在調用其餘鏈碼時,自己會維護一個responseMap,key是chaidID+txID,若是存在,則報錯channel exists
     
    併發調用

解決方法:老老實實一個個調用,上一個結果返回了再調用下一個。在我這裏,併發難處理?不存在的。

  1. Error: could not assemble transaction, err proposal response was not successful, error code 500, msg chaincode registration failed: container exited with 2
    鏈碼升級時報錯,重啓peer時發現啓動不了,原來我鏈碼中引用的一個config.go的文件,此文件有一個init函數會加載同目錄下的一個yaml配置文件。而fabric 的鏈碼打包安裝到docker時,並不會加載非go的文件,所以,實例化時找這個文件找不到就panic報錯了。因爲fabric啓動docker容器失敗會自動刪除docker容器,所以本應該能打印出來的錯誤被fabric給幹掉了,所以出現題乾的錯誤。謹記:全部的鏈碼,必須是純go文件寫的,無任何非go依賴,如c文件,yml文件等,不然必然報錯報錯報錯,還找不到緣由!!!

  2. Description: failed to execute transaction 10eb8d06f4c8f43b3f6bacb19b97230edda4fbf87527a7e47ba3d602674c49ec: [channel syschannel] could not launch chaincode basis:20191125152021-152f4433: chaincode registration failed: container exited with 0
    鏈碼調用時報錯,刪除全部的docker container和images再調用依然報錯,重啓peer後回覆正常。猜想是ip或是端口問題。留據存疑。

21.Error: got unexpected status: NOT_FOUND -- channel does not exist
實例化鏈碼時報錯,查詢節點加入的通道peer channel list時,發現已存在。緣由??未知。猜想,kafka集羣未初始化topic時,就加入了通道,致使實際通道加入失敗,但peer又已經記錄了通道狀態爲已加入?

  1. https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection
    實例化鏈碼時失敗報錯,緣由是服務器是不聯網的,而且本地的鏡像版本太低,致使服務器拉取最新的鏡像而聯網報錯。解決方案更新本地鏡像,docker save/docker load。

  2. cannot retrieve package for chaincode…, too many open files
    大併發invoke chaincode時報錯。

【分析】

因爲是生產代碼,想上生產環境須要先申請才能上去,爲加快查問題的速度,先從源碼分析一下錯誤產生的緣由

 
image.png
 
image.png
 
image.png

根據文件調用棧能夠看出,fabric在invoke鏈碼時會去檢查鏈碼的實例化策略,這是爲了防止有已經部署好的鏈碼是繞過了這個策略實例化的。因爲在檢查時,會去本地文件系統讀取鏈碼信息,當大量併發時,超過系統設置的文件句柄,因而報錯,too many open files.

【解決方案】

因爲peer在進行鏈碼調用時是由於要檢查鏈碼實例化策略才須要打開文件,且根據代碼顯示,打開文件是必要的(?),文件未寫入,且未佔用句柄不關閉,因此這裏的解決方案有:

    1. 臨時方案。加大系統句柄數,修改/etc/security/limits.conf文件,末尾加上
root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535
    1. 永久方案。考慮將文件信息加入內存,沒必要每次都打開,但這裏會出現必定的風險,也即文件和內存內容的同步,這裏能夠加入同步機制來處理。
      這裏,爲恢復環境爲第一要,先採用臨時方案,後續考慮永久方案。

    2. error received from Discovery Server: failed constructing descriptor for chaincodes:<name:"basis" >鏈碼調用時報這個錯,最後經過peer chaincodes list --instantiated -C mychannel測試發現,此臺機器未實例化,而集羣中的其餘機器是實例化過的,從新實例化鏈碼雖然不報錯,但仍然沒法實例化此臺機器。重啓此臺機器的peer後,通過短暫的同步恢復正常。懷疑多是併發實例化鏈碼時產生實例化檢查衝突致使本節點未啓動實例化任務。

相關文章
相關標籤/搜索