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

fix typos, minor log fixes #181

Merged
merged 1 commit into from
Jun 27, 2023
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 balancer/pkg/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (m *mock) mergeKeyRanges(border *string) error {
return fmt.Errorf("something goes wrong...")
}
if m.keyRangeToShard[leftRng] != m.keyRangeToShard[rightRng] {
// it's ok, because we try actionStageMerge by every transfered border
// it's ok, because we try actionStageMerge by every transferred border
return nil
}
newRng := KeyRange{left: leftRng.left, right: rightRng.right}
Expand Down
2 changes: 1 addition & 1 deletion coordinator/provider/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (qc *qdbCoordinator) DropShardingRuleAll(ctx context.Context) ([]*shrule.Sh
dropResp, err := cl.DropShardingRules(ctx, &routerproto.DropShardingRuleRequest{
Id: ids,
})
spqrlog.Logger.Printf(spqrlog.DEBUG4, "drop sharding rules responce %v", dropResp)
spqrlog.Logger.Printf(spqrlog.DEBUG4, "drop sharding rules response %v", dropResp)

return err
}); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion qdb/etcdqdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (q *EtcdQDB) fetchKeyRange(ctx context.Context, nodePath string) (*KeyRange
func (q *EtcdQDB) GetKeyRange(ctx context.Context, id string) (*KeyRange, error) {
spqrlog.Logger.Printf(spqrlog.DEBUG2, "etcdqdb: get key range %+v", id)
ret, err := q.fetchKeyRange(ctx, keyRangeNodePath(id))
spqrlog.Logger.Printf(spqrlog.DEBUG1, "get key range responce %v %v", ret, err)
spqrlog.Logger.Printf(spqrlog.DEBUG1, "get key range response %v %v", ret, err)
return ret, err
}

Expand Down
5 changes: 5 additions & 0 deletions router/datashard/datashard.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ func (sh *Conn) Receive() (pgproto3.BackendMessage, error) {
return sh.dedicated.Receive()
}


func (sh *Conn) String() string {
return sh.name
}

func (sh *Conn) Name() string {
return sh.name
}
Expand Down
2 changes: 1 addition & 1 deletion router/qrouter/proxy_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (qr *ProxyQrouter) deparseShardingMapping(

var ParseError = fmt.Errorf("parsing stmt error")

// CheckTableIsRoutable Given table create statment, check if it is routable with some sharding rule
// CheckTableIsRoutable Given table create statement, check if it is routable with some sharding rule
func (qr *ProxyQrouter) CheckTableIsRoutable(ctx context.Context, node *pgquery.Node_CreateStmt) error {

var entries []string
Expand Down
22 changes: 6 additions & 16 deletions router/rule/rulemgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
)

type MatchMgr[T any] interface {
MatchKey(key route.Key) (*T, error)
UnderlyingEntityName() string
MatchKey(key route.Key, underlyingEntityName string) (*T, error)
}

type RulesMgr interface {
Expand Down Expand Up @@ -69,26 +68,19 @@ func (F *RulesMgrImpl) Reload(frmp map[route.Key]*config.FrontendRule, bemp map[
}

func (F *RulesMgrImpl) MatchKeyFrontend(key route.Key) (*config.FrontendRule, error) {
return F.fe.MatchKey(key)
return F.fe.MatchKey(key, "frontend rules")
}

func (F *RulesMgrImpl) MatchKeyBackend(key route.Key) (*config.BackendRule, error) {
return F.be.MatchKey(key)
return F.be.MatchKey(key, "backend rules")
}

type MgrImpl[T any] struct {
rule map[route.Key]*T

defaultRuleAllocator func(key route.Key) *T

underlyingEntityName string
}

func (r *MgrImpl[T]) UnderlyingEntityName() string {
return r.underlyingEntityName
}

func (m *MgrImpl[T]) MatchKey(key route.Key) (*T, error) {
func (m *MgrImpl[T]) MatchKey(key route.Key, underlyingEntityName string) (*T, error) {
matchRule, ok := m.rule[key]
if ok {
return matchRule, nil
Expand All @@ -102,8 +94,8 @@ func (m *MgrImpl[T]) MatchKey(key route.Key) (*T, error) {
return matchRule, nil
}

return nil, fmt.Errorf("failed to route frontend for client:"+
" route for user:%s and db:%s is unconfigured in %s", key.Usr(), key.DB(), m.UnderlyingEntityName())
return nil, fmt.Errorf("failed to route frontend for client:" +
" route for user:%s and db:%s is unconfigured in %s", key.Usr(), key.DB(), underlyingEntityName)
}

func NewMgr(frmp map[route.Key]*config.FrontendRule,
Expand All @@ -124,7 +116,6 @@ func NewMgr(frmp map[route.Key]*config.FrontendRule,
PoolPreparedStatement: dfr.PoolPreparedStatement,
}
},
underlyingEntityName: "frontend rules",
}

be := &MgrImpl[config.BackendRule]{
Expand All @@ -140,7 +131,6 @@ func NewMgr(frmp map[route.Key]*config.FrontendRule,
ConnectionLimit: dbe.ConnectionLimit,
}
},
underlyingEntityName: "backend rules",
}

ret := &RulesMgrImpl{
Expand Down
8 changes: 3 additions & 5 deletions router/rulerouter/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ type RelayStateImpl struct {
}

func (rst *RelayStateImpl) SetTxStatus(status txstatus.TXStatus) {
//TODO implement me
rst.txStatus = status
}

func (rst *RelayStateImpl) Client() client.RouterClient {
//TODO implement me
return rst.Cl
}

Expand Down Expand Up @@ -219,7 +217,7 @@ func (rst *RelayStateImpl) Reroute() error {
switch v := routingState.(type) {
case qrouter.MultiMatchState:
if rst.TxActive() {
return fmt.Errorf("ddl is forbidden inside multi-shard transation")
return fmt.Errorf("ddl is forbidden inside multi-shard transition")
}
return rst.procRoutes(rst.Qr.DataShardsRoutes())
case qrouter.ShardMatchState:
Expand Down Expand Up @@ -423,7 +421,7 @@ func (rst *RelayStateImpl) CompleteRelay(replyCl bool) error {
return nil
}

spqrlog.Logger.Printf(spqrlog.DEBUG1, "cleint %p: complete relay iter with TX %s", rst.Client(), func(b txstatus.TXStatus) string {
spqrlog.Logger.Printf(spqrlog.DEBUG1, "client %p: complete relay iter with TX %s", rst.Client(), func(b txstatus.TXStatus) string {
switch b {
case txstatus.TXIDLE:
return "idle"
Expand Down Expand Up @@ -573,7 +571,7 @@ func (rst *RelayStateImpl) Sync(waitForResp, replyCl bool, cmngr PoolMgr) error
}

func (rst *RelayStateImpl) ProcessMessage(msg pgproto3.FrontendMessage, waitForResp, replyCl bool, cmngr PoolMgr) error {
spqrlog.Logger.Printf(spqrlog.DEBUG3, "relay step: proccess message for client %p", &rst.Cl)
spqrlog.Logger.Printf(spqrlog.DEBUG3, "relay step: process message for client %p", &rst.Cl)
if err := rst.PrepareRelayStep(cmngr); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions router/rulerouter/rulerouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (r *RuleRouterImpl) PreRoute(conn net.Conn) (rclient.RouterClient, error) {
},
} {
if err := cl.Send(msg); err != nil {
return nil, errors.Wrap(err, "failed to make route failure responce")
return nil, errors.Wrap(err, "failed to make route failure response")
}
}
return nil, err
Expand All @@ -177,7 +177,7 @@ func (r *RuleRouterImpl) PreRoute(conn net.Conn) (rclient.RouterClient, error) {
},
} {
if err := cl.Send(msg); err != nil {
return nil, errors.Wrap(err, "failed to make route failure responce")
return nil, errors.Wrap(err, "failed to make route failure response")
}
}
return nil, err
Expand Down
Loading