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

domain: load stats table asynchronously #5188

Merged
merged 3 commits into from
Nov 22, 2017
Merged

Conversation

alivxxx
Copy link
Contributor

@alivxxx alivxxx commented Nov 22, 2017

We do not have to wait all stats table loaded into memory when starts TiDB server.

@shenli
Copy link
Member

shenli commented Nov 22, 2017

LGTM

Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

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

LGTM

@shenli
Copy link
Member

shenli commented Nov 22, 2017

/run-all-tests

@shenli
Copy link
Member

shenli commented Nov 22, 2017

@lamxTyler CI failed.

@alivxxx
Copy link
Contributor Author

alivxxx commented Nov 22, 2017

@shenli It is not caused by this PR, @tiancaiamao is looking at it.

@coocood coocood merged commit 7b2b365 into pingcap:master Nov 22, 2017
@darren
Copy link
Contributor

darren commented Nov 22, 2017

@lamxTyler @shenli

Before this PR, tidb-server on our cluster takes 8 minutes to start before
it can accept connections. Most of the time is spent on loading stats.

After this PR, tidb-server starts very quickly and ready for accepting queries,
However it raises another problem: because stats loading is running in the background
and will take for a while. if tidb-server in the meantime accepts queries on tables whose
histograms are still in the loading queue, the queries will be very slow and resource intensive
thus bring significant impact on the cluster.

If that's the case then I would prefer that tidb-server load stats fully before accepting queries.

Is it feasible that loading the stats on demand?

@shenli
Copy link
Member

shenli commented Nov 22, 2017

@darren How many tables do you have? Could you provide us some of you schema and sql? We could check why them run slow with default statistic info.

@darren
Copy link
Contributor

darren commented Nov 22, 2017

@shenli

We are still bulk loading data in the cluster and due to rotational disks on our TiKV servers, thus I expect that it will load slow. I think it's normal.

Here's a debug log of tidb-server start before this PR:

tidb-server.log.gz

@alivxxx alivxxx deleted the load branch November 23, 2017 02:24
@alivxxx
Copy link
Contributor Author

alivxxx commented Nov 28, 2017

@darren In #5215, we speed up the loading of stats when the server starts, could you try it and see if it is faster enough?

@darren
Copy link
Contributor

darren commented Nov 28, 2017

@lamxTyler
If I stop loading data in another tidb-server instance, it loads faster enough, I estimate that it takes about 30 seconds or so (about 1500+ tables).

@shenli
Copy link
Member

shenli commented Nov 28, 2017

@lamxTyler Could we make it another 10x faster?

@shenli
Copy link
Member

shenli commented Nov 28, 2017

A native improvement: load stats_meta/stats_histograms/stats_buckets parallelly.

@darren
Copy link
Contributor

darren commented Nov 28, 2017

@lamxTyler

Could you log some info about when stats loading starts and finishes? for now I have to set log level to debug and do some estimates by hand.

I think the print out some info level log about stats loading status is important for admins.

@alivxxx
Copy link
Contributor Author

alivxxx commented Nov 29, 2017

@darren Yes, I will do it.

@shenli
Copy link
Member

shenli commented Nov 30, 2017

@darren #5266 makes loading stats info faster and add time consuming in log for loading stats info.

@darren
Copy link
Contributor

darren commented Dec 1, 2017

@lamxTyler @shenli

Good job!

It's really faster now:

2017/12/01 10:21:55.491 domain.go:613: [info] [stats] init stats info takes 7.019830276s

alivxxx added a commit to alivxxx/tidb that referenced this pull request Dec 11, 2017
shenli pushed a commit that referenced this pull request Dec 11, 2017
load stats table asynchronously (#5188)
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.

5 participants