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

运行polaris-go里的example的circuitbreaker时崩溃报空指针错误 #102

Closed
gtyi999 opened this issue Oct 22, 2022 · 4 comments · Fixed by #104
Closed

运行polaris-go里的example的circuitbreaker时崩溃报空指针错误 #102

gtyi999 opened this issue Oct 22, 2022 · 4 comments · Fixed by #104
Assignees
Labels
bug Something isn't working

Comments

@gtyi999
Copy link

gtyi999 commented Oct 22, 2022

Describe the bug
运行polaris-go里的example的circuitbreaker时崩溃报空指针错误

To Reproduce
分别运行circuitbreaker的provider 和 consumer ,运行两个provider实例,按照readme步骤测试熔断功能,先停止一个provider实例,curl 向 consumer再发起请求,consumer就崩溃了。

Expected behavior
希望能正常测试熔断功能

Environment

  • Version: [master]
  • OS: [centos 7.9]

Additional context
分别运行circuitbreaker的provider 和 consumer ,运行两个provider实例,按照readme步骤测试熔断功能,先停止一个provider实例,curl 向 consumer再发起请求,consumer就崩溃了。

@gtyi999 gtyi999 added the bug Something isn't working label Oct 22, 2022
@gtyi999
Copy link
Author

gtyi999 commented Oct 22, 2022

2022/10/21 17:58:27 [errot] send request to 127.0.0.1:28082 fail : Get "http://127.0.0.1:28082/echo": dial tcp 127.0.0.1:28082: connect: connection refused
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0xa53617]

goroutine 84 [running]:
github.com/polarismesh/polaris-go/plugin/statreporter/prometheus.(*PrometheusHandler).handleCircuitBreakGauge(0xc0000a2410, 0x4044e6?, 0xc000394330)
/root/workspace/go/src/polaris-go/plugin/statreporter/prometheus/prometheus_handler.go:228 +0x77
github.com/polarismesh/polaris-go/plugin/statreporter/prometheus.(*PrometheusHandler).ReportStat(0xa0?, 0xc?, {0xd00750?, 0xc000394330?})
/root/workspace/go/src/polaris-go/plugin/statreporter/prometheus/prometheus_handler.go:139 +0x5a
github.com/polarismesh/polaris-go/plugin/statreporter/prometheus.(*PrometheusReporter).ReportStat(0x750000c0000218b8?, 0x0?, {0xd00750?, 0xc000394330?})
/root/workspace/go/src/polaris-go/plugin/statreporter/prometheus/prometheus_reporter.go:84 +0x27
github.com/polarismesh/polaris-go/pkg/flow.(*Engine).SyncReportStat(0xc0000d2ea0, 0x4, {0xd00750, 0xc000394330})
/root/workspace/go/src/polaris-go/pkg/flow/impl.go:344 +0x171
github.com/polarismesh/polaris-go/plugin/localregistry/inmemory.(*LocalCache).UpdateInstances(0xc00040a000, 0xc000286040)
/root/workspace/go/src/polaris-go/plugin/localregistry/inmemory/inmemory.go:577 +0x7a2
github.com/polarismesh/polaris-go/pkg/plugin/localregistry.(*Proxy).UpdateInstances(0xc0003b6448?, 0xc000021c60?)
/root/workspace/go/src/polaris-go/pkg/plugin/localregistry/proxy.go:48 +0x24
github.com/polarismesh/polaris-go/pkg/flow/cbcheck.(*CircuitBreakCallBack).doCircuitBreakForService(0xc000438600, {{0xc0003b6448?, 0x40e6be?}, {0xc000036450?, 0xffffffffffffff04?}}, {0x0, 0x0}, {0xd02e88?, 0xc0001c4a80}, {0xbec320, ...})
/root/workspace/go/src/polaris-go/pkg/flow/cbcheck/ticker.go:135 +0x790
github.com/polarismesh/polaris-go/pkg/flow/cbcheck.(*CircuitBreakRealTimeCallBack).Process(0xc0005480a0)
/root/workspace/go/src/polaris-go/pkg/flow/cbcheck/realtime.go:68 +0x136
github.com/polarismesh/polaris-go/pkg/flow/schedule.(*taskRoutine).runTakePriority(0xc0000a28c0)
/root/workspace/go/src/polaris-go/pkg/flow/schedule/routines.go:139 +0x202
created by github.com/polarismesh/polaris-go/pkg/flow/schedule.(*taskRoutine).start
/root/workspace/go/src/polaris-go/pkg/flow/schedule/routines.go:106 +0x178

@chuntaojun
Copy link
Member

我修复下

@andrewshan
Copy link
Member

handleCircuitBreakGauge

是什么原因导致panic?

@chuntaojun
Copy link
Member

err := g.engine.SyncReportStat(model.CircuitBreakStat,
&model.CircuitBreakGauge{ChangeInstance: updateInstance, CBStatus: nextCBStatus})

这里原先的逻辑,塞入的是 preCBStatus,会导致 nil panic

chuntaojun added a commit to chuntaojun/polaris-go that referenced this issue Oct 25, 2022
chuntaojun added a commit that referenced this issue Oct 25, 2022
* feat: 添加就近路由支持文档

* rebase upstream/master

* fix issue #102

* fix: change countervec to gaugevec

* fix:fix review issue

* 更新

* fix:修复route/nearby/consumer编译失败问题

* fix:调整限流规则demo的规则图片
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants