* 1. init ddl tables create tidb_ddl_job, tidb_ddl_reorg, tidb_ddl_history tables with raw meta write, these 3 tables is use to replace the ddl job queue and reorg and history hash table * 2. setup concurrent ddl env and add ddl worker pool adds the ddl worker pool definition, the ddl job manager will find a job and ship it to a worker in the worker pool. Also, this commit provides a sessionctx wrapper, only use in ddl relate. it just wraps begin, commit and execute * 3. add ddl manager to handle ddl job * 4. reorg handler for concurrent ddl just implements the partner of the reorg information. * 5. manage ddl jobs for concurrent ddl add the partner of add job, delete job and many others related to history job because many of the functions need a session now, we just change the caller * 6. add metrics for concurrent ddl add metrics * 7. support multiple tables * 8. fix test * 9. migrate ddl between table and queue support switch between the old and new ddl framework, migrate the existing ddl job between queue and table * 10. check tikv version and set reorg worker count according cpu count * *: add featuretag on tests Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com> * use a determined table id for 3 tables * remove ctx value * add GetSchemaVersionWithNonEmptyDiff function * address tangenta and zimulala comment * use only one etcd path * make ActionRenameTable support multi-schema * reset sql digest to make top sql work correct * add comment * fix test * remove 0 for schema version lock Co-authored-by: xiongjiwei <xiongjiwei1996@outlook.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io> Co-authored-by: wjHuang <huangwenjun1997@gmail.com>
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
// Copyright 2022 PingCAP, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package session_test
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/pingcap/tidb/session"
|
|
"github.com/pingcap/tidb/testkit"
|
|
"github.com/pingcap/tidb/testkit/external"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestInitMetaTable(t *testing.T) {
|
|
store, clean := testkit.CreateMockStore(t)
|
|
defer clean()
|
|
|
|
tk := testkit.NewTestKit(t, store)
|
|
tk.MustExec("use test")
|
|
for _, sql := range session.DDLJobTables {
|
|
tk.MustExec(sql.SQL)
|
|
}
|
|
|
|
tbls := map[string]struct{}{
|
|
"tidb_ddl_job": {},
|
|
"tidb_ddl_reorg": {},
|
|
"tidb_ddl_history": {},
|
|
}
|
|
|
|
for tbl := range tbls {
|
|
metaInMySQL := external.GetTableByName(t, tk, "mysql", tbl).Meta()
|
|
metaInTest := external.GetTableByName(t, tk, "test", tbl).Meta()
|
|
|
|
require.Greater(t, metaInMySQL.ID, int64(0))
|
|
require.Greater(t, metaInMySQL.UpdateTS, uint64(0))
|
|
|
|
metaInTest.ID = metaInMySQL.ID
|
|
metaInMySQL.UpdateTS = metaInTest.UpdateTS
|
|
require.True(t, reflect.DeepEqual(metaInMySQL, metaInTest))
|
|
}
|
|
}
|