-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Thread pool #332
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
This was referenced Jan 23, 2024
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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的线程池(虽然没有实现)设计