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

Hide router notice msgs under extended debug setting #212

Merged
merged 4 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 6 additions & 4 deletions cmd/router/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
saveProfie bool
profileFile string
daemonize bool
logLevel string
logLevel string
)

var rootCmd = &cobra.Command{
Expand Down Expand Up @@ -101,15 +101,17 @@ var runCmd = &cobra.Command{
var pprofFile *os.File

if saveProfie {
spqrlog.Zero.Fatal().Msg("starting cpu profile")

spqrlog.Zero.Log().Msg("starting cpu profile")
pprofFile, err = os.Create(profileFile)
if err != nil {
spqrlog.Zero.Fatal().
Err(err).
Msg("got an error while starting cpu profile")
return err
}
spqrlog.Zero.Fatal().Str("file", profileFile).Msg("starting cpu profile")

spqrlog.Zero.Log().Str("file", profileFile).Msg("starting cpu profile")
if err := pprof.StartCPUProfile(pprofFile); err != nil {
spqrlog.Zero.Fatal().
Err(err).
Expand All @@ -119,7 +121,7 @@ var runCmd = &cobra.Command{
}

sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1, syscall.SIGUSR2)
signal.Notify(sigs, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1, syscall.SIGUSR2)

router, err := router.NewRouter(ctx, &rcfg)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Router struct {

MaintainParams bool `json:"maintain_params" toml:"maintain_params" yaml:"maintain_params"`
WithJaeger bool `json:"with_jaeger" toml:"with_jaeger" yaml:"with_jaeger"`
ExtendedDebug bool `json:"extended_debug" toml:"extended_debug" yaml:"extended_debug"`
reshke marked this conversation as resolved.
Show resolved Hide resolved

PidFileName string `json:"pid_filename" toml:"pid_filename" yaml:"pid_filename"`
LogFileName string `json:"log_filename" toml:"log_filename" yaml:"log_filename"`
Expand Down
1 change: 0 additions & 1 deletion router/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,6 @@ func (cl *PsqlClient) ProcQuery(query pgproto3.FrontendMessage, waitForResp bool
Str("server", cl.server.Name()).
Type("query-type", query).
Msg("client process query")
_ = cl.ReplyDebugNoticef("executing your query %v", query)
cl.mu.RLock()
defer cl.mu.RUnlock()
if cl.server == nil {
Expand Down
10 changes: 7 additions & 3 deletions router/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ func ProcessMessage(qr qrouter.QueryRouter, cmngr rulerouter.PoolMgr, rst rulero
Str("name", q.Name).
Str("query", q.Query).
Uint64("hash", hash)
if err := rst.Client().ReplyDebugNoticef("name %v, query %v, hash %d", q.Name, q.Query, hash); err != nil {
return err
if rst.ExtendedDebug() {
if err := rst.Client().ReplyDebugNoticef("name %v, query %v, hash %d", q.Name, q.Query, hash); err != nil {
return err
}
}
rst.Client().StorePreparedStatement(q.Name, q.Query)
// simply reply witch ok parse complete
Expand Down Expand Up @@ -332,7 +334,9 @@ func Frontend(qr qrouter.QueryRouter, cl client.RouterClient, cmngr rulerouter.P
Uint("client", spqrlog.GetPointer(cl)).
Msg("process frontend for route")

_ = cl.ReplyDebugNoticef("process frontend for route %s %s", cl.Usr(), cl.DB())
if rcfg.ExtendedDebug {
_ = cl.ReplyDebugNoticef("process frontend for route %s %s", cl.Usr(), cl.DB())
}
rst := rulerouter.NewRelayState(qr, cl, cmngr, rcfg)

defer rst.Close()
Expand Down
19 changes: 14 additions & 5 deletions router/rulerouter/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type RelayStateMgr interface {
ActiveShardsReset()
TxActive() bool

ExtendedDebug() bool

RelayStep(msg pgproto3.FrontendMessage, waitForResp bool, replyCl bool) (txstatus.TXStatus, error)

UnRouteWithError(shkey []kr.ShardKey, errmsg error) error
Expand Down Expand Up @@ -63,6 +65,8 @@ type RelayStateImpl struct {
WorldShardFallback bool
routerMode config.RouterMode

extendedDebug bool
reshke marked this conversation as resolved.
Show resolved Hide resolved

routingState qrouter.RoutingState

Qr qrouter.QueryRouter
Expand All @@ -82,6 +86,10 @@ func (rst *RelayStateImpl) SetTxStatus(status txstatus.TXStatus) {
rst.txStatus = status
}

func (rst *RelayStateImpl) ExtendedDebug() bool {
return rst.extendedDebug
}

func (rst *RelayStateImpl) Client() client.RouterClient {
return rst.Cl
}
Expand Down Expand Up @@ -128,6 +136,7 @@ func NewRelayState(qr qrouter.QueryRouter, client client.RouterClient, manager P
WorldShardFallback: rcfg.WorldShardFallback,
routerMode: config.RouterMode(rcfg.RouterMode),
maintain_params: rcfg.MaintainParams,
extendedDebug: rcfg.ExtendedDebug,
}
}

Expand Down Expand Up @@ -186,9 +195,11 @@ func (rst *RelayStateImpl) procRoutes(routes []*qrouter.DataShardRoute) error {
for _, shr := range routes {
rst.activeShards = append(rst.activeShards, shr.Shkey)
}
// TDB: hide under setting
if err := rst.Cl.ReplyDebugNoticef("matched datashard routes %+v", routes); err != nil {
return err
if rst.ExtendedDebug() {
// TDB: hide under setting
reshke marked this conversation as resolved.
Show resolved Hide resolved
if err := rst.Cl.ReplyDebugNoticef("matched datashard routes %+v", routes); err != nil {
return err
}
}

if err := rst.Connect(routes); err != nil {
Expand Down Expand Up @@ -296,7 +307,6 @@ func (rst *RelayStateImpl) Connect(shardRoutes []*qrouter.DataShardRoute) error
return err
}


spqrlog.Zero.Debug().
Str("user", rst.Cl.Usr()).
Str("db", rst.Cl.DB()).
Expand Down Expand Up @@ -440,7 +450,6 @@ func (rst *RelayStateImpl) CompleteRelay(replyCl bool) error {
return nil
}


spqrlog.Zero.Debug().
Uint("client", spqrlog.GetPointer(rst.Client())).
Str("txstatus", rst.txStatus.String()).
Expand Down
Loading