-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[optimize](table stat) Reduce lock when get table statistics (#39807)
## Proposed changes Issue Number: this pr will pick part of #35457 to reduce the potential of dead lock with following example: 时间点 | create table线程1 | create table线程2 | table stat线程 | truncate线程 -- | -- | -- | -- | -- t1 | add table1 read lock | | | t2 | | add table2 read lock | | t3 | | | try add table1 write lock,blocked | t4 | | | | try add table2 write lock,blocked t5 | try add table2 read lock,Due to a thread attempting to add the table2 write lock earlier, it was forced to queue up | | | t6 | | try add table1 read lock,Due to a thread attempting to add the table1 write lock earlier, it was forced to queue up | | This deadlock situation usually occurs when it is a fair lock. So we should optimize the read lock. This PR places the updates of table statistics(such as data size/replica count) in the Table Stats Thread to be done on a scheduled basis, so that there is no need to add a read lock when obtaining table statistics. <!--Describe your changes.-->
- Loading branch information
Showing
4 changed files
with
98 additions
and
56 deletions.
There are no files selected for viewing
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
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
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
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