Skip to content

Commit

Permalink
Merge branch 'master' into issue-28175
Browse files Browse the repository at this point in the history
  • Loading branch information
tisonkun authored Sep 25, 2021
2 parents 05d9120 + 9955eee commit 81a62ea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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__

Expand Down
2 changes: 1 addition & 1 deletion executor/index_lookup_merge_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 16 additions & 0 deletions executor/index_lookup_merge_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 13 additions & 1 deletion store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package store
import (
"net/url"
"strings"
"sync"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/kv"
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
}

0 comments on commit 81a62ea

Please sign in to comment.