Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.18.4
go-version: 1.19
- name: Checkout code
uses: actions/checkout@v2
- name: Restore cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pd-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.18.4
go-version: 1.19
- name: Checkout code
uses: actions/checkout@v2
- name: Make
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pd-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: "1.18.4"
go-version: "1.19"
- name: Checkout code
uses: actions/checkout@v2
- name: Restore cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tso-consistency-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: "1.18.4"
go-version: "1.19"
- name: Checkout code
uses: actions/checkout@v2
- name: Make TSO Consistency Test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tso-function-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: "1.18.4"
go-version: "1.19"
- name: Checkout code
uses: actions/checkout@v2
- name: Make TSO Function Test
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash)

install-tools:
@mkdir -p $(GO_TOOLS_BIN_PATH)
@which golangci-lint >/dev/null 2>&1 || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_TOOLS_BIN_PATH) v1.47.1
@which golangci-lint >/dev/null 2>&1 || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_TOOLS_BIN_PATH) v1.48.0
@grep '_' tools.go | sed 's/"//g' | awk '{print $$2}' | xargs go install

.PHONY: install-tools
Expand Down
8 changes: 4 additions & 4 deletions client/tlsutil/tlsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ import (
"crypto/tls"
"crypto/x509"
"encoding/pem"
"io/ioutil"
"os"
)

// NewCert generates TLS cert by using the given cert,key and parse function.
func NewCert(certfile, keyfile string, parseFunc func([]byte, []byte) (tls.Certificate, error)) (*tls.Certificate, error) {
cert, err := ioutil.ReadFile(certfile)
cert, err := os.ReadFile(certfile)
if err != nil {
return nil, err
}

key, err := ioutil.ReadFile(keyfile)
key, err := os.ReadFile(keyfile)
if err != nil {
return nil, err
}
Expand All @@ -69,7 +69,7 @@ func NewCertPool(caFiles []string) (*x509.CertPool, error) {
certPool := x509.NewCertPool()

for _, caFile := range caFiles {
pemByte, err := ioutil.ReadFile(caFile)
pemByte, err := os.ReadFile(caFile)
if err != nil {
return nil, err
}
Expand Down
51 changes: 30 additions & 21 deletions pkg/btree/btree.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,24 @@
// It has a flatter structure than an equivalent red-black or other binary tree,
// which in some cases yields better memory usage and/or performance.
// See some discussion on the matter here:
// http://google-opensource.blogspot.com/2013/01/c-containers-that-save-memory-and-time.html
//
// http://google-opensource.blogspot.com/2013/01/c-containers-that-save-memory-and-time.html
//
// Note, though, that this project is in no way related to the C++ B-Tree
// implementation written about there.
//
// Within this tree, each node contains a slice of items and a (possibly nil)
// slice of children. For basic numeric values or raw structs, this can cause
// efficiency differences when compared to equivalent C++ template code that
// stores values in arrays within the node:
// * Due to the overhead of storing values as interfaces (each
// - Due to the overhead of storing values as interfaces (each
// value needs to be stored as the value itself, then 2 words for the
// interface pointing to that value and its type), resulting in higher
// memory use.
// * Since interfaces can point to values anywhere in memory, values are
// - Since interfaces can point to values anywhere in memory, values are
// most likely not stored in contiguous blocks, resulting in a higher
// number of cache misses.
//
// These issues don't tend to matter, though, when working with strings or other
// heap-allocated structures, since C++-equivalent structures also must store
// pointers and also distribute their values across the heap.
Expand Down Expand Up @@ -244,8 +247,8 @@ func (s *children) truncate(index int) {
// If the node has any children, indices[i] is the index of items[i] in the subtree.
// We have following formulas:
//
// indices[i] = if i == 0 { children[0].length() }
// else { indices[i-1] + 1 + children[i].length() }
// indices[i] = if i == 0 { children[0].length() }
// else { indices[i-1] + 1 + children[i].length() }
type indices []int

func (s *indices) addAt(index int, delta int) {
Expand Down Expand Up @@ -321,8 +324,8 @@ func (s indices) find(k int) (index int, found bool) {
// node is an internal node in a tree.
//
// It must at all times maintain the invariant that either
// * len(children) == 0, len(items) unconstrained
// * len(children) == len(items) + 1
// - len(children) == 0, len(items) unconstrained
// - len(children) == len(items) + 1
type node struct {
items items
children children
Expand Down Expand Up @@ -594,15 +597,20 @@ func (n *node) remove(item Item, minItems int, typ toRemove) (out Item) {
// remove it.
//
// Most documentation says we have to do two sets of special casing:
// 1) item is in this node
// 2) item is in child
// 1. item is in this node
// 2. item is in child
//
// In both cases, we need to handle the two subcases:
// A) node has enough values that it can spare one
// B) node doesn't have enough values
//
// A) node has enough values that it can spare one
// B) node doesn't have enough values
//
// For the latter, we have to check:
// a) left sibling has node to spare
// b) right sibling has node to spare
// c) we must merge
//
// a) left sibling has node to spare
// b) right sibling has node to spare
// c) we must merge
//
// To simplify our code here, we handle cases #1 and #2 the same:
// If a node doesn't have enough items, we make sure it does (using a,b,c).
// We then simply redo our remove call, and the second time (regardless of
Expand Down Expand Up @@ -1043,13 +1051,14 @@ func (t *BTree) getRootLength() int {
// one, instead of being lost to the garbage collector.
//
// This call takes:
// O(1): when addNodesToFreelist is false, this is a single operation.
// O(1): when the freelist is already full, it breaks out immediately
// O(freelist size): when the freelist is empty and the nodes are all owned
// by this tree, nodes are added to the freelist until full.
// O(tree size): when all nodes are owned by another tree, all nodes are
// iterated over looking for nodes to add to the freelist, and due to
// ownership, none are.
//
// O(1): when addNodesToFreelist is false, this is a single operation.
// O(1): when the freelist is already full, it breaks out immediately
// O(freelist size): when the freelist is empty and the nodes are all owned
// by this tree, nodes are added to the freelist until full.
// O(tree size): when all nodes are owned by another tree, all nodes are
// iterated over looking for nodes to add to the freelist, and due to
// ownership, none are.
func (t *BTree) Clear(addNodesToFreelist bool) {
if t.root != nil && addNodesToFreelist {
t.root.reset(t.cow)
Expand Down
18 changes: 11 additions & 7 deletions pkg/codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,18 @@ var pads = make([]byte, encGroupSize)

// EncodeBytes guarantees the encoded value is in ascending order for comparison,
// encoding with the following rule:
// [group1][marker1]...[groupN][markerN]
// group is 8 bytes slice which is padding with 0.
// marker is `0xFF - padding 0 count`
//
// [group1][marker1]...[groupN][markerN]
// group is 8 bytes slice which is padding with 0.
// marker is `0xFF - padding 0 count`
//
// For example:
// [] -> [0, 0, 0, 0, 0, 0, 0, 0, 247]
// [1, 2, 3] -> [1, 2, 3, 0, 0, 0, 0, 0, 250]
// [1, 2, 3, 0] -> [1, 2, 3, 0, 0, 0, 0, 0, 251]
// [1, 2, 3, 4, 5, 6, 7, 8] -> [1, 2, 3, 4, 5, 6, 7, 8, 255, 0, 0, 0, 0, 0, 0, 0, 0, 247]
//
// [] -> [0, 0, 0, 0, 0, 0, 0, 0, 247]
// [1, 2, 3] -> [1, 2, 3, 0, 0, 0, 0, 0, 250]
// [1, 2, 3, 0] -> [1, 2, 3, 0, 0, 0, 0, 0, 251]
// [1, 2, 3, 4, 5, 6, 7, 8] -> [1, 2, 3, 4, 5, 6, 7, 8, 255, 0, 0, 0, 0, 0, 0, 0, 0, 247]
//
// Refer: https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format#memcomparable-format
func EncodeBytes(data []byte) Key {
// Allocate more space to avoid unnecessary slice growing.
Expand Down
2 changes: 1 addition & 1 deletion pkg/netutil/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 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
// 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,
Expand Down
4 changes: 2 additions & 2 deletions plugin/scheduler_example/evict_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ func init() {
}

// SchedulerType returns the type of the scheduler
//nolint
// nolint
func SchedulerType() string {
return EvictLeaderType
}

// SchedulerArgs returns the args for the scheduler
//nolint
// nolint
func SchedulerArgs() []string {
args := []string{"1"}
return args
Expand Down
8 changes: 6 additions & 2 deletions server/api/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ func (h *adminHandler) DeleteAllRegionCache(w http.ResponseWriter, r *http.Reque
// @Failure 500 {string} string "PD server failed to proceed the request."
// @Router /admin/reset-ts [post]
// if force-use-larger=true:
// reset ts to max(current ts, input ts).
//
// reset ts to max(current ts, input ts).
//
// else:
// reset ts to input ts if it > current ts and < upper bound, error if not in that range
//
// reset ts to input ts if it > current ts and < upper bound, error if not in that range
//
// during EBS based restore, we call this to make sure ts of pd >= resolved_ts in backup.
func (h *adminHandler) ResetTS(w http.ResponseWriter, r *http.Request) {
handler := h.svr.GetHandler()
Expand Down
6 changes: 3 additions & 3 deletions server/api/pprof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 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
// 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,
Expand All @@ -17,7 +17,7 @@ import (
"archive/zip"
"bytes"
"fmt"
"io/ioutil"
"io"
"testing"

"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -54,7 +54,7 @@ func (suite *profTestSuite) TestGetZip() {
rsp, err := testDialClient.Get(suite.urlPrefix + "/pprof/zip?" + "seconds=5s")
suite.NoError(err)
defer rsp.Body.Close()
body, err := ioutil.ReadAll(rsp.Body)
body, err := io.ReadAll(rsp.Body)
suite.NoError(err)
suite.NotNil(body)
zipReader, err := zip.NewReader(bytes.NewReader(body), int64(len(body)))
Expand Down
90 changes: 45 additions & 45 deletions server/cluster/unsafe_recovery_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,51 +43,51 @@ const (
)

// Stage transition graph: for more details, please check `unsafeRecoveryController.HandleStoreHeartbeat()`
// +-----------+ +-----------+
// +-----------+ | | | |
// | | | collect | | tombstone |
// | idle |------>| Report |-----+---->| tiflash |-----+
// | | | | | | learner | |
// +-----------+ +-----------+ | | | |
// | +-----------+ |
// | | |
// | | |
// | v |
// | +-----------+ |
// | | | |
// | | force | |
// | | LeaderFor |-----+
// | |CommitMerge| |
// | | | |
// | +-----------+ |
// | | |
// | | |
// | v |
// | +-----------+ | +-----------+
// | | | | | | +-----------+
// | | force | | | exitForce | | |
// | | Leader |-----+---->| Leader |------->| failed |
// | | | | | | | |
// | +-----------+ | +-----------+ +-----------+
// | | |
// | | |
// | v |
// | +-----------+ |
// | | | |
// | | demote | |
// +-----| Voter |-----|
// | | |
// +-----------+ |
// | |
// | |
// v |
// +-----------+ +-----------+ |
// +-----------+ | | | | |
// | | | exitForce | | create | |
// | finished |<------| Leader |<----------| Region |-----+
// | | | | | |
// +-----------+ +-----------+ +-----------+
//
// +-----------+ +-----------+
// +-----------+ | | | |
// | | | collect | | tombstone |
// | idle |------>| Report |-----+---->| tiflash |-----+
// | | | | | | learner | |
// +-----------+ +-----------+ | | | |
// | +-----------+ |
// | | |
// | | |
// | v |
// | +-----------+ |
// | | | |
// | | force | |
// | | LeaderFor |-----+
// | |CommitMerge| |
// | | | |
// | +-----------+ |
// | | |
// | | |
// | v |
// | +-----------+ | +-----------+
// | | | | | | +-----------+
// | | force | | | exitForce | | |
// | | Leader |-----+---->| Leader |------->| failed |
// | | | | | | | |
// | +-----------+ | +-----------+ +-----------+
// | | |
// | | |
// | v |
// | +-----------+ |
// | | | |
// | | demote | |
// +-----| Voter |-----|
// | | |
// +-----------+ |
// | |
// | |
// v |
// +-----------+ +-----------+ |
// +-----------+ | | | | |
// | | | exitForce | | create | |
// | finished |<------| Leader |<----------| Region |-----+
// | | | | | |
// +-----------+ +-----------+ +-----------+
const (
idle unsafeRecoveryStage = iota
collectReport
Expand Down Expand Up @@ -381,7 +381,7 @@ func (u *unsafeRecoveryController) handleErr() bool {
return false
}

/// It dispatches recovery plan if any.
// It dispatches recovery plan if any.
func (u *unsafeRecoveryController) dispatchPlan(heartbeat *pdpb.StoreHeartbeatRequest, resp *pdpb.StoreHeartbeatResponse) {
storeID := heartbeat.Stats.StoreId
now := time.Now()
Expand Down
Loading