Comments (3)
@bysomeone 你来看一下这个问题
from chain33.
@bysomeone 你来看一下这个问题
好的
from chain33.
如题,分析一下可能的原因
初步分析是在并发的情况下,消息队列sub消息时和发送的顺序可能不一致
chain33消息队列sub过程代码
go func() {
defer func() {
client.wg.Done()
}()
for {
select {
case data, ok := <-sub.high:
if client.isEnd(data, ok) {
qlog.Info("unsub1", "topic", topic)
return
}
client.Recv() <- data
default:
select {
case data, ok := <-sub.high:
if client.isEnd(data, ok) {
qlog.Info("unsub2", "topic", topic)
return
}
client.Recv() <- data
case data, ok := <-sub.low:
if client.isEnd(data, ok) {
qlog.Info("unsub3", "topic", topic)
return
}
client.Recv() <- data
case <-client.done:
qlog.Error("unsub4", "topic", topic)
return
}
}
}
TestDelBlock中调用的两个send(删除区块命令和查询mempool size命令)分别对应以上的sub.low和sub.high两个管道,正常情况是先删除再查询,即先收到low再high,但在并发情况下,可能sub的协程可能被调度睡眠,唤醒后其实sub和high都已经就绪,但high写在更前面,会优先执行high对应逻辑,也就是查询mempool size的时候还没有执行DelBlock,固然为0
类似代码demo,https://play.golang.org/p/A6DIww95dA7
至于产生并发,是go test默认执行行为,所有包的test是并发执行的,在某种并发条件下即可触发以上情况
for i in {1..100}; do go test -run DelBlock; done > delBlock.log &
for i in {1..100}; do go test -run DelBlock; done >> delBlock.log &
...
本地启动10个并发shell,打印流程中相关日志,可以复现这种情况
from chain33.
Related Issues (20)
- TxFee新增FeeLimit
- 以太坊地址大小写兼容问题 HOT 2
- 扩展Address driver接口 HOT 1
- 部署/调用合约的手续费问题 HOT 1
- 以太坊地址作为dbkey存储大小写敏感 HOT 2
- 执行 send 命令行时, 无法指定签名的地址类型 HOT 3
- 钱包增加 coin type 898 支持 HOT 1
- block TxHash未正确设置 HOT 1
- 32位机器上使用atomic需要保证字节对齐 HOT 1
- 平行链延时交易兼容问题 HOT 1
- 平行链扩容方案 HOT 1
- 平行链EVM交易出现ErrSign的错误 HOT 3
- 平行链的evm手续费问题 HOT 3
- eth 兼容交易哈希与chain33 哈希映射 HOT 1
- 单元测试偶发失败 HOT 1
- chain33进程无法退出 HOT 1
- 源码编译 HOT 1
- 平行链执行器地址格式兼容 HOT 1
- blockchain同步处理导致死锁
- queue 模块单元测试偶现超时问题 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chain33.