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

*: Update client-go and verify all read ts (#58054) #58912

Open
wants to merge 1 commit into
base: release-8.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6807,13 +6807,23 @@ def go_deps():
name = "com_github_tikv_client_go_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
<<<<<<< HEAD
sha256 = "4d03d9794b514c22355693f7ed5ae3a806d04aef704c57e7791cbc972275d72b",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20241212055527-4d50d6744f0c",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241212055527-4d50d6744f0c.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241212055527-4d50d6744f0c.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241212055527-4d50d6744f0c.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241212055527-4d50d6744f0c.zip",
=======
sha256 = "844684ee6ae7decc5cadcab3f95c526b66878f8401c71cf82af68ec0cc5257d5",
strip_prefix = "github.com/tikv/client-go/v2@v2.0.8-0.20241209094930-06d7f4b9233b",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241209094930-06d7f4b9233b.zip",
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241209094930-06d7f4b9233b.zip",
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241209094930-06d7f4b9233b.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20241209094930-06d7f4b9233b.zip",
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
],
)
go_repository(
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@ require (
github.com/tdakkota/asciicheck v0.2.0
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tidwall/btree v1.7.0
<<<<<<< HEAD
github.com/tikv/client-go/v2 v2.0.8-0.20241212055527-4d50d6744f0c
github.com/tikv/pd/client v0.0.0-20240806105739-10ecdbe92b55
=======
github.com/tikv/client-go/v2 v2.0.8-0.20241209094930-06d7f4b9233b
github.com/tikv/pd/client v0.0.0-20241111073742-238d4d79ea31
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
github.com/timakin/bodyclose v0.0.0-20240125160201-f835fa56326a
github.com/twmb/murmur3 v1.1.6
github.com/uber/jaeger-client-go v2.22.1+incompatible
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,17 @@ github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM=
github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI=
github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
<<<<<<< HEAD
github.com/tikv/client-go/v2 v2.0.8-0.20241212055527-4d50d6744f0c h1:55hXQ+8kmgvUv7W+sSnCyp5BpmeFE9yfXFfYKUokMLw=
github.com/tikv/client-go/v2 v2.0.8-0.20241212055527-4d50d6744f0c/go.mod h1:+vXk4Aex17GnI8gfSMPxrL0SQLbBYgP3Db4FvHiImwM=
github.com/tikv/pd/client v0.0.0-20240806105739-10ecdbe92b55 h1:+1unfy0TcJJtud3d7BuYsvNG6tPVuXIH+WiIFhOx1Kc=
github.com/tikv/pd/client v0.0.0-20240806105739-10ecdbe92b55/go.mod h1:1zqLOMhnkZIpBLj2oXOO2bWvtXhb12OmYr+cPkjQ6tI=
=======
github.com/tikv/client-go/v2 v2.0.8-0.20241209094930-06d7f4b9233b h1:x8E2J8UuUa2ysUkgVfNGgiXxZ9nfqBpQ43PBLwmCitU=
github.com/tikv/client-go/v2 v2.0.8-0.20241209094930-06d7f4b9233b/go.mod h1:NI2GfVlB9n7DsIGCxrKcD4psrcuFNEV8m1BgyzK1Amc=
github.com/tikv/pd/client v0.0.0-20241111073742-238d4d79ea31 h1:oAYc4m5Eu1OY9ogJ103VO47AYPHvhtzbUPD8L8B67Qk=
github.com/tikv/pd/client v0.0.0-20241111073742-238d4d79ea31/go.mod h1:W5a0sDadwUpI9k8p7M77d3jo253ZHdmua+u4Ho4Xw8U=
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
github.com/timakin/bodyclose v0.0.0-20240125160201-f835fa56326a h1:A6uKudFIfAEpoPdaal3aSqGxBzLyU8TqyXImLwo6dIo=
github.com/timakin/bodyclose v0.0.0-20240125160201-f835fa56326a/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
Expand Down
56 changes: 51 additions & 5 deletions pkg/ddl/column_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/external"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/mock"
"github.com/stretchr/testify/require"
)

Expand All @@ -48,10 +47,14 @@ func TestColumnAdd(t *testing.T) {
tk.MustExec("create table t (c1 int, c2 int);")
tk.MustExec("insert t values (1, 2);")

<<<<<<< HEAD
d := dom.DDL()
tc := &callback.TestDDLCallback{Do: dom}

ct := testNewContext(store)
=======
ct := testNewContext(t, store)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
// set up hook
var (
deleteOnlyTable table.Table
Expand Down Expand Up @@ -127,8 +130,13 @@ func TestColumnAdd(t *testing.T) {
return
}
first = false
<<<<<<< HEAD
sess := testNewContext(store)
err := sessiontxn.NewTxn(context.Background(), sess)
=======
sess := testNewContext(t, store)
txn, err := newTxn(sess)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)
_, err = writeOnlyTable.AddRecord(sess.GetTableCtx(), types.MakeDatums(10, 10))
require.NoError(t, err)
Expand Down Expand Up @@ -223,7 +231,15 @@ func checkAddWriteOnly(ctx sessionctx.Context, deleteOnlyTable, writeOnlyTable t
if err != nil {
return errors.Trace(err)
}
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
if err != nil {
return errors.Trace(err)
}
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -261,7 +277,15 @@ func checkAddWriteOnly(ctx sessionctx.Context, deleteOnlyTable, writeOnlyTable t
if err != nil {
return errors.Trace(err)
}
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
if err != nil {
return errors.Trace(err)
}
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
if err != nil {
return errors.Trace(err)
}
Expand All @@ -278,7 +302,15 @@ func checkAddWriteOnly(ctx sessionctx.Context, deleteOnlyTable, writeOnlyTable t
if err != nil {
return errors.Trace(err)
}
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
if err != nil {
return errors.Trace(err)
}
_, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -308,7 +340,15 @@ func checkAddPublic(sctx sessionctx.Context, writeOnlyTable, publicTable table.T
if err != nil {
return errors.Trace(err)
}
<<<<<<< HEAD
err = sessiontxn.NewTxn(ctx, sctx)
=======
err = txn.Commit(context.Background())
if err != nil {
return errors.Trace(err)
}
txn, err = newTxn(sctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
if err != nil {
return errors.Trace(err)
}
Expand All @@ -325,7 +365,15 @@ func checkAddPublic(sctx sessionctx.Context, writeOnlyTable, publicTable table.T
if err != nil {
return errors.Trace(err)
}
<<<<<<< HEAD
err = sessiontxn.NewTxn(ctx, sctx)
=======
err = txn.Commit(context.Background())
if err != nil {
return errors.Trace(err)
}
_, err = newTxn(sctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -431,10 +479,8 @@ func testCheckJobDone(t *testing.T, store kv.Storage, jobID int64, isAdd bool) {
}
}

func testNewContext(store kv.Storage) sessionctx.Context {
ctx := mock.NewContext()
ctx.Store = store
return ctx
func testNewContext(t *testing.T, store kv.Storage) sessionctx.Context {
return testkit.NewSession(t, store)
}

func TestIssue40135(t *testing.T) {
Expand Down
79 changes: 77 additions & 2 deletions pkg/ddl/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,13 @@ func TestColumnBasic(t *testing.T) {
tk.MustExec(fmt.Sprintf("insert into t1 values(%d, %d, %d)", i, 10*i, 100*i))
}

<<<<<<< HEAD
ctx := testNewContext(store)
err := sessiontxn.NewTxn(context.Background(), ctx)
=======
ctx := testNewContext(t, store)
txn, err := newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)

var tableID int64
Expand Down Expand Up @@ -214,7 +219,13 @@ func TestColumnBasic(t *testing.T) {

h, err := tbl.AddRecord(ctx.GetTableCtx(), types.MakeDatums(11, 12, 13, 14))
require.NoError(t, err)
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
require.NoError(t, err)
_, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)
values, err := tables.RowWithCols(tbl, ctx, h, tbl.Cols())
require.NoError(t, err)
Expand Down Expand Up @@ -385,7 +396,13 @@ func checkDeleteOnlyColumn(t *testing.T, ctx sessionctx.Context, tableID int64,
newRow := types.MakeDatums(int64(11), int64(22), int64(33))
newHandle, err := tbl.AddRecord(ctx.GetTableCtx(), newRow)
require.NoError(t, err)
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
require.NoError(t, err)
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)

rows := [][]types.Datum{row, newRow}
Expand All @@ -407,7 +424,13 @@ func checkDeleteOnlyColumn(t *testing.T, ctx sessionctx.Context, tableID int64,

err = tbl.RemoveRecord(ctx.GetTableCtx(), newHandle, newRow)
require.NoError(t, err)
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
require.NoError(t, err)
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)
i = 0
err = tables.IterRecords(tbl, ctx, tbl.Cols(), func(_ kv.Handle, data []types.Datum, cols []*table.Column) (bool, error) {
Expand Down Expand Up @@ -447,7 +470,13 @@ func checkWriteOnlyColumn(t *testing.T, ctx sessionctx.Context, tableID int64, h
newRow := types.MakeDatums(int64(11), int64(22), int64(33))
newHandle, err := tbl.AddRecord(ctx.GetTableCtx(), newRow)
require.NoError(t, err)
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
require.NoError(t, err)
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)

rows := [][]types.Datum{row, newRow}
Expand All @@ -469,7 +498,14 @@ func checkWriteOnlyColumn(t *testing.T, ctx sessionctx.Context, tableID int64, h

err = tbl.RemoveRecord(ctx.GetTableCtx(), newHandle, newRow)
require.NoError(t, err)
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======

err = txn.Commit(context.Background())
require.NoError(t, err)
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)

i = 0
Expand Down Expand Up @@ -507,7 +543,13 @@ func checkReorganizationColumn(t *testing.T, ctx sessionctx.Context, tableID int
newRow := types.MakeDatums(int64(11), int64(22), int64(33))
newHandle, err := tbl.AddRecord(ctx.GetTableCtx(), newRow)
require.NoError(t, err)
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
require.NoError(t, err)
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)

rows := [][]types.Datum{row, newRow}
Expand All @@ -530,7 +572,13 @@ func checkReorganizationColumn(t *testing.T, ctx sessionctx.Context, tableID int

err = tbl.RemoveRecord(ctx.GetTableCtx(), newHandle, newRow)
require.NoError(t, err)
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
require.NoError(t, err)
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)

i = 0
Expand Down Expand Up @@ -573,7 +621,13 @@ func checkPublicColumn(t *testing.T, ctx sessionctx.Context, tableID int64, newC
}
handle, err := tbl.AddRecord(ctx.GetTableCtx(), newRow)
require.NoError(t, err)
<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
err = txn.Commit(context.Background())
require.NoError(t, err)
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)

rows := [][]types.Datum{updatedRow, newRow}
Expand All @@ -593,8 +647,14 @@ func checkPublicColumn(t *testing.T, ctx sessionctx.Context, tableID int64, newC

err = tbl.RemoveRecord(ctx.GetTableCtx(), handle, newRow)
require.NoError(t, err)
err = txn.Commit(context.Background())
require.NoError(t, err)

<<<<<<< HEAD
err = sessiontxn.NewTxn(context.Background(), ctx)
=======
txn, err = newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)

i = 0
Expand All @@ -611,7 +671,7 @@ func checkPublicColumn(t *testing.T, ctx sessionctx.Context, tableID int64, newC
}

func checkAddColumn(t *testing.T, state model.SchemaState, tableID int64, handle kv.Handle, newCol *table.Column, oldRow []types.Datum, columnValue any, dom *domain.Domain, store kv.Storage, columnCnt int) {
ctx := testNewContext(store)
ctx := testNewContext(t, store)
switch state {
case model.StateNone:
checkNoneColumn(t, ctx, tableID, handle, newCol, columnValue, dom)
Expand Down Expand Up @@ -655,8 +715,13 @@ func TestAddColumn(t *testing.T) {
tableID = int64(tableIDi)
tbl := testGetTable(t, dom, tableID)

<<<<<<< HEAD
ctx := testNewContext(store)
err := sessiontxn.NewTxn(context.Background(), ctx)
=======
ctx := testNewContext(t, store)
txn, err := newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)
oldRow := types.MakeDatums(int64(1), int64(2), int64(3))
handle, err := tbl.AddRecord(ctx.GetTableCtx(), oldRow)
Expand Down Expand Up @@ -728,8 +793,13 @@ func TestAddColumns(t *testing.T) {
tableID = int64(tableIDi)
tbl := testGetTable(t, dom, tableID)

<<<<<<< HEAD
ctx := testNewContext(store)
err := sessiontxn.NewTxn(context.Background(), ctx)
=======
ctx := testNewContext(t, store)
txn, err := newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)
oldRow := types.MakeDatums(int64(1), int64(2), int64(3))
handle, err := tbl.AddRecord(ctx.GetTableCtx(), oldRow)
Expand Down Expand Up @@ -791,7 +861,7 @@ func TestDropColumnInColumnTest(t *testing.T) {
tableID = int64(tableIDi)
tbl := testGetTable(t, dom, tableID)

ctx := testNewContext(store)
ctx := testNewContext(t, store)
colName := "c4"
defaultColValue := int64(4)
row := types.MakeDatums(int64(1), int64(2), int64(3))
Expand Down Expand Up @@ -852,8 +922,13 @@ func TestDropColumns(t *testing.T) {
tableID = int64(tableIDi)
tbl := testGetTable(t, dom, tableID)

<<<<<<< HEAD
ctx := testNewContext(store)
err := sessiontxn.NewTxn(context.Background(), ctx)
=======
ctx := testNewContext(t, store)
txn, err := newTxn(ctx)
>>>>>>> 0bf3e019002 (*: Update client-go and verify all read ts (#58054))
require.NoError(t, err)

colNames := []string{"c3", "c4"}
Expand Down
Loading