Skip to content

Commit

Permalink
Merge branch 'master' into json-use-jsoniter
Browse files Browse the repository at this point in the history
  • Loading branch information
3AceShowHand committed Oct 12, 2022
2 parents 9097912 + 3752703 commit 21d7161
Show file tree
Hide file tree
Showing 279 changed files with 14,467 additions and 8,360 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check_and_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Cache Tools
id: cache-tools
Expand All @@ -68,7 +68,7 @@ jobs:
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Build
run: make build
2 changes: 1 addition & 1 deletion .github/workflows/dataflow_engine_chaos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Cache go modules
uses: actions/cache@v2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/dataflow_engine_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Build images
run: make engine_image
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Build images
run: make engine_image
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Build images
run: make engine_image
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Build images
run: make engine_image
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dm_binlog_999999.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-20.04

steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Check out code
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dm_chaos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Set up Go for building DM, now it's v1.16
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- name: Print Go version
run: go version

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dm_upstream_switch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-20.04

steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Check out code
uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ticdc_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Cache Vendor
id: cache-vendor
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Cache Vendor
id: cache-vendor
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Cache Vendor
id: cache-vendor
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/upgrade_dm_via_tiup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
working-directory: ${{ github.workspace }}/go/src/github.com/pingcap/tiflow

steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Check out code
uses: actions/checkout@v2
Expand Down Expand Up @@ -80,10 +80,10 @@ jobs:
["v2.0.1", "v2.0.7", "v5.3.0"]

steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Check out code
uses: actions/checkout@v2
Expand Down Expand Up @@ -186,10 +186,10 @@ jobs:
env:
working-directory: ${{ github.workspace }}/go/src/github.com/pingcap/tiflow
steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Check out code
uses: actions/checkout@v2
Expand Down
7 changes: 6 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
go: 1.18
go: 1.19
linters:
enable:
- unconvert
Expand Down Expand Up @@ -101,6 +101,11 @@ issues:
- errcheck
- gosec
- makezero
# G113 Potential uncontrolled memory consumption in Rat.SetString (CVE-2022-23772)
# only affects gp < 1.16.14. and go < 1.17.7
- text: "(G113)"
linters:
- gosec
include:
- EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported)
- EXC0014 # comment on exported (.+) should be of the form "(.+)..."
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ your contribution accepted.

Developing TiDB-CDC requires:

* [Go 1.18+](https://go.dev/doc/code)
* [Go 1.19+](https://go.dev/doc/code)
* An internet connection to download the dependencies

Simply run `make` to build the program.
Expand Down
2 changes: 1 addition & 1 deletion README_DM.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To check the code style and build binaries, you can simply run:
make build
```

Note that DM supports building with Go version `Go >= 1.16`, and unit test preparation can be found in [Running/Unit Test](dm/tests/README.md#Unit-Test)
Note that DM supports building with Go version `Go >= 1.19`, and unit test preparation can be found in [Running/Unit Test](dm/tests/README.md#Unit-Test)

If you only want to build binaries, you can run:

Expand Down
2 changes: 1 addition & 1 deletion README_TiCDC.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ make cdc
$ make test
```

Note that TiCDC supports building with Go version `Go >= 1.18`.
Note that TiCDC supports building with Go version `Go >= 1.19`.

When TiCDC is built successfully, you can find binary in the `bin` directory. Instructions for unit test and integration
test can be found in [Running tests](./tests/integration_tests/README.md).
Expand Down
6 changes: 2 additions & 4 deletions cdc/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,8 @@ func (h *OpenAPI) ListChangefeed(c *gin.Context) {
ID: cfID.ID,
}

if cfInfo != nil {
resp.FeedState = cfInfo.State
resp.RunningError = cfInfo.Error
}
resp.FeedState = cfInfo.State
resp.RunningError = cfInfo.Error

if cfStatus != nil {
resp.CheckpointTSO = cfStatus.CheckpointTs
Expand Down
38 changes: 38 additions & 0 deletions cdc/api/v2/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,22 @@ func (c *ReplicaConfig) ToInternalReplicaConfig() *config.ReplicaConfig {
Columns: selector.Columns,
})
}
var csvConfig *config.CSVConfig
if c.Sink.CSVConfig != nil {
csvConfig = &config.CSVConfig{
Delimiter: c.Sink.CSVConfig.Delimiter,
Quote: c.Sink.CSVConfig.Quote,
Terminator: c.Sink.CSVConfig.Terminator,
NullString: c.Sink.CSVConfig.NullString,
DateSeparator: c.Sink.CSVConfig.DateSeparator,
IncludeCommitTs: c.Sink.CSVConfig.IncludeCommitTs,
}
}

res.Sink = &config.SinkConfig{
DispatchRules: dispatchRules,
Protocol: c.Sink.Protocol,
CSVConfig: csvConfig,
TxnAtomicity: config.AtomicityLevel(c.Sink.TxnAtomicity),
ColumnSelectors: columnSelectors,
SchemaRegistry: c.Sink.SchemaRegistry,
Expand Down Expand Up @@ -259,10 +272,23 @@ func ToAPIReplicaConfig(c *config.ReplicaConfig) *ReplicaConfig {
Columns: selector.Columns,
})
}
var csvConfig *CSVConfig
if cloned.Sink.CSVConfig != nil {
csvConfig = &CSVConfig{
Delimiter: cloned.Sink.CSVConfig.Delimiter,
Quote: cloned.Sink.CSVConfig.Quote,
Terminator: cloned.Sink.CSVConfig.Terminator,
NullString: cloned.Sink.CSVConfig.NullString,
DateSeparator: cloned.Sink.CSVConfig.DateSeparator,
IncludeCommitTs: cloned.Sink.CSVConfig.IncludeCommitTs,
}
}

res.Sink = &SinkConfig{
Protocol: cloned.Sink.Protocol,
SchemaRegistry: cloned.Sink.SchemaRegistry,
DispatchRules: dispatchRules,
CSVConfig: csvConfig,
ColumnSelectors: columnSelectors,
TxnAtomicity: string(cloned.Sink.TxnAtomicity),
}
Expand Down Expand Up @@ -392,11 +418,23 @@ type Table struct {
type SinkConfig struct {
Protocol string `json:"protocol"`
SchemaRegistry string `json:"schema_registry"`
CSVConfig *CSVConfig `json:"csv"`
DispatchRules []*DispatchRule `json:"dispatchers,omitempty"`
ColumnSelectors []*ColumnSelector `json:"column_selectors"`
TxnAtomicity string `json:"transaction_atomicity"`
}

// CSVConfig denotes the csv config
// This is the same as config.CSVConfig
type CSVConfig struct {
Delimiter string `json:"delimiter"`
Quote string `json:"quote"`
Terminator string `json:"terminator"`
NullString string `json:"null"`
DateSeparator string `json:"date_separator"`
IncludeCommitTs bool `json:"include_commit_ts"`
}

// DispatchRule represents partition rule for a table
// This is a duplicate of config.DispatchRule
type DispatchRule struct {
Expand Down
1 change: 1 addition & 0 deletions cdc/capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ func (c *captureImpl) campaignOwner(ctx cdcContext.Context) error {
err = c.runEtcdWorker(ownerCtx, owner,
orchestrator.NewGlobalState(c.EtcdClient.GetClusterID()),
ownerFlushInterval, util.RoleOwner.String())
c.owner.AsyncStop()
c.setOwner(nil)

// if owner exits, resign the owner key,
Expand Down
15 changes: 7 additions & 8 deletions cdc/entry/schema/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,6 @@ func (s *snapshot) iterPartitions(includeIneligible bool, f func(id int64, i *mo
}
return true
})
return
}

func (s *snapshot) iterSchemas(f func(i *timodel.DBInfo)) {
Expand Down Expand Up @@ -1128,7 +1127,7 @@ func (s *snapshot) drop() {

schemas := make([]versionedID, 0, s.schemas.Len())
var schemaID int64 = -1
var schemaDroped bool = false
schemaDroped := false
s.schemas.Ascend(func(x versionedID) bool {
if x.tag >= tag {
if x.id != schemaID {
Expand All @@ -1148,7 +1147,7 @@ func (s *snapshot) drop() {

tables := make([]versionedID, 0, s.tables.Len())
var tableID int64 = -1
var tableDroped bool = false
tableDroped := false
s.tables.Ascend(func(x versionedID) bool {
if x.tag >= tag {
if x.id != tableID {
Expand Down Expand Up @@ -1178,7 +1177,7 @@ func (s *snapshot) drop() {

partitions := make([]versionedID, 0, s.partitions.Len())
var partitionID int64 = -1
var partitionDroped bool = false
partitionDroped := false
s.partitions.Ascend(func(x versionedID) bool {
if x.tag >= tag {
if x.id != partitionID {
Expand All @@ -1204,8 +1203,8 @@ func (s *snapshot) drop() {
}

schemaNames := make([]versionedEntityName, 0, s.schemaNameToID.Len())
var schemaName string = ""
var schemaNameDroped bool = false
schemaName := ""
schemaNameDroped := false
s.schemaNameToID.Ascend(func(x versionedEntityName) bool {
if x.tag >= tag {
if x.entity != schemaName {
Expand All @@ -1225,8 +1224,8 @@ func (s *snapshot) drop() {

tableNames := make([]versionedEntityName, 0, s.tableNameToID.Len())
schemaID = -1
var tableName string = ""
var tableNameDroped bool = false
tableName := ""
tableNameDroped := false
s.tableNameToID.Ascend(func(x versionedEntityName) bool {
if x.tag >= tag {
if x.prefix != schemaID || x.entity != tableName {
Expand Down
4 changes: 2 additions & 2 deletions cdc/entry/schema_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func TestTable(t *testing.T) {
}
preTableInfo, err := snap.PreTableInfo(job)
require.Nil(t, err)
require.Equal(t, preTableInfo.TableName, model.TableName{Schema: "Test", Table: "T"})
require.Equal(t, preTableInfo.TableName, model.TableName{Schema: "Test", Table: "T", TableID: 2})
require.Equal(t, preTableInfo.ID, int64(2))

err = snap.HandleDDL(job)
Expand All @@ -262,7 +262,7 @@ func TestTable(t *testing.T) {
}
preTableInfo, err = snap.PreTableInfo(job)
require.Nil(t, err)
require.Equal(t, preTableInfo.TableName, model.TableName{Schema: "Test", Table: "T"})
require.Equal(t, preTableInfo.TableName, model.TableName{Schema: "Test", Table: "T", TableID: 9})
require.Equal(t, preTableInfo.ID, int64(9))

err = snap.HandleDDL(job)
Expand Down
Loading

0 comments on commit 21d7161

Please sign in to comment.