长安链采用mysql作为数据存储数据库时部署evm智能合约第一次会失败
【问题分类】
- bug
- 存储相关
【问题描述】
采用MySQL作为账本存储引擎,并修改chainmaker.yml中存储部分的配置,启动4节点单链环境,然后采用java-sdk部署示例的token.bin智能合约第一次失败。但是mysql数据库有创建新的智能合约库和表,只是因为部署失败表里边没有插入初始化数据。再发起一次部署合约调用,sdk返回成功,且新的智能合约库下边的表会正常插入初始化数据。
【相关日志文件】
chainmaker-go 的 log/system.log & bin/panic.log file *
2022-06-28 16:07:23.306 [ERROR] [Storage] @chain1 statesqldb/statesqldb.go:389 failed to read state, contract:6f34fcb7b62922896e99fab564b8de5520121713, key:,error:sql query error
2022-06-28 16:07:23.306 [ERROR] [Vm] @chain1 v2@v2.2.1/runtime.go:300 error encountered in contract [6f34fcb7b62922896e99fab564b8de5520121713] execution,tx: [4892b4e35bbcf8a15082797c0bf2ab0d32e48c184919fed9b1999cb97268aea4], error: [no such data in the storage: sql query error]
2022-06-28 16:07:23.307 [ERROR] [Vm] @chain1 v2@v2.2.1/runtime.go:148 failed to invoke evm, tx id:4892b4e35bbcf8a15082797c0bf2ab0d32e48c184919fed9b1999cb97268aea4, error:no such data in the storage: sql query error
2022-06-28 16:07:23.307 [ERROR] [Core] @chain1 scheduler/scheduler.go:432 failed to run vm for tx id:4892b4e35bbcf8a15082797c0bf2ab0d32e48c184919fed9b1999cb97268aea4, tx result:code:CONTRACT_FAIL contract_result:<code:1 message:"contract initial fail, no such data in the storage: sql query error" > , error:contract initial fail, no such data in the storage: sql query error
2022-06-28 16:07:23.359 [INFO] [Storage] @chain1 v2@v2.2.1/blockstore_impl.go:566 chain[chain1]: put block[2] common (txs:1, bytes: 18568), time used: marshal: 0, writeFile: 1, writeCache: 28, writeKvDB: 0, total: 30
通过java-sdk发起第一次部署token.bin合约响应信息
message: "OK"
contract_result {
code: 1
message: "contract initial fail, no such data in the storage: sql query error"
}
Mysql有新建statedb_chain1_6f34fcb7b62922896e99fab564b8de5520121713的数据库和对应的表,但state_infos表里边无初始化数据 再次使用java-sdk部署token.bin合约,成功响应信息
message: "OK"
contract_result {
result: "\n(6f34fcb7b62922896e99fab564b8de5520121713\022\0011\030\005*\266\b\n\030ljh-org2.qianjinlian.com\032\250\a-----BEGIN CERTIFICATE-----\nMIIChjCCAiygAwIBAgIDCa1LMAoGCCqBHM9VAYN1MIGRMQswCQYDVQQGEwJDTjES\nMBAGA1UECBMJR3Vhbmdkb25nMREwDwYDVQQHEwhTaGVuemhlbjEhMB8GA1UEChMY\nbGpoLW9yZzIucWlhbmppbmxpYW4uY29tMRIwEAYDVQQLEwlyb290LWNlcnQxJDAi\nBgNVBAMTG2NhLmxqaC1vcmcyLnFpYW5qaW5saWFuLmNvbTAeFw0yMjA2MTUwMzE3\nMzdaFw0yNzA2MTQwMzE3MzdaMIGYMQswCQYDVQQGEwJDTjESMBAGA1UECBMJR3Vh\nbmdkb25nMREwDwYDVQQHEwhTaGVuemhlbjEhMB8GA1UEChMYbGpoLW9yZzIucWlh\nbmppbmxpYW4uY29tMQ8wDQYDVQQLEwZjbGllbnQxLjAsBgNVBAMTJWNsaWVudDEu\nc2lnbi5samgtb3JnMi5xaWFuamlubGlhbi5jb20wWTATBgcqhkjOPQIBBggqgRzP\nVQGCLQNCAASq5pvLD74V4t7i5k6OpDgZVc3dKYnMGCkpFeYEoqrE+lwqUjrkm3++\n7xLgak1fW9Dl3TKBKjojWQL46dqsygGmo2owaDAOBgNVHQ8BAf8EBAMCBsAwKQYD\nVR0OBCIEIEnTMIvB4ryPKKyzRMI/oTcWYGt9ym8jM+0tnhX0XWV8MCsGA1UdIwQk\nMCKAILEnHuCWfEFnImXZR9Qn10sQ5b9O016fzx3U5JGFBOGLMAoGCCqBHM9VAYN1\nA0gAMEUCIA2DhxEKtwVHPESfPObH1IZSeTvnLJ/9NKPGBs2RgWlXAiEA5bX3DDAT\n9QD5EWSkIV9YTyP9olDnL2vPsHeNmteEJuU=\n-----END CERTIFICATE-----\n\"%client1.sign.ljh-org2.qianjinlian.com*\006CLIENT2@49d3308bc1e2bc8f28acb344c23fa13716606b7dca6f2333ed2d9e15f45d657c"
message: "OK"
gas_used: 61794
}
Mysql会在statedb_chain1_6f34fcb7b62922896e99fab564b8de5520121713的state_infos表插入初始化数据
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information