From 6575c90821797472b08f382e8b10e83705f13e21 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Fri, 24 Sep 2021 12:10:46 -0600 Subject: [PATCH 1/3] README: Fix description of distributed transactions (#28047) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a4caab04511ea..ec1f533775e24 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ TiDB ("Ti" stands for Titanium) is an open-source NewSQL database that supports 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__ +- __Distributed Transactions__ - 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. + 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 an [optimized](https://pingcap.com/blog/async-commit-the-accelerator-for-transaction-commit-in-tidb-5.0) Two-phase commit to ensure that Regions are maintained in a transactionally consistent way. - __Cloud Native__ From 6a8375a8f33cce5e31f513cb76c6b5f735bf55a6 Mon Sep 17 00:00:00 2001 From: senhtry Date: Sat, 25 Sep 2021 09:06:46 +0800 Subject: [PATCH 2/3] store: thread safe for Register kv.Driver (#28267) --- store/store.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/store/store.go b/store/store.go index 3cb84f27394a0..eca23fc5a5c83 100644 --- a/store/store.go +++ b/store/store.go @@ -17,6 +17,7 @@ package store import ( "net/url" "strings" + "sync" "github.com/pingcap/errors" "github.com/pingcap/tidb/kv" @@ -26,9 +27,13 @@ import ( ) var stores = make(map[string]kv.Driver) +var storesLock sync.RWMutex // Register registers a kv storage with unique name and its associated Driver. func Register(name string, driver kv.Driver) error { + storesLock.Lock() + defer storesLock.Unlock() + name = strings.ToLower(name) if _, ok := stores[name]; ok { @@ -59,7 +64,7 @@ func newStoreWithRetry(path string, maxRetries int) (kv.Storage, error) { } name := strings.ToLower(storeURL.Scheme) - d, ok := stores[name] + d, ok := loadDriver(name) if !ok { return nil, errors.Errorf("invalid uri format, storage %s is not registered", name) } @@ -78,3 +83,10 @@ func newStoreWithRetry(path string, maxRetries int) (kv.Storage, error) { } return s, errors.Trace(err) } + +func loadDriver(name string) (kv.Driver, bool) { + storesLock.RLock() + defer storesLock.RUnlock() + d, ok := stores[name] + return d, ok +} From 9955eeebfa4b423551031b8a5b701e848d8888fe Mon Sep 17 00:00:00 2001 From: Qi Yu Date: Sat, 25 Sep 2021 10:18:46 +0800 Subject: [PATCH 3/3] execution: Fix out of range value in inl_merge_join (#28065) --- executor/index_lookup_merge_join.go | 2 +- executor/index_lookup_merge_join_test.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/executor/index_lookup_merge_join.go b/executor/index_lookup_merge_join.go index d468acd35d39c..8632e53d0604c 100644 --- a/executor/index_lookup_merge_join.go +++ b/executor/index_lookup_merge_join.go @@ -689,7 +689,7 @@ func (imw *innerMergeWorker) constructDatumLookupKey(task *lookUpMergeJoinTask, innerValue, err := outerValue.ConvertTo(sc, innerColType) if err != nil { // If the converted outerValue overflows, we don't need to lookup it. - if terror.ErrorEqual(err, types.ErrOverflow) { + if terror.ErrorEqual(err, types.ErrOverflow) || terror.ErrorEqual(err, types.ErrWarnDataOutOfRange) { return nil, nil } if terror.ErrorEqual(err, types.ErrTruncated) && (innerColType.Tp == mysql.TypeSet || innerColType.Tp == mysql.TypeEnum) { diff --git a/executor/index_lookup_merge_join_test.go b/executor/index_lookup_merge_join_test.go index ff40efa01c9b7..16b74c00d39b4 100644 --- a/executor/index_lookup_merge_join_test.go +++ b/executor/index_lookup_merge_join_test.go @@ -42,6 +42,22 @@ func (s *testSerialSuite) TestIndexLookupMergeJoinHang(c *C) { c.Assert(err.Error(), Equals, "OOM test index merge join doesn't hang here.") } +func (s *testSerialSuite) TestIssue28052(c *C) { + tk := testkit.NewTestKit(c, s.store) + + tk.MustExec("use test") + tk.MustExec("drop table if exists t") + tk.MustExec("CREATE TABLE `t` (" + + "`col_tinyint_key_signed` tinyint(4) DEFAULT NULL," + + "`col_year_key_signed` year(4) DEFAULT NULL," + + "KEY `col_tinyint_key_signed` (`col_tinyint_key_signed`)," + + "KEY `col_year_key_signed` (`col_year_key_signed`)" + + " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin") + + tk.MustExec("insert into t values(-100,NULL);") + tk.MustQuery("select /*+ inl_merge_join(t1, t2) */ count(*) from t t1 right join t t2 on t1. `col_year_key_signed` = t2. `col_tinyint_key_signed`").Check(testkit.Rows("1")) +} + func (s *testSerialSuite) TestIssue18068(c *C) { c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/testIssue18068", `return(true)`), IsNil) defer func() {