go-admin-team / go-admin

基于Gin + Vue + Element UI & Arco Design & Ant Design 的前后端分离权限管理系统脚手架(包含了:多租户的支持,基础用户管理功能,jwt鉴权,代码生成器,RBAC资源控制,表单构建,定时任务等)3分钟构建自己的中后台项目;项目文档》:https://www.go-admin.pro V2 Demo: https://vue2.go-admin.dev V3 Demo: https://vue3.go-admin.dev Antd 订阅版:https://antd.go-admin.pro
https://www.go-admin.pro
MIT License
11.15k stars 2.32k forks source link

Sentinel 限流 限流BUG #788

Open xiaopihai1 opened 3 months ago

xiaopihai1 commented 3 months ago

go version go1.22.1 windows/amd64

处理器 12th Gen Intel(R) Core(TM) i7-12700H 2.30 GHz 系统类型 64 位操作系统, 基于 x64 的处理器

go run main.go version 2.1.2

// Sentinel 限流 func Sentinel() gin.HandlerFunc { if _, err := system.LoadRules([]system.Rule{ { MetricType: system.InboundQPS, TriggerCount: 200, Strategy: system.BBR, }, }); err != nil { log.Fatalf("Unexpected error: %+v", err) } return sentinel.SentinelMiddleware( sentinel.WithBlockFallback(func(ctx gin.Context) { ctx.AbortWithStatusJSON(200, map[string]interface{}{ "msg": "too many request; the quota used up!", "code": 500, }) }), ) }

是阿里那个包的问题么

github.com/alibaba/sentinel-golang/core/stat/base.(AtomicBucketWrapArray).elementOffset C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/base/leap_array.go:108 github.com/alibaba/sentinel-golang/core/stat/base.(AtomicBucketWrapArray).compareAndSet C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/base/leap_array.go:130 github.com/alibaba/sentinel-golang/core/stat/base.(LeapArray).currentBucketOfTime C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/base/leap_array.go:194 github.com/alibaba/sentinel-golang/core/stat/base.(BucketLeapArray).currentBucketWithTime C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/base/bucket_leap_array.go:112 github.com/alibaba/sentinel-golang/core/stat/base.(BucketLeapArray).updateConcurrencyWithTime C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/base/bucket_leap_array.go:104 github.com/alibaba/sentinel-golang/core/stat/base.(BucketLeapArray).UpdateConcurrency C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/base/bucket_leap_array.go:100 github.com/alibaba/sentinel-golang/core/stat.(BaseStatNode).UpdateConcurrency C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/base_node.go:72 github.com/alibaba/sentinel-golang/core/stat.(BaseStatNode).IncreaseConcurrency C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/base_node.go:96 github.com/alibaba/sentinel-golang/core/stat.(Slot).recordPassFor C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/stat_slot.go:80 github.com/alibaba/sentinel-golang/core/stat.(Slot).OnEntryPassed C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/stat/stat_slot.go:50 github.com/alibaba/sentinel-golang/core/base.(SlotChain).Entry C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/core/base/slot_chain.go:211 github.com/alibaba/sentinel-golang/api.entry C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/api/api.go:169 github.com/alibaba/sentinel-golang/api.Entry C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang@v1.0.4/api/api.go:146 github.com/alibaba/sentinel-golang/pkg/adapters/gin.SentinelMiddleware.func1 C:/Users/18796/go/pkg/mod/github.com/alibaba/sentinel-golang/pkg/adapters/gin@v0.0.0-20230626085943-08071855bc67/middleware.go:24 github.com/gin-gonic/gin.(Context).Next C:/Users/18796/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(Engine).handleHTTPRequest C:/Users/18796/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 github.com/gin-gonic/gin.(Engine).ServeHTTP C:/Users/18796/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 net/http.serverHandler.ServeHTTP C:/Program Files/Go/src/net/http/server.go:3137 net/http.(*conn).serve C:/Program Files/Go/src/net/http/server.go:2039 runtime.goexit C:/Program Files/Go/src/runtime/asm_386.s:1363 {"timestamp":"2024-03-30 14:59:52.52300","caller":"leap_array.go:108","logLevel":"ERROR","msg":"array index out of bounds in AtomicBucketWrapArray.elementOffset()","idx":-3,"arrayLength":20} array index out of bounds