From 62c0f3461fddfaebdd20c249a4e0fbe5cc79ddca Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Tue, 16 Aug 2022 15:26:19 +0800 Subject: [PATCH 1/4] fmt the code using go1.19 Signed-off-by: Ryan Leung --- Makefile | 2 +- pkg/btree/btree.go | 51 ++++++----- pkg/codec/codec.go | 18 ++-- pkg/netutil/address_test.go | 2 +- plugin/scheduler_example/evict_leader.go | 4 +- server/api/pprof_test.go | 2 +- server/cluster/unsafe_recovery_controller.go | 90 +++++++++---------- server/encryptionkm/key_manager.go | 7 +- server/handler.go | 2 +- server/join/join.go | 39 ++++---- server/schedule/filter/filters_test.go | 2 +- server/schedule/labeler/rules.go | 2 +- server/schedule/operator/builder.go | 12 +-- server/schedule/placement/fit.go | 2 +- server/schedule/placement/fit_test.go | 2 +- server/schedulers/balance_benchmark_test.go | 2 +- .../buckets/hot_bucket_cache_test.go | 2 +- server/statistics/region_collection.go | 2 +- server/tso/global_allocator.go | 11 +-- server/tso/tso.go | 17 ++-- 20 files changed, 145 insertions(+), 126 deletions(-) diff --git a/Makefile b/Makefile index 839e7d33fb1..d5619dd693e 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/pkg/btree/btree.go b/pkg/btree/btree.go index 68049a8dbaf..2d1f85f7632 100644 --- a/pkg/btree/btree.go +++ b/pkg/btree/btree.go @@ -25,7 +25,9 @@ // 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. // @@ -33,13 +35,14 @@ // 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. @@ -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) { @@ -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 @@ -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 @@ -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) diff --git a/pkg/codec/codec.go b/pkg/codec/codec.go index aefe4374bf7..fb4b61a6ef8 100644 --- a/pkg/codec/codec.go +++ b/pkg/codec/codec.go @@ -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. diff --git a/pkg/netutil/address_test.go b/pkg/netutil/address_test.go index 211b29083e6..faa3e2e1d04 100644 --- a/pkg/netutil/address_test.go +++ b/pkg/netutil/address_test.go @@ -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, diff --git a/plugin/scheduler_example/evict_leader.go b/plugin/scheduler_example/evict_leader.go index cf52f7a96c3..d0d2e49263d 100644 --- a/plugin/scheduler_example/evict_leader.go +++ b/plugin/scheduler_example/evict_leader.go @@ -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 diff --git a/server/api/pprof_test.go b/server/api/pprof_test.go index a0165aaf27d..8472960d7e1 100644 --- a/server/api/pprof_test.go +++ b/server/api/pprof_test.go @@ -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, diff --git a/server/cluster/unsafe_recovery_controller.go b/server/cluster/unsafe_recovery_controller.go index a0ecf777721..58f19faca3e 100644 --- a/server/cluster/unsafe_recovery_controller.go +++ b/server/cluster/unsafe_recovery_controller.go @@ -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 @@ -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() diff --git a/server/encryptionkm/key_manager.go b/server/encryptionkm/key_manager.go index 0bd4c10b339..671034721bf 100644 --- a/server/encryptionkm/key_manager.go +++ b/server/encryptionkm/key_manager.go @@ -344,9 +344,10 @@ func (m *KeyManager) loadKeys() error { } // rotateKeyIfNeeded rotate key if one of the following condition is meet. -// * Encryption method is changed. -// * Current key is exposed. -// * Current key expired. +// - Encryption method is changed. +// - Current key is exposed. +// - Current key expired. +// // Otherwise re-save all keys to finish master key rotation if forceUpdate = true. // Require mu lock to be held. func (m *KeyManager) rotateKeyIfNeeded(forceUpdate bool) error { diff --git a/server/handler.go b/server/handler.go index 9e7210d8d78..5615150f2c1 100644 --- a/server/handler.go +++ b/server/handler.go @@ -202,7 +202,7 @@ func (h *Handler) GetHotRegionsWriteInterval() time.Duration { return h.opt.GetHotRegionsWriteInterval() } -// GetHotRegionsReservedDays gets days hot region information is kept. +// GetHotRegionsReservedDays gets days hot region information is kept. func (h *Handler) GetHotRegionsReservedDays() uint64 { return h.opt.GetHotRegionsReservedDays() } diff --git a/server/join/join.go b/server/join/join.go index b8b4aa2a2a4..6c675bb6d3a 100644 --- a/server/join/join.go +++ b/server/join/join.go @@ -46,8 +46,9 @@ var listMemberRetryTimes = 20 // and returns the initial configuration of the PD cluster. // // TL;TR: The join functionality is safe. With data, join does nothing, w/o data -// and it is not a member of cluster, join does MemberAdd, it returns an -// error if PD tries to join itself, missing data or join a duplicated PD. +// +// and it is not a member of cluster, join does MemberAdd, it returns an +// error if PD tries to join itself, missing data or join a duplicated PD. // // Etcd automatically re-joins the cluster if there is a data directory. So // first it checks if there is a data directory or not. If there is, it returns @@ -56,29 +57,29 @@ var listMemberRetryTimes = 20 // // If there is no data directory, there are following cases: // -// - A new PD joins an existing cluster. -// What join does: MemberAdd, MemberList, then generate initial-cluster. +// - A new PD joins an existing cluster. +// What join does: MemberAdd, MemberList, then generate initial-cluster. // -// - A failed PD re-joins the previous cluster. -// What join does: return an error. (etcd reports: raft log corrupted, -// truncated, or lost?) +// - A failed PD re-joins the previous cluster. +// What join does: return an error. (etcd reports: raft log corrupted, +// truncated, or lost?) // -// - A deleted PD joins to previous cluster. -// What join does: MemberAdd, MemberList, then generate initial-cluster. -// (it is not in the member list and there is no data, so -// we can treat it as a new PD.) +// - A deleted PD joins to previous cluster. +// What join does: MemberAdd, MemberList, then generate initial-cluster. +// (it is not in the member list and there is no data, so +// we can treat it as a new PD.) // // If there is a data directory, there are following special cases: // -// - A failed PD tries to join the previous cluster but it has been deleted -// during its downtime. -// What join does: return "" (etcd will connect to other peers and find -// that the PD itself has been removed.) +// - A failed PD tries to join the previous cluster but it has been deleted +// during its downtime. +// What join does: return "" (etcd will connect to other peers and find +// that the PD itself has been removed.) // -// - A deleted PD joins the previous cluster. -// What join does: return "" (as etcd will read data directory and find -// that the PD itself has been removed, so an empty string -// is fine.) +// - A deleted PD joins the previous cluster. +// What join does: return "" (as etcd will read data directory and find +// that the PD itself has been removed, so an empty string +// is fine.) func PrepareJoinCluster(cfg *config.Config) error { // - A PD tries to join itself. if cfg.Join == "" { diff --git a/server/schedule/filter/filters_test.go b/server/schedule/filter/filters_test.go index 5bb8e7eec41..2a5ed445098 100644 --- a/server/schedule/filter/filters_test.go +++ b/server/schedule/filter/filters_test.go @@ -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, diff --git a/server/schedule/labeler/rules.go b/server/schedule/labeler/rules.go index 3d14f1d2450..c902fff8f66 100644 --- a/server/schedule/labeler/rules.go +++ b/server/schedule/labeler/rules.go @@ -171,7 +171,7 @@ func (rule *LabelRule) expireBefore(t time.Time) bool { return rule.minExpire.Before(t) } -// initKeyRangeRulesFromLabelRuleData init and adjust []KeyRangeRule from `LabelRule.Data`` +// initKeyRangeRulesFromLabelRuleData init and adjust []KeyRangeRule from `LabelRule.Data“ func initKeyRangeRulesFromLabelRuleData(data interface{}) ([]*KeyRangeRule, error) { rules, ok := data.([]interface{}) if !ok { diff --git a/server/schedule/operator/builder.go b/server/schedule/operator/builder.go index 85fed44599e..752e9c1a1a4 100644 --- a/server/schedule/operator/builder.go +++ b/server/schedule/operator/builder.go @@ -39,11 +39,13 @@ type ClusterInformer interface { } // Builder is used to create operators. Usage: -// op, err := NewBuilder(desc, cluster, region). -// RemovePeer(store1). -// AddPeer(peer1). -// SetLeader(store2). -// Build(kind) +// +// op, err := NewBuilder(desc, cluster, region). +// RemovePeer(store1). +// AddPeer(peer1). +// SetLeader(store2). +// Build(kind) +// // The generated Operator will choose the most appropriate execution order // according to various constraints. type Builder struct { diff --git a/server/schedule/placement/fit.go b/server/schedule/placement/fit.go index 255c544ec9c..9a28244137a 100644 --- a/server/schedule/placement/fit.go +++ b/server/schedule/placement/fit.go @@ -258,7 +258,7 @@ func (w *fitWorker) fixRuleWithCandidates(candidates []*fitPeer, index int, coun return better } -// pickPeersFromBinaryInt picks the candidates with the related index at the position of binary for the `binaryNumber`` is `1`. +// pickPeersFromBinaryInt picks the candidates with the related index at the position of binary for the `binaryNumber` is `1`. // binaryNumber = 5, which means the related binary is 101, it will returns {candidates[0],candidates[2]} // binaryNumber = 6, which means the related binary is 110, it will returns {candidates[1],candidates[2]} func pickPeersFromBinaryInt(candidates []*fitPeer, binaryNumber uint) []*fitPeer { diff --git a/server/schedule/placement/fit_test.go b/server/schedule/placement/fit_test.go index 7c4c9147ac5..15ace4d817b 100644 --- a/server/schedule/placement/fit_test.go +++ b/server/schedule/placement/fit_test.go @@ -68,7 +68,7 @@ func makeRegion(def string) *core.RegionInfo { } // example: "3/voter/zone=zone1+zone2,rack=rack2/zone,rack,host" -// count role constraints location_labels +// count role constraints location_labels func makeRule(def string) *Rule { var rule Rule splits := strings.Split(def, "/") diff --git a/server/schedulers/balance_benchmark_test.go b/server/schedulers/balance_benchmark_test.go index 25006b10d99..01fe60bc1dc 100644 --- a/server/schedulers/balance_benchmark_test.go +++ b/server/schedulers/balance_benchmark_test.go @@ -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, diff --git a/server/statistics/buckets/hot_bucket_cache_test.go b/server/statistics/buckets/hot_bucket_cache_test.go index a55a505957b..e9669eb2eec 100644 --- a/server/statistics/buckets/hot_bucket_cache_test.go +++ b/server/statistics/buckets/hot_bucket_cache_test.go @@ -75,7 +75,7 @@ func TestPutItem(t *testing.T) { regionCount: 2, treeLen: 2, }, { - // // case 5: region 1,2,3 will be merged. + // case 5: region 1,2,3 will be merged. regionID: 4, keys: [][]byte{[]byte(""), []byte("")}, regionCount: 1, diff --git a/server/statistics/region_collection.go b/server/statistics/region_collection.go index 1c46d7acdda..ab5e6b22d9c 100644 --- a/server/statistics/region_collection.go +++ b/server/statistics/region_collection.go @@ -191,7 +191,7 @@ func (r *RegionStatistics) Observe(region *core.RegionInfo, stores []*core.Store // Better to make sure once any of these conditions changes, it will trigger the heartbeat `save_cache`. // Otherwise, the state may be out-of-date for a long time, which needs another way to apply the change ASAP. - // For example, see `RegionStatsNeedUpdate` above to know how `OversizedRegion` and ``UndersizedRegion` are updated. + // For example, see `RegionStatsNeedUpdate` above to know how `OversizedRegion` and `UndersizedRegion` are updated. conditions := map[RegionStatisticType]bool{ MissPeer: len(region.GetPeers()) < desiredReplicas, ExtraPeer: len(region.GetPeers()) > desiredReplicas, diff --git a/server/tso/global_allocator.go b/server/tso/global_allocator.go index c5aaaaac819..e64512b4161 100644 --- a/server/tso/global_allocator.go +++ b/server/tso/global_allocator.go @@ -146,12 +146,13 @@ func (gta *GlobalTSOAllocator) SetTSO(tso uint64) error { // GenerateTSO is used to generate the given number of TSOs. // Make sure you have initialized the TSO allocator before calling this method. // Basically, there are two ways to generate a Global TSO: -// 1. The old way to generate a normal TSO from memory directly, which makes the TSO service node become single point. -// 2. The new way to generate a Global TSO by synchronizing with all other Local TSO Allocators. +// 1. The old way to generate a normal TSO from memory directly, which makes the TSO service node become single point. +// 2. The new way to generate a Global TSO by synchronizing with all other Local TSO Allocators. +// // And for the new way, there are two different strategies: -// 1. Collect the max Local TSO from all Local TSO Allocator leaders and write it back to them as MaxTS. -// 2. Estimate a MaxTS and try to write it to all Local TSO Allocator leaders directly to reduce the RTT. -// During the process, if the estimated MaxTS is not accurate, it will fallback to the collecting way. +// 1. Collect the max Local TSO from all Local TSO Allocator leaders and write it back to them as MaxTS. +// 2. Estimate a MaxTS and try to write it to all Local TSO Allocator leaders directly to reduce the RTT. +// During the process, if the estimated MaxTS is not accurate, it will fallback to the collecting way. func (gta *GlobalTSOAllocator) GenerateTSO(count uint32) (pdpb.Timestamp, error) { if !gta.leadership.Check() { tsoCounter.WithLabelValues("not_leader", gta.timestampOracle.dcLocation).Inc() diff --git a/server/tso/tso.go b/server/tso/tso.go index b7a00c3f9ab..a52b2a70188 100644 --- a/server/tso/tso.go +++ b/server/tso/tso.go @@ -125,10 +125,11 @@ func (t *timestampOracle) generateTSO(count int64, suffixBits int) (physical int // in etcd with the value of 1. // Once we get a normal TSO like this (18 bits): xxxxxxxxxxxxxxxxxx. We will make the TSO's // low bits of logical part from each DC looks like: -// global: xxxxxxxxxx00000000 -// dc-1: xxxxxxxxxx00000001 -// dc-2: xxxxxxxxxx00000010 -// dc-3: xxxxxxxxxx00000011 +// +// global: xxxxxxxxxx00000000 +// dc-1: xxxxxxxxxx00000001 +// dc-2: xxxxxxxxxx00000010 +// dc-3: xxxxxxxxxx00000011 func (t *timestampOracle) differentiateLogical(rawLogical int64, suffixBits int) int64 { return rawLogical< Date: Fri, 26 Aug 2022 12:00:36 +0800 Subject: [PATCH 2/4] upgrade ci go version Signed-off-by: nolouch --- .github/workflows/check.yaml | 2 +- .github/workflows/pd-docker-image.yaml | 2 +- .github/workflows/pd-tests.yaml | 2 +- .github/workflows/tso-consistency-test.yaml | 2 +- .github/workflows/tso-function-test.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index b47331ec73f..36390880843 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -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 diff --git a/.github/workflows/pd-docker-image.yaml b/.github/workflows/pd-docker-image.yaml index 34e384b5581..b48cadc833a 100644 --- a/.github/workflows/pd-docker-image.yaml +++ b/.github/workflows/pd-docker-image.yaml @@ -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 diff --git a/.github/workflows/pd-tests.yaml b/.github/workflows/pd-tests.yaml index 86c6302e070..ab986a40a0d 100644 --- a/.github/workflows/pd-tests.yaml +++ b/.github/workflows/pd-tests.yaml @@ -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 diff --git a/.github/workflows/tso-consistency-test.yaml b/.github/workflows/tso-consistency-test.yaml index d71f7e21fd5..c373b809fb6 100644 --- a/.github/workflows/tso-consistency-test.yaml +++ b/.github/workflows/tso-consistency-test.yaml @@ -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 diff --git a/.github/workflows/tso-function-test.yaml b/.github/workflows/tso-function-test.yaml index 272694f7537..85240fe2d72 100644 --- a/.github/workflows/tso-function-test.yaml +++ b/.github/workflows/tso-function-test.yaml @@ -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 From 250eb9d87fd93e7a64af19dfdba24bb30aa52b4b Mon Sep 17 00:00:00 2001 From: nolouch Date: Fri, 26 Aug 2022 12:18:35 +0800 Subject: [PATCH 3/4] fix ioutil Signed-off-by: nolouch --- client/tlsutil/tlsutil.go | 8 ++++---- server/api/pprof_test.go | 4 ++-- server/config/store_config.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/tlsutil/tlsutil.go b/client/tlsutil/tlsutil.go index 4501e194432..16e758cefdd 100644 --- a/client/tlsutil/tlsutil.go +++ b/client/tlsutil/tlsutil.go @@ -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 } @@ -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 } diff --git a/server/api/pprof_test.go b/server/api/pprof_test.go index 8472960d7e1..9965dbed73b 100644 --- a/server/api/pprof_test.go +++ b/server/api/pprof_test.go @@ -17,7 +17,7 @@ import ( "archive/zip" "bytes" "fmt" - "io/ioutil" + "io" "testing" "github.com/stretchr/testify/suite" @@ -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))) diff --git a/server/config/store_config.go b/server/config/store_config.go index 27fc456dd08..74a3957acbe 100644 --- a/server/config/store_config.go +++ b/server/config/store_config.go @@ -17,7 +17,7 @@ package config import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "reflect" "sync/atomic" @@ -230,7 +230,7 @@ func (s TiKVConfigSource) GetConfig(statusAddress string) (*StoreConfig, error) return nil, err } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } From ce32127d805ebba66bfdec83d657c040df2923ca Mon Sep 17 00:00:00 2001 From: nolouch Date: Fri, 26 Aug 2022 12:20:49 +0800 Subject: [PATCH 4/4] fix docs Signed-off-by: nolouch --- server/api/admin.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/api/admin.go b/server/api/admin.go index 994ca974152..93dffbd66c5 100644 --- a/server/api/admin.go +++ b/server/api/admin.go @@ -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()