本文整理汇总了Golang中github.com/youtube/vitess/go/tb.Stack函数的典型用法代码示例。如果您正苦于以下问题:Golang Stack函数的具体用法?Golang Stack怎么用?Golang Stack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Stack函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
}
}
开发者ID:kissthink,项目名称:vitess,代码行数:25,代码来源:tablet_error.go
示例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))
}
}
开发者ID:aaijazi,项目名称:vitess,代码行数:8,代码来源:rpc_utils.go
示例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")
}
开发者ID:qman1989,项目名称:vitess,代码行数:29,代码来源:rowcache_invalidator.go
示例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)
}
}
开发者ID:chinna1986,项目名称:vitess,代码行数:7,代码来源:vtgate.go
示例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)
}
}
}
开发者ID:jackwanger,项目名称:cloud-base,代码行数:27,代码来源:sqlquery.go
示例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()
}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:32,代码来源:sqlquery.go
示例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)
}
}
开发者ID:yangzhongj,项目名称:vitess,代码行数:8,代码来源:vtgate.go
示例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()
}
}
开发者ID:fengshao0907,项目名称:vitess,代码行数:32,代码来源:tablet_error.go
示例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
}
开发者ID:tjyang,项目名称:vitess,代码行数:27,代码来源:rowcache_invalidator.go
示例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)
}
}
开发者ID:chinna1986,项目名称:vitess,代码行数:11,代码来源:tablet_error.go
示例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)
}
}
开发者ID:qman1989,项目名称:vitess,代码行数:12,代码来源:rowcache_invalidator.go
示例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)
}
}
开发者ID:nimishzynga,项目名称:vitess,代码行数:12,代码来源:sqlquery.go
示例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)
}
}
开发者ID:tjyang,项目名称:vitess,代码行数:12,代码来源:rowcache_invalidator.go
示例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
}
开发者ID:c3p0hz,项目名称:vitess,代码行数:50,代码来源:tabletserver.go
示例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)
}
}
}
开发者ID:CowLeo,项目名称:vitess,代码行数:15,代码来源:tablet_error.go
示例16: handleExecError
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)
errorStats.Add("Panic", 1)
return
}
*err = terr
terr.RecordStats()
if terr.ErrorType == RETRY || terr.SqlError == DUPLICATE_KEY { // suppress these errors in logs
return
}
log.Errorf("%s: %v", terr.Message, query)
}
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:20,代码来源:sqlquery.go
示例17: handleError
func handleError(err *error, logStats *sqlQueryStats) {
if logStats != nil {
logStats.Send()
}
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(FAIL, "%v: uncaught panic", x)
internalErrors.Add("Panic", 1)
return
}
*err = terr
terr.RecordStats()
if terr.ErrorType == RETRY { // Retry errors are too spammy
return
}
log.Errorf("%s", terr.Message)
}
}
开发者ID:rjammala,项目名称:vitess,代码行数:20,代码来源:tablet_error.go
示例18: handleError
func handleError(err *error, logStats *LogStats, queryServiceStats *QueryServiceStats) {
var terr *TabletError
defer func() {
if logStats != nil {
logStats.Error = terr
logStats.Send()
}
}()
if x := recover(); x != nil {
terr, ok := x.(*TabletError)
if !ok {
log.Errorf("Uncaught panic:\n%v\n%s", x, tb.Stack(4))
terr = NewTabletError(vtrpcpb.ErrorCode_UNKNOWN_ERROR, "%v: uncaught panic", x)
*err = terr
queryServiceStats.InternalErrors.Add("Panic", 1)
return
}
*err = terr
terr.RecordStats(queryServiceStats)
switch terr.ErrorCode {
case vtrpcpb.ErrorCode_QUERY_NOT_SERVED:
// Retry errors are too spammy
return
case vtrpcpb.ErrorCode_RESOURCE_EXHAUSTED:
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, mysql.ErrDataTooLong,
mysql.ErrDataOutOfRange, mysql.ErrBadNullError:
log.Infof("%v", terr)
default:
log.Errorf("%v", terr)
}
}
}
}
开发者ID:CowLeo,项目名称:vitess,代码行数:38,代码来源:tablet_error.go
示例19: handleExecErrorNoPanic
func (sq *SqlQuery) handleExecErrorNoPanic(query *proto.Query, err interface{}, logStats *SQLQueryStats) error {
terr, ok := err.(*TabletError)
if !ok {
log.Errorf("Uncaught panic for %v:\n%v\n%s", query, err, tb.Stack(4))
sq.qe.queryServiceStats.InternalErrors.Add("Panic", 1)
return NewTabletError(ErrFail, "%v: uncaught panic for %v", err, query)
}
var myError error
if sq.config.TerseErrors && terr.SqlError != 0 && len(query.BindVariables) != 0 {
myError = fmt.Errorf("%s(errno %d) during query: %s", terr.Prefix(), terr.SqlError, query.Sql)
} else {
myError = terr
}
terr.RecordStats(sq.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:
logMethod = log.Infof
case 0:
if strings.Contains(terr.Error(), "Row count exceeded") {
logMethod = log.Infof
}
}
logMethod("%v: %v", terr, query)
return myError
}
开发者ID:payintel,项目名称:vitess,代码行数:37,代码来源:sqlquery.go
示例20: handleExecErrorNoPanic
func (sq *SqlQuery) handleExecErrorNoPanic(query *proto.Query, err interface{}, logStats *SQLQueryStats) error {
terr, ok := err.(*TabletError)
if !ok {
log.Errorf("Uncaught panic for %v:\n%v\n%s", query, err, tb.Stack(4))
sq.qe.queryServiceStats.InternalErrors.Add("Panic", 1)
return NewTabletError(ErrFail, "%v: uncaught panic for %v", err, query)
}
var myError error
if sq.config.TerseErrors && terr.SqlError != 0 {
myError = fmt.Errorf("%s(errno %d) during query: %s", terr.Prefix(), terr.SqlError, query.Sql)
} else {
myError = terr
}
terr.RecordStats(sq.qe.queryServiceStats)
// suppress these errors in logs
if terr.ErrorType == ErrRetry || terr.ErrorType == ErrTxPoolFull || terr.SqlError == mysql.ErrDupEntry {
return myError
}
if terr.ErrorType == ErrFatal {
log.Errorf("%v: %v", terr, query)
}
log.Warningf("%v: %v", terr, query)
return myError
}
开发者ID:haoqoo,项目名称:vitess,代码行数:24,代码来源:sqlquery.go
注:本文中的github.com/youtube/vitess/go/tb.Stack函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论