zoukankan      html  css  js  c++  java
  • go thrift报错问题--WriteStructEnd

    问题

    go thrift开发过程中,多个goroutine共用一个client时,报错:

    panic: runtime error: index out of range

    goroutine 24 [running]:
    happy-apple/vendor/git.apache.org/thrift.git/lib/go/thrift.(TCompactProtocol).WriteStructEnd(0xc4201086e0, 0x0, 0x0)
    /home/admin/workspace/src/happy-apple/vendor/git.apache.org/thrift.git/lib/go/thrift/compact_protocol.go:160 +0x66
    happy-apple/protocol/falconeye.(
    TAppleMetric).Write(0xc420112090, 0x787020, 0xc4201086e0, 0x0, 0x0)
    /home/admin/workspace/src/happy-apple/protocol/falconeye/common.go:1714 +0xb9
    happy-apple/protocol/falconeye.(ReportPutMetricDataArgs).writeField1(0xc4200f85a0, 0x787020, 0xc4201086e0, 0x0, 0x0)
    /home/admin/workspace/src/happy-apple/protocol/falconeye/report.go:308 +0x123
    happy-apple/protocol/falconeye.(
    ReportPutMetricDataArgs).Write(0xc4200f85a0, 0x787020, 0xc4201086e0, 0x200000001, 0x0)
    /home/admin/workspace/src/happy-apple/protocol/falconeye/report.go:292 +0x195
    happy-apple/protocol/falconeye.(ReportClient).sendPutMetricData(0xc420094320, 0xc4200aa040, 0x1, 0x1, 0x1, 0xc420112090)
    /home/admin/workspace/src/happy-apple/protocol/falconeye/report.go:70 +0xe9
    happy-apple/protocol/falconeye.(
    ReportClient).PutMetricData(0xc420094320, 0xc4200aa040, 0x1, 0x1, 0x1, 0xc4200aa040, 0x0)
    /home/admin/workspace/src/happy-apple/protocol/falconeye/report.go:53 +0x4d
    main.TestSendData(0xc420094320, 0x0, 0x0)
    /home/admin/workspace/src/happy-apple/protocol/falconeye/report-remote/qps_client.go:116 +0x2c9
    main.sendTask(0xc420094320)
    /home/admin/workspace/src/happy-apple/protocol/falconeye/report-remote/qps_client.go:71 +0x2b
    created by main.main
    /home/admin/workspace/src/happy-apple/protocol/falconeye/report-remote/qps_client.go:47 +0x17b

    使用的lib是git.apache.org/thrift.git/lib/go

    原因及解决办法:

    一个thrift client 不支持多个协程routine同时使用.
    可创建多个client,每个协程routine一个client

  • 相关阅读:
    css3圆角细节
    css3伪元素
    使用vscode在谷歌上运行代码
    SpringCloud-技术专区-Gateway优雅的处理Filter抛出的异常
    SpringCloud-技术专区-Gateway全局通用异常处理
    Mybatis-技术专区-插件开发指南
    消息中间件-技术专区-RabbitMQ基本介绍
    SpringBoot-技术专区-自定义TaskExecutor线程池
    MySQL-技术专区-Binlog和Redolog的介绍
    SpringBoot-技术专区-Redis同数据源动态切换db
  • 原文地址:https://www.cnblogs.com/lanyangsh/p/9192341.html
Copyright © 2011-2022 走看看