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

[optimize](table stat) Reduce lock when get table statistics #39807

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

xy720
Copy link
Member

@xy720 xy720 commented Aug 22, 2024

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.

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@github-actions github-actions bot added the area/planner Issues or PRs related to the query planner label Aug 22, 2024
@@ -148,6 +150,8 @@ public enum OlapTableState {

private TableProperty tableProperty;

private volatile Statistics statistics = new Statistics();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When fe restarted, the statistics has not inited and the dataSize will be 0. At this point, createTable behavior will not be restricted.
Should we deal with this situation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discuss, if statistics is not inited, we should try init it first.
But I think we may first implement this logic in master branch.

Copy link
Contributor

@lide-reed lide-reed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Aug 28, 2024
Copy link
Contributor

PR approved by at least one committer and no changes requested.

Copy link
Contributor

PR approved by anyone and no changes requested.

@lide-reed lide-reed merged commit 367d264 into apache:branch-1.2-lts Aug 28, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. area/planner Issues or PRs related to the query planner reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants