Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

高并发下的日志死锁 #57

Open
Harryguo2020 opened this issue Mar 6, 2021 · 1 comment
Open

高并发下的日志死锁 #57

Harryguo2020 opened this issue Mar 6, 2021 · 1 comment

Comments

@Harryguo2020
Copy link

Harryguo2020 commented Mar 6, 2021

请问一下,在日志并发缓存队列中有一个 SWITCH 队列的用途是什么

//上一次写入是否完成
           if (_lastReadFinished)
           {
               _lastReadFinished = false;
               //切换队列
               Switch();
               //取数据写入
               QueueProcess(action);
               _lastReadFinished = true;
           }

发现可能是因为这里,造成高并发下,多任务持续写入日志的时候, 随机的发生任务死锁现象。 建议是否可以去除, 因为使用 ConcurrentQueue 原理上已经是支持并发状态下的先入先出功能了, 应该不需要进行读写切换。

@hey-hoho
Copy link
Owner

hey-hoho commented Mar 8, 2021

因为考虑到ConcurrentQueue容量有限,如果数据量偏大造成频繁扩容可能会有性能瓶颈,所以使用2个队列来处理,Switch方法是用来切换当前处理队列的。您说的死锁现象我会进一步测试观察下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants