本文整理汇总了Golang中github.com/youtube/vitess/go/tb.Stack函数的典型用法代码示例。如果您正苦于以下问题:Golang Stack函数的具体用法?Golang Stack怎么用?Golang Stack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Stack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleError
func handleError(err *error, logStats *SQLQueryStats, queryServiceStats *QueryServiceStats) {
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic:\n%v\n%s", x, tb.Stack(4))
*err = NewTabletError(ErrFail, "%v: uncaught panic", x)
queryServiceStats.InternalErrors.Add("Panic", 1)
return
}
*err = terr
terr.RecordStats(queryServiceStats)
if terr.ErrorType == ErrRetry { // Retry errors are too spammy
return
}
if terr.ErrorType == ErrTxPoolFull {
logTxPoolFull.Errorf("%v", terr)
} else {
log.Errorf("%v", terr)
}
}
if logStats != nil {
logStats.Error = *err
logStats.Send()
}
}
示例2: HandlePanic
// HandlePanic should be called using 'defer' in the RPC code that executes the command.
func HandlePanic(component string, err *error) {
if x := recover(); x != nil {
// gRPC 0.13 chokes when you return a streaming error that contains newlines.
*err = fmt.Errorf("uncaught %v panic: %v, %s", component, x,
strings.Replace(string(tb.Stack(4)), "\n", ";", -1))
}
}
示例3: run
func (rci *RowcacheInvalidator) run() {
for {
// We wrap this code in a func so we can catch all panics.
// If an error is returned, we log it, wait 1 second, and retry.
// This loop can only be stopped by calling Close.
err := func() (inner error) {
defer func() {
if x := recover(); x != nil {
inner = fmt.Errorf("%v: uncaught panic:\n%s", x, tb.Stack(4))
}
}()
rp, err := rci.mysqld.BinlogInfo(rci.GroupId.Get())
if err != nil {
return err
}
return rci.evs.Stream(rp.MasterLogFile, int64(rp.MasterLogPosition), func(reply *blproto.StreamEvent) error {
rci.processEvent(reply)
return nil
})
}()
if err == nil {
break
}
log.Errorf("binlog.ServeUpdateStream returned err '%v', retrying in 1 second.", err.Error())
internalErrors.Add("Invalidation", 1)
time.Sleep(1 * time.Second)
}
log.Infof("Rowcache invalidator stopped")
}
示例4: handlePanic
func handlePanic(err *error) {
if x := recover(); x != nil {
log.Errorf("Uncaught panic:\n%v\n%s", x, tb.Stack(4))
*err = fmt.Errorf("uncaught panic: %v", x)
internalErrors.Add("Panic", 1)
}
}
示例5: handleExecError
// handleExecError handles panics during query execution and sets
// the supplied error return value.
func handleExecError(query *proto.Query, err *error, logStats *SQLQueryStats) {
if logStats != nil {
logStats.Send()
}
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic for %v:\n%v\n%s", query, x, tb.Stack(4))
*err = NewTabletError(FAIL, "%v: uncaught panic for %v", x, query)
internalErrors.Add("Panic", 1)
return
}
*err = terr
terr.RecordStats()
// suppress these errors in logs
if terr.ErrorType == RETRY || terr.ErrorType == TX_POOL_FULL || terr.SqlError == mysql.DUP_ENTRY {
return
}
if terr.ErrorType == FATAL {
log.Errorf("%v: %v", terr, query)
} else {
log.Warningf("%v: %v", terr, query)
}
}
}
示例6: handleExecError
// handleExecError handles panics during query execution and sets
// the supplied error return value.
func (sq *SqlQuery) handleExecError(query *proto.Query, err *error, logStats *SQLQueryStats) {
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic for %v:\n%v\n%s", query, x, tb.Stack(4))
*err = NewTabletError(ErrFail, "%v: uncaught panic for %v", x, query)
sq.qe.queryServiceStats.InternalErrors.Add("Panic", 1)
return
}
if sq.config.TerseErrors && terr.SqlError != 0 {
*err = fmt.Errorf("%s(errno %d) during query: %s", terr.Prefix(), terr.SqlError, query.Sql)
} else {
*err = terr
}
terr.RecordStats(sq.qe.queryServiceStats)
// suppress these errors in logs
if terr.ErrorType == ErrRetry || terr.ErrorType == ErrTxPoolFull || terr.SqlError == mysql.ErrDupEntry {
return
}
if terr.ErrorType == ErrFatal {
log.Errorf("%v: %v", terr, query)
} else {
log.Warningf("%v: %v", terr, query)
}
}
if logStats != nil {
logStats.Error = *err
logStats.Send()
}
}
示例7: HandlePanic
// HandlePanic recovers from panics, and logs / increment counters
func (vtg *VTGate) HandlePanic(err *error) {
if x := recover(); x != nil {
log.Errorf("Uncaught panic:\n%v\n%s", x, tb.Stack(4))
*err = fmt.Errorf("uncaught panic: %v, vtgate: %v", x, servenv.ListeningURL.String())
internalErrors.Add("Panic", 1)
}
}
示例8: handleError
func handleError(err *error, logStats *SQLQueryStats, queryServiceStats *QueryServiceStats) {
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic:\n%v\n%s", x, tb.Stack(4))
*err = NewTabletError(ErrFail, vtrpc.ErrorCode_UNKNOWN_ERROR, "%v: uncaught panic", x)
queryServiceStats.InternalErrors.Add("Panic", 1)
return
}
*err = terr
terr.RecordStats(queryServiceStats)
switch terr.ErrorType {
case ErrRetry: // Retry errors are too spammy
return
case ErrTxPoolFull:
logTxPoolFull.Errorf("%v", terr)
default:
switch terr.SqlError {
// MySQL deadlock errors are (usually) due to client behavior, not server
// behavior, and therefore logged at the INFO level.
case mysql.ErrLockWaitTimeout, mysql.ErrLockDeadlock:
log.Infof("%v", terr)
default:
log.Errorf("%v", terr)
}
}
}
if logStats != nil {
logStats.Error = *err
logStats.Send()
}
}
示例9: run
func (rci *RowcacheInvalidator) run(ctx *sync2.ServiceContext) error {
for {
evs := binlog.NewEventStreamer(rci.dbname, rci.mysqld, rci.Position(), rci.processEvent)
// We wrap this code in a func so we can catch all panics.
// If an error is returned, we log it, wait 1 second, and retry.
// This loop can only be stopped by calling Close.
err := func() (inner error) {
defer func() {
if x := recover(); x != nil {
inner = fmt.Errorf("%v: uncaught panic:\n%s", x, tb.Stack(4))
}
}()
return evs.Stream(ctx)
}()
if err == nil || !ctx.IsRunning() {
break
}
if IsConnErr(err) {
rci.checker.CheckMySQL()
}
log.Errorf("binlog.ServeUpdateStream returned err '%v', retrying in 1 second.", err.Error())
rci.qe.queryServiceStats.InternalErrors.Add("Invalidation", 1)
time.Sleep(1 * time.Second)
}
log.Infof("Rowcache invalidator stopped")
return nil
}
示例10: logError
func logError() {
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic:\n%v\n%s", x, tb.Stack(4))
internalErrors.Add("Panic", 1)
return
}
log.Errorf("%v", terr)
}
}
示例11: handleInvalidationError
func handleInvalidationError(event *blproto.StreamEvent) {
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic for %+v:\n%v\n%s", event, x, tb.Stack(4))
internalErrors.Add("Panic", 1)
return
}
log.Errorf("%v: %+v", terr, event)
internalErrors.Add("Invalidation", 1)
}
}
示例12: handleInvalidationError
func handleInvalidationError(request interface{}) {
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic for %v:\n%v\n%s", request, x, tb.Stack(4))
internalErrors.Add("Panic", 1)
return
}
log.Errorf("%s: %v", terr.Message, request)
internalErrors.Add("Invalidation", 1)
}
}
示例13: handleInvalidationError
func (rci *RowcacheInvalidator) handleInvalidationError(event *binlogdatapb.StreamEvent) {
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic for %+v:\n%v\n%s", event, x, tb.Stack(4))
rci.qe.queryServiceStats.InternalErrors.Add("Panic", 1)
return
}
log.Errorf("%v: %+v", terr, event)
rci.qe.queryServiceStats.InternalErrors.Add("Invalidation", 1)
}
}
示例14: handleExecErrorNoPanic
func (tsv *TabletServer) handleExecErrorNoPanic(query *proto.Query, err interface{}, logStats *LogStats) error {
var terr *TabletError
defer func() {
if logStats != nil {
logStats.Error = terr
}
}()
terr, ok := err.(*TabletError)
if !ok {
log.Errorf("Uncaught panic for %v:\n%v\n%s", query, err, tb.Stack(4))
tsv.qe.queryServiceStats.InternalErrors.Add("Panic", 1)
terr = NewTabletError(ErrFail, vtrpc.ErrorCode_UNKNOWN_ERROR, "%v: uncaught panic for %v", err, query)
return terr
}
var myError error
if tsv.config.TerseErrors && terr.SQLError != 0 && len(query.BindVariables) != 0 {
myError = &TabletError{
ErrorType: terr.ErrorType,
SQLError: terr.SQLError,
ErrorCode: terr.ErrorCode,
Message: fmt.Sprintf("(errno %d) during query: %s", terr.SQLError, query.Sql),
}
} else {
myError = terr
}
terr.RecordStats(tsv.qe.queryServiceStats)
logMethod := log.Warningf
// Suppress or demote some errors in logs
switch terr.ErrorType {
case ErrRetry, ErrTxPoolFull:
return myError
case ErrFatal:
logMethod = log.Errorf
}
// We want to suppress/demote some MySQL error codes (regardless of the ErrorType)
switch terr.SQLError {
case mysql.ErrDupEntry:
return myError
case mysql.ErrLockWaitTimeout, mysql.ErrLockDeadlock, mysql.ErrDataTooLong,
mysql.ErrDataOutOfRange, mysql.ErrBadNullError:
logMethod = log.Infof
case 0:
if strings.Contains(terr.Error(), "Row count exceeded") {
logMethod = log.Infof
}
}
logMethod("%v: %v", terr, query)
return myError
}
示例15: logError
func logError(queryServiceStats *QueryServiceStats) {
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic:\n%v\n%s", x, tb.Stack(4))
queryServiceStats.InternalErrors.Add("Panic", 1)
return
}
if terr.ErrorCode == vtrpcpb.ErrorCode_RESOURCE_EXHAUSTED {
logTxPoolFull.Errorf("%v", terr)
} else {
log.Errorf("%v", terr)
}
}
}