Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <jinhao.hu@pingcap.com>
  • Loading branch information
HuSharp committed Mar 1, 2024
1 parent 6cb8917 commit 4c811eb
Show file tree
Hide file tree
Showing 40 changed files with 110 additions and 106 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func newClientWithKeyspaceName(
return nil
}

// Create a PD service discovery with null keyspace id, then query the real id wth the keyspace name,
// Create a PD service discovery with null keyspace id, then query the real id with the keyspace name,
// finally update the keyspace id to the PD service discovery for the following interactions.
c.pdSvcDiscovery = newPDServiceDiscovery(
clientCtx, clientCancel, &c.wg, c.setServiceMode, updateKeyspaceIDCb, nullKeyspaceID, c.svrUrls, c.tlsCfg, c.option)
Expand Down
2 changes: 1 addition & 1 deletion client/pd_service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ func (c *pdServiceDiscovery) GetServiceClient() ServiceClient {
return leaderClient
}

// GetAllServiceClients implments ServiceDiscovery
// GetAllServiceClients implements ServiceDiscovery
func (c *pdServiceDiscovery) GetAllServiceClients() []ServiceClient {
all := c.all.Load()
if all == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/btree/btree_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ type copyOnWriteContext[T Item[T]] struct {
// The internal tree structure of b is marked read-only and shared between t and
// t2. Writes to both t and t2 use copy-on-write logic, creating new nodes
// whenever one of b's original nodes would have been modified. Read operations
// should have no performance degredation. Write operations for both t and t2
// should have no performance degradation. Write operations for both t and t2
// will initially experience minor slow-downs caused by additional allocs and
// copies due to the aforementioned copy-on-write logic, but should converge to
// the original performance characteristics of the original tree.
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/fifo.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c *FIFO) FromElems(key uint64) []*Item {
return elems
}

// FromLastSameElems returns continuous items that have the same comparable attribute with the the lastest one.
// FromLastSameElems returns continuous items that have the same comparable attribute with the last one.
func (c *FIFO) FromLastSameElems(checkFunc func(any) (bool, string)) []*Item {
c.RLock()
defer c.RUnlock()
Expand Down
2 changes: 1 addition & 1 deletion pkg/cgroup/cgroup_cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func checkKernelVersionNewerThan(re *require.Assertions, t *testing.T, major, mi
re.Len(kernelVersion, 1, fmt.Sprintf("release str is %s", releaseStr))
kernelVersionPartRE := regexp.MustCompile(`[0-9]+`)
kernelVersionParts := kernelVersionPartRE.FindAllString(kernelVersion[0], -1)
re.Len(kernelVersionParts, 3, fmt.Sprintf("kernel verion str is %s", kernelVersion[0]))
re.Len(kernelVersionParts, 3, fmt.Sprintf("kernel version str is %s", kernelVersion[0]))
t.Logf("parsed kernel version parts: major %s, minor %s, patch %s",
kernelVersionParts[0], kernelVersionParts[1], kernelVersionParts[2])
mustConvInt := func(s string) int {
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/rangetree/range_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func bucketDebrisFactory(startKey, endKey []byte, item RangeItem) []RangeItem {
if bytes.Compare(left, right) >= 0 {
return nil
}
// the left has oen intersection like |010 - 100| and |020 - 100|.
// the left has one intersection like |010 - 100| and |020 - 100|.
if !bytes.Equal(item.GetStartKey(), left) {
res = append(res, newSimpleBucketItem(item.GetStartKey(), left))
}
// the right has oen intersection like |010 - 100| and |010 - 099|.
// the right has one intersection like |010 - 100| and |010 - 099|.
if !bytes.Equal(right, item.GetEndKey()) {
res = append(res, newSimpleBucketItem(right, item.GetEndKey()))
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/core/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -1708,16 +1708,16 @@ func (r *RegionsInfo) GetAverageRegionSize() int64 {
// ValidRegion is used to decide if the region is valid.
func (r *RegionsInfo) ValidRegion(region *metapb.Region) error {
startKey := region.GetStartKey()
currnetRegion := r.GetRegionByKey(startKey)
if currnetRegion == nil {
currentRegion := r.GetRegionByKey(startKey)
if currentRegion == nil {
return errors.Errorf("region not found, request region: %v", logutil.RedactStringer(RegionToHexMeta(region)))
}
// If the request epoch is less than current region epoch, then returns an error.
regionEpoch := region.GetRegionEpoch()
currnetEpoch := currnetRegion.GetMeta().GetRegionEpoch()
if regionEpoch.GetVersion() < currnetEpoch.GetVersion() ||
regionEpoch.GetConfVer() < currnetEpoch.GetConfVer() {
return errors.Errorf("invalid region epoch, request: %v, current: %v", regionEpoch, currnetEpoch)
currentEpoch := currentRegion.GetMeta().GetRegionEpoch()
if regionEpoch.GetVersion() < currentEpoch.GetVersion() ||
regionEpoch.GetConfVer() < currentEpoch.GetConfVer() {
return errors.Errorf("invalid region epoch, request: %v, current: %v", regionEpoch, currentEpoch)
}
return nil
}
Expand Down Expand Up @@ -1806,19 +1806,19 @@ func EncodeToString(src []byte) []byte {
return dst
}

// HexRegionKey converts region key to hex format. Used for formating region in
// HexRegionKey converts region key to hex format. Used for formatting region in
// logs.
func HexRegionKey(key []byte) []byte {
return ToUpperASCIIInplace(EncodeToString(key))
}

// HexRegionKeyStr converts region key to hex format. Used for formating region in
// HexRegionKeyStr converts region key to hex format. Used for formatting region in
// logs.
func HexRegionKeyStr(key []byte) string {
return String(HexRegionKey(key))
}

// RegionToHexMeta converts a region meta's keys to hex format. Used for formating
// RegionToHexMeta converts a region meta's keys to hex format. Used for formatting
// region in logs.
func RegionToHexMeta(meta *metapb.Region) HexRegionMeta {
if meta == nil {
Expand All @@ -1827,7 +1827,7 @@ func RegionToHexMeta(meta *metapb.Region) HexRegionMeta {
return HexRegionMeta{meta}
}

// HexRegionMeta is a region meta in the hex format. Used for formating region in logs.
// HexRegionMeta is a region meta in the hex format. Used for formatting region in logs.
type HexRegionMeta struct {
*metapb.Region
}
Expand All @@ -1839,15 +1839,15 @@ func (h HexRegionMeta) String() string {
return strings.TrimSpace(proto.CompactTextString(meta))
}

// RegionsToHexMeta converts regions' meta keys to hex format. Used for formating
// RegionsToHexMeta converts regions' meta keys to hex format. Used for formatting
// region in logs.
func RegionsToHexMeta(regions []*metapb.Region) HexRegionsMeta {
hexRegionMetas := make([]*metapb.Region, len(regions))
copy(hexRegionMetas, regions)
return hexRegionMetas
}

// HexRegionsMeta is a slice of regions' meta in the hex format. Used for formating
// HexRegionsMeta is a slice of regions' meta in the hex format. Used for formatting
// region in logs.
type HexRegionsMeta []*metapb.Region

Expand Down
2 changes: 1 addition & 1 deletion pkg/encryption/crypter.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func newIV(ivLength int) ([]byte, error) {
}
if n != ivLength {
return nil, errs.ErrEncryptionGenerateIV.GenWithStack(
"iv length exepcted %d vs actual %d", ivLength, n)
"iv length expected %d vs actual %d", ivLength, n)

Check warning on line 85 in pkg/encryption/crypter.go

View check run for this annotation

Codecov / codecov/patch

pkg/encryption/crypter.go#L85

Added line #L85 was not covered by tests
}
return iv, nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/encryption/key_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ func TestSetLeadershipWithEncryptionMethodChanged(t *testing.T) {
}
err := saveKeys(leadership, masterKeyMeta, keys, defaultKeyManagerHelper())
re.NoError(err)
// Config with different encrption method.
// Config with different encryption method.
config := &Config{
DataEncryptionMethod: "aes256-ctr",
MasterKey: MasterKeyConfig{
Expand Down Expand Up @@ -579,7 +579,7 @@ func TestSetLeadershipWithCurrentKeyExposed(t *testing.T) {
}
err := saveKeys(leadership, masterKeyMeta, keys, defaultKeyManagerHelper())
re.NoError(err)
// Config with different encrption method.
// Config with different encryption method.
config := &Config{
DataEncryptionMethod: "aes128-ctr",
MasterKey: MasterKeyConfig{
Expand Down
2 changes: 1 addition & 1 deletion pkg/encryption/kms.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func newMasterKeyFromKMS(
}
if len(output.Plaintext) != masterKeyLength {
return nil, errs.ErrEncryptionKMS.GenWithStack(
"unexpected data key length generated from AWS KMS, expectd %d vs actual %d",
"unexpected data key length generated from AWS KMS, expected %d vs actual %d",

Check warning on line 93 in pkg/encryption/kms.go

View check run for this annotation

Codecov / codecov/patch

pkg/encryption/kms.go#L93

Added line #L93 was not covered by tests
masterKeyLength, len(output.Plaintext))
}
masterKey = &MasterKey{
Expand Down
2 changes: 1 addition & 1 deletion pkg/encryption/region_crypter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func processRegionKeys(region *metapb.Region, key *encryptionpb.DataKey, iv []by
}

// EncryptRegion encrypt the region start key and end key, using the current key return from the
// key manager. The return is an encypted copy of the region, with Encryption meta updated.
// key manager. The return is an encrypted copy of the region, with Encryption meta updated.
func EncryptRegion(region *metapb.Region, keyManager KeyManager) (*metapb.Region, error) {
if region == nil {
return nil, errs.ErrEncryptionEncryptRegion.GenWithStack("trying to encrypt nil region")
Expand Down
4 changes: 4 additions & 0 deletions pkg/mcs/metastorage/server/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Manager struct {
srv bs.Server
clusterID uint64
client *clientv3.Client
ownClient *clientv3.Client
storage *endpoint.StorageEndpoint
}

Expand Down Expand Up @@ -55,6 +56,9 @@ func NewManager[T ClusterIDProvider](srv bs.Server) *Manager {

// GetClient returns the client of etcd.
func (m *Manager) GetClient() *clientv3.Client {
if m.ownClient != nil {
return m.ownClient

Check warning on line 60 in pkg/mcs/metastorage/server/manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/mcs/metastorage/server/manager.go#L60

Added line #L60 was not covered by tests
}
return m.client
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/movingaverage/weight_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewWeightAllocator(length, segNum int) *WeightAllocator {
segLength := length / segNum
// segMod is used for split seg when is length not divisible by segNum.
segMod := length % segNum
segIndexs := make([]int, 0, segNum)
segIndexes := make([]int, 0, segNum)
weights := make([]float64, 0, length)
unitCount := 0
for i := 0; i < segNum; i++ {
Expand All @@ -46,11 +46,11 @@ func NewWeightAllocator(length, segNum int) *WeightAllocator {
next++
}
unitCount += (segNum - i) * next
segIndexs = append(segIndexs, next)
segIndexes = append(segIndexes, next)
}
unitWeight := 1.0 / float64(unitCount)
for i := 0; i < segNum; i++ {
for j := 0; j < segIndexs[i]; j++ {
for j := 0; j < segIndexes[i]; j++ {
weights = append(weights, unitWeight*float64(segNum-i))
}
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ const speedStatisticalWindow = 10 * time.Minute
// Manager is used to maintain the progresses we care about.
type Manager struct {
syncutil.RWMutex
progesses map[string]*progressIndicator
progresses map[string]*progressIndicator
}

// NewManager creates a new Manager.
func NewManager() *Manager {
return &Manager{
progesses: make(map[string]*progressIndicator),
progresses: make(map[string]*progressIndicator),
}
}

Expand All @@ -59,7 +59,7 @@ func (m *Manager) Reset() {
m.Lock()
defer m.Unlock()

m.progesses = make(map[string]*progressIndicator)
m.progresses = make(map[string]*progressIndicator)
}

// AddProgress adds a progress into manager if it doesn't exist.
Expand All @@ -69,8 +69,8 @@ func (m *Manager) AddProgress(progress string, current, total float64, updateInt

history := list.New()
history.PushBack(current)
if _, exist = m.progesses[progress]; !exist {
m.progesses[progress] = &progressIndicator{
if _, exist = m.progresses[progress]; !exist {
m.progresses[progress] = &progressIndicator{
total: total,
remaining: total,
history: history,
Expand All @@ -86,7 +86,7 @@ func (m *Manager) UpdateProgress(progress string, current, remaining float64, is
m.Lock()
defer m.Unlock()

if p, exist := m.progesses[progress]; exist {
if p, exist := m.progresses[progress]; exist {
p.remaining = remaining
if p.total < remaining {
p.total = remaining
Expand Down Expand Up @@ -120,7 +120,7 @@ func (m *Manager) UpdateProgressTotal(progress string, total float64) {
m.Lock()
defer m.Unlock()

if p, exist := m.progesses[progress]; exist {
if p, exist := m.progresses[progress]; exist {
p.total = total
}
}
Expand All @@ -130,8 +130,8 @@ func (m *Manager) RemoveProgress(progress string) (exist bool) {
m.Lock()
defer m.Unlock()

if _, exist = m.progesses[progress]; exist {
delete(m.progesses, progress)
if _, exist = m.progresses[progress]; exist {
delete(m.progresses, progress)
return
}
return
Expand All @@ -143,7 +143,7 @@ func (m *Manager) GetProgresses(filter func(p string) bool) []string {
defer m.RUnlock()

processes := []string{}
for p := range m.progesses {
for p := range m.progresses {
if filter(p) {
processes = append(processes, p)
}
Expand All @@ -156,7 +156,7 @@ func (m *Manager) Status(progress string) (process, leftSeconds, currentSpeed fl
m.RLock()
defer m.RUnlock()

if p, exist := m.progesses[progress]; exist {
if p, exist := m.progresses[progress]; exist {
process = 1 - p.remaining/p.total
if process < 0 {
process = 0
Expand Down
2 changes: 1 addition & 1 deletion pkg/progress/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestProgress(t *testing.T) {
for i := 0; i < 100; i++ {
m.UpdateProgress(n, 30, 30, false)
}
re.Equal(61, m.progesses[n].history.Len())
re.Equal(61, m.progresses[n].history.Len())
p, ls, cs, err = m.Status(n)
re.NoError(err)
re.Equal(0.7, p)
Expand Down
2 changes: 1 addition & 1 deletion pkg/replication/replication_mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func TestStateSwitch(t *testing.T) {
rep.tickUpdateState()
re.Equal(drStateSync, rep.drGetState())

// once zone2 down, swith to async state.
// once zone2 down, switch to async state.
setStoreState(cluster, "up", "up", "up", "up", "down", "down")
rep.tickUpdateState()
re.Equal(drStateAsyncWait, rep.drGetState())
Expand Down
8 changes: 4 additions & 4 deletions pkg/response/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ type MetaStore struct {
type SlowTrend struct {
// CauseValue is the slow trend detecting raw input, it changes by the performance and pressure along time of the store.
// The value itself is not important, what matter is:
// - The comparition result from store to store.
// - The comparison result from store to store.
// - The change magnitude along time (represented by CauseRate).
// Currently it's one of store's internal latency (duration of waiting in the task queue of raftstore.store).
// Currently, it's one of store's internal latency (duration of waiting in the task queue of raftstore.store).
CauseValue float64 `json:"cause_value"`
// CauseRate is for mesuring the change magnitude of CauseValue of the store,
// CauseRate is for measuring the change magnitude of CauseValue of the store,
// - CauseRate > 0 means the store is become slower currently
// - CauseRate < 0 means the store is become faster currently
// - CauseRate == 0 means the store's performance and pressure does not have significant changes
CauseRate float64 `json:"cause_rate"`
// ResultValue is the current gRPC QPS of the store.
ResultValue float64 `json:"result_value"`
// ResultRate is for mesuring the change magnitude of ResultValue of the store.
// ResultRate is for measuring the change magnitude of ResultValue of the store.
ResultRate float64 `json:"result_rate"`
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/schedule/checker/rule_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,20 +1018,20 @@ func (suite *ruleCheckerTestSuite) TestFixOrphanPeerWithDisconnectedStoreAndRule
op = suite.rc.Check(suite.cluster.GetRegion(1))
re.NotNil(op)
re.Contains(op.Desc(), "orphan")
var removedPeerStroeID uint64
var removedPeerStoreID uint64
newLeaderStoreID := r1.GetLeader().GetStoreId()
for i := 0; i < op.Len(); i++ {
if s, ok := op.Step(i).(operator.RemovePeer); ok {
removedPeerStroeID = s.FromStore
removedPeerStoreID = s.FromStore
}
if s, ok := op.Step(i).(operator.TransferLeader); ok {
newLeaderStoreID = s.ToStore
}
}
re.NotZero(removedPeerStroeID)
re.NotZero(removedPeerStoreID)
r1 = r1.Clone(
core.WithLeader(r1.GetStorePeer(newLeaderStoreID)),
core.WithRemoveStorePeer(removedPeerStroeID))
core.WithRemoveStorePeer(removedPeerStoreID))
suite.cluster.PutRegion(r1)
r1 = suite.cluster.GetRegion(1)
re.Len(r1.GetPeers(), 6-j)
Expand Down Expand Up @@ -1571,7 +1571,7 @@ func (suite *ruleCheckerTestSuite) TestFixOfflinePeer() {
re.Nil(suite.rc.Check(region))
}

func (suite *ruleCheckerTestSuite) TestFixOfflinePeerWithAvaliableWitness() {
func (suite *ruleCheckerTestSuite) TestFixOfflinePeerWithAvailableWitness() {
re := suite.Require()
suite.cluster.AddLabelsStore(1, 1, map[string]string{"zone": "z1"})
suite.cluster.AddLabelsStore(2, 1, map[string]string{"zone": "z1"})
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/filter/filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func TestStoreStateFilterReason(t *testing.T) {
}
}

// No reason catched
// No reason caught
store = store.Clone(core.SetLastHeartbeatTS(time.Now()))
testCases := []testCase{
{2, "store-state-ok-filter", "store-state-ok-filter"},
Expand Down

0 comments on commit 4c811eb

Please sign in to comment.