Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into add-status-counters
Browse files Browse the repository at this point in the history
  • Loading branch information
morgo committed Feb 20, 2021
2 parents 3f6f38f + 3ad7f40 commit a404679
Show file tree
Hide file tree
Showing 413 changed files with 15,621 additions and 110,774 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ explain_test
cmd/explaintest/explain-test.out
cmd/explaintest/explaintest_tidb-server
cmd/explaintest/portgenerator
cmd/explaintest/s/
*.fail.go
tools/bin/
vendor
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ gotest: failpoint-enable
ifeq ("$(TRAVIS_COVERAGE)", "1")
@echo "Running in TRAVIS_COVERAGE mode."
$(GO) get github.com/go-playground/overalls
@export log_level=error; \
@export log_level=info; \
$(OVERALLS) -project=github.com/pingcap/tidb \
-covermode=count \
-ignore='.git,vendor,cmd,docs,tests,LICENSES' \
Expand All @@ -132,7 +132,7 @@ ifeq ("$(TRAVIS_COVERAGE)", "1")
|| { $(FAILPOINT_DISABLE); exit 1; }
else
@echo "Running in native mode."
@export log_level=fatal; export TZ='Asia/Shanghai'; \
@export log_level=info; export TZ='Asia/Shanghai'; \
$(GOTEST) -ldflags '$(TEST_LDFLAGS)' $(EXTRA_TEST_ARGS) -cover $(PACKAGES) -check.p true -check.timeout 4s || { $(FAILPOINT_DISABLE); exit 1; }
endif
@$(FAILPOINT_DISABLE)
Expand Down
40 changes: 25 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
[![Coverage Status](https://codecov.io/gh/pingcap/tidb/branch/master/graph/badge.svg)](https://codecov.io/gh/pingcap/tidb)
[![GoDoc](https://img.shields.io/badge/Godoc-reference-blue.svg)](https://godoc.org/github.com/pingcap/tidb)

- [**Slack Channel**](https://slack.tidb.io)
- [**Slack Channel**](https://slack.tidb.io/invite?team=tidb-community&channel=everyone&ref=pingcap-tidb)
- **Twitter**: [@PingCAP](https://twitter.com/PingCAP)
- [**Reddit**](https://www.reddit.com/r/TiDB/)
- **Mailing list**: [Google Group](https://groups.google.com/forum/#!forum/tidb-user)
- [**Blog**](https://www.pingcap.com/blog/)
- **Mailing list**: [lists.tidb.io](https://lists.tidb.io/g/main/subgroups)
- [**For support, please contact PingCAP**](http://bit.ly/contact_us_via_github)

## What is TiDB?
Expand All @@ -27,17 +26,17 @@ TiDB ("Ti" stands for Titanium) is an open-source NewSQL database that supports

- __MySQL Compatible Syntax__

TiDB acts like it is a MySQL 5.7 server to your applications. You can continue to use all of the existing MySQL client libraries, and in many cases, you will not need to change a single line of code in your application. Because TiDB is built from scratch, not a MySQL fork, please check out the list of [known compatibility differences](https://pingcap.com/docs/v3.0/reference/mysql-compatibility/).
TiDB acts like it is a MySQL 5.7 server to your applications. You can continue to use all of the existing MySQL client libraries, and in many cases, you will not need to change a single line of code in your application. Because TiDB is built from scratch, not a MySQL fork, please check out the list of [known compatibility differences](https://docs.pingcap.com/tidb/stable/mysql-compatibility).

- __Distributed Transactions with Strong Consistency__

TiDB internally shards table into small range-based chunks that we refer to as "regions". Each region defaults to approximately 100MiB in size, and TiDB uses a Two-phase commit internally to ensure that regions are maintained in a transactionally consistent way.
TiDB internally shards table into small range-based chunks that we refer to as "Regions". Each Region defaults to approximately 100 MiB in size, and TiDB uses a Two-phase commit internally to ensure that Regions are maintained in a transactionally consistent way.

- __Cloud Native__

TiDB is designed to work in the cloud -- public, private, or hybrid -- making deployment, provisioning, operations, and maintenance simple.

The storage layer of TiDB, called TiKV, [became](https://www.cncf.io/blog/2018/08/28/cncf-to-host-tikv-in-the-sandbox/) a [Cloud Native Computing Foundation](https://www.cncf.io/) member project in 2018. The architecture of the TiDB platform also allows SQL processing and storage to be scaled independently of each other in a very cloud-friendly manner.
The storage layer of TiDB, called TiKV, is a [Cloud Native Computing Foundation (CNCF) Graduated](https://www.cncf.io/announcements/2020/09/02/cloud-native-computing-foundation-announces-tikv-graduation/) project. The architecture of the TiDB platform also allows SQL processing and storage to be scaled independently of each other in a very cloud-friendly manner.

- __Minimize ETL__

Expand All @@ -47,12 +46,10 @@ TiDB ("Ti" stands for Titanium) is an open-source NewSQL database that supports

TiDB uses the Raft consensus algorithm to ensure that data is highly available and safely replicated throughout storage in Raft groups. In the event of failure, a Raft group will automatically elect a new leader for the failed member, and self-heal the TiDB cluster without any required manual intervention. Failure and self-healing operations are also transparent to applications.

For more details and latest updates, see [official TiDB blog](https://www.pingcap.com/blog/).

For more details and latest updates, see [TiDB docs](https://docs.pingcap.com/tidb/stable) and [release notes](https://docs.pingcap.com/tidb/dev/release-notes).

## Quick start


See [Quick Start Guide](https://pingcap.com/docs/stable/quick-start-with-tidb/ ), which includes deployment methods using TiUP, Ansible, Docker, and Kubernetes.

### To start developing TiDB
Expand All @@ -61,20 +58,22 @@ The [community repository](https://github.com/pingcap/community) hosts all infor

[<img src="docs/contribution-map.png" alt="contribution-map" width="180">](https://github.com/pingcap/tidb-map/blob/master/maps/contribution-map.md#tidb-is-an-open-source-distributed-htap-database-compatible-with-the-mysql-protocol)

Contributions are welcomed and greatly appreciated. See
[Contribution Guide](https://github.com/pingcap/community/blob/master/contributors/README.md)
for details on submitting patches and the contribution workflow. For more contributing information, click on the contributor icon above.
Contributions are welcomed and greatly appreciated. See [Contribution Guide](https://github.com/pingcap/community/blob/master/contributors/README.md) for details on submitting patches and the contribution workflow. For more contributing information, click on the contributor icon above.

## Adopters

View the current list of in-production TiDB adopters [here](https://pingcap.com/docs/adopters/).
View the current list of in-production TiDB adopters [here](https://docs.pingcap.com/tidb/stable/adopters).

## Case studies

- [English](https://pingcap.com/case-studies)
- [简体中文](https://pingcap.com/cases-cn/)

## Roadmap

Read the [Roadmap](https://pingcap.com/docs/ROADMAP).


## Getting Help
## Getting help

- [**Stack Overflow**](https://stackoverflow.com/questions/tagged/tidb)
- [**User Group (Chinese)**](https://asktug.com)
Expand All @@ -84,13 +83,24 @@ Read the [Roadmap](https://pingcap.com/docs/ROADMAP).
+ [English](https://pingcap.com/docs)
+ [简体中文](https://pingcap.com/docs-cn)

## Blog

- [English](https://www.pingcap.com/blog/)
- [简体中文](https://pingcap.com/blog-cn/)

## TiDB Monthly

[TiDB Monthly](https://pingcap.com/weekly/)

## Architecture

![architecture](./docs/architecture.png)

## License

TiDB is under the Apache 2.0 license. See the [LICENSE](./LICENSE) file for details.

## Acknowledgments

- Thanks [cznic](https://github.com/cznic) for providing some great open source tools.
- Thanks [GolevelDB](https://github.com/syndtr/goleveldb), [BoltDB](https://github.com/boltdb/bolt), and [RocksDB](https://github.com/facebook/rocksdb) for their powerful storage engines.
52 changes: 52 additions & 0 deletions bindinfo/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,29 @@ func (s *testSuite) TestCapturedBindingCharset(c *C) {
c.Assert(rows[0][7], Equals, "")
}

func (s *testSuite) TestConcurrentCapture(c *C) {
tk := testkit.NewTestKit(c, s.store)
s.cleanBindingEnv(tk)
// Simulate an existing binding generated by concurrent CREATE BINDING, which has not been synchronized to current tidb-server yet.
// Actually, it is more common to be generated by concurrent baseline capture, I use Manual just for simpler test verification.
tk.MustExec("insert into mysql.bind_info values('select * from test . t', 'select * from test . t', '', 'using', '2000-01-01 09:00:00', '2000-01-01 09:00:00', '', '','" +
bindinfo.Manual + "')")
tk.MustQuery("select original_sql, source from mysql.bind_info where source != 'builtin'").Check(testkit.Rows(
"select * from test . t manual",
))
stmtsummary.StmtSummaryByDigestMap.Clear()
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int)")
c.Assert(tk.Se.Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil), IsTrue)
tk.MustExec("select * from t")
tk.MustExec("select * from t")
tk.MustExec("admin capture bindings")
tk.MustQuery("select original_sql, source from mysql.bind_info where source != 'builtin'").Check(testkit.Rows(
"select * from test . t capture",
))
}

func (s *testSuite) TestUpdateSubqueryCapture(c *C) {
tk := testkit.NewTestKit(c, s.store)
s.cleanBindingEnv(tk)
Expand Down Expand Up @@ -1997,3 +2020,32 @@ func (s *testSuite) TestIssue20417(c *C) {
c.Assert(status == "using" || status == "rejected", IsTrue)
tk.MustExec("set @@tidb_evolve_plan_baselines=0")
}

func (s *testSuite) TestCaptureWithZeroSlowLogThreshold(c *C) {
tk := testkit.NewTestKit(c, s.store)
s.cleanBindingEnv(tk)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")
stmtsummary.StmtSummaryByDigestMap.Clear()
c.Assert(tk.Se.Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil), IsTrue)
tk.MustExec("set tidb_slow_log_threshold = 0")
tk.MustExec("select * from t")
tk.MustExec("select * from t")
tk.MustExec("set tidb_slow_log_threshold = 300")
tk.MustExec("admin capture bindings")
rows := tk.MustQuery("show global bindings").Rows()
c.Assert(len(rows), Equals, 1)
c.Assert(rows[0][0], Equals, "select * from test . t")
}

func (s *testSuite) TestExplainTableStmts(c *C) {
tk := testkit.NewTestKit(c, s.store)
s.cleanBindingEnv(tk)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(id int, value decimal(5,2))")
tk.MustExec("table t")
tk.MustExec("explain table t")
tk.MustExec("desc table t")
}
Loading

0 comments on commit a404679

Please sign in to comment.