polarismesh/polaris-go

新版本熔断器在开->半开时会panic

WTIFS opened this issue · 0 comments

WTIFS commented

Describe the bug
熔断器在开闭状态时使用的类型是 BaseCircuitBreakerStatus,在半开状态使用的类型是 HalfOpenStatus,在写入 atomic.Value 时会因两种类型不一样导致 panic

image image

To Reproduce
plugin/circuitbreaker/composite/task_pool.goaddaddDelay 函数中增加如下代码:

		if r := recover(); r != nil {
			buf := make([]byte, 1<<18)
			n := runtime.Stack(buf, false)
			fmt.Printf("panic recovered: %v.\nruntime stack: %s", r, buf[0:n])
		}

然后触发熔断,等待一会儿,便能看到 panic 日志

Expected behavior
A clear and concise description of what you expected to happen.

Environment

  • Version: [e.g. v1.0.0]
  • OS: [e.g. CentOS8]

Additional context
Add any other context about the problem here.