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

Thread pool #332

Merged
merged 39 commits into from
Jan 22, 2024
Merged

Thread pool #332

merged 39 commits into from
Jan 22, 2024

Conversation

hnwyllmm
Copy link
Collaborator

What problem were solved in this pull request?

Issue Number: close #322 #301 #143 #47
ref #138

Problem:
当前使用的seda处理框架和libevent消息处理模式不适用于SQL处理模型。

SQL 请求处理模式是来一个请求应答后才能接收新的请求。但是当前收到某个连接的消息后在返回应答之前,可以接收新的请求,导致可以同时处理同一个连接的多个请求,出现并发错误。

另外,同一个SQL请求,需要有一个统一的处理上下文,不能在线程间切来切去。而seda将处理请求分为多个stage,会在不同的线程间切换。

What is changed and how it works?

新增线程模型概念,用来处理连接上的请求。设计文档参考 miniob-thread-model.md。

对于新连接监听,放在主线程来做。接收到新连接时,交给线程模型来处理,可以是一个连接一个线程,也可以是一个线程池统一管理。
不管使用哪种模型,在处理一个SQL结束之前,不会去监听该连接上是否有新的消息到达,因此也不会出现一个连接上多个请求同时处理的情况。

Other information

本设计参考了Java的线程池和Percona/MariaDB的线程池(虽然没有实现)设计

Copy link

codecov bot commented Jan 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7fc2b8f) 24.36% compared to head (915e141) 0.00%.
Report is 1 commits behind head on main.

❗ Current head 915e141 differs from pull request most recent head 73be9f4. Consider uploading reports for the commit 73be9f4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##             main   #332       +/-   ##
=========================================
- Coverage   24.36%      0   -24.37%     
=========================================
  Files         215      0      -215     
  Lines       10633      0    -10633     
=========================================
- Hits         2591      0     -2591     
+ Misses       8042      0     -8042     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Successfully merging this pull request may close these issues.

[BUG] observer 单连接上并发处理请求的问题
1 participant