diff --git a/core/stat/internal/cpu_linux.go b/core/stat/internal/cpu_linux.go index 29ce9decb..faf36c701 100644 --- a/core/stat/internal/cpu_linux.go +++ b/core/stat/internal/cpu_linux.go @@ -1,5 +1,3 @@ -//go:build !nocgroup - package internal import ( @@ -25,6 +23,7 @@ var ( preTotal uint64 limit float64 cores uint64 + noCgroup bool initOnce sync.Once ) @@ -32,6 +31,7 @@ var ( func initialize() { cpus, err := effectiveCpus() if err != nil { + noCgroup = true logx.Error(err) return } @@ -47,12 +47,14 @@ func initialize() { preSystem, err = systemCpuUsage() if err != nil { + noCgroup = true logx.Error(err) return } preTotal, err = cpuUsage() if err != nil { + noCgroup = true logx.Error(err) return } @@ -62,6 +64,10 @@ func initialize() { func RefreshCpu() uint64 { initOnce.Do(initialize) + if noCgroup { + return 0 + } + total, err := cpuUsage() if err != nil { return 0 diff --git a/core/stat/internal/cpu_other.go b/core/stat/internal/cpu_other.go index 0634828cf..b9c27ff75 100644 --- a/core/stat/internal/cpu_other.go +++ b/core/stat/internal/cpu_other.go @@ -1,4 +1,4 @@ -//go:build !linux || nocgroup +//go:build !linux package internal diff --git a/core/stores/sqlx/stmt.go b/core/stores/sqlx/stmt.go index cc35f2b5c..b66dcc7f5 100644 --- a/core/stores/sqlx/stmt.go +++ b/core/stores/sqlx/stmt.go @@ -141,7 +141,6 @@ func (s statement) QueryRowsPartialCtx(ctx context.Context, v any, args ...any) func (s statement) queryRows(ctx context.Context, scanFn func(any, rowsScanner) error, v any, args ...any) error { var scanFailed bool - err := s.brk.DoWithAcceptable(func() error { return queryStmt(ctx, s.stmt, func(rows *sql.Rows) error { err := scanFn(v, rows) diff --git a/readme-cn.md b/readme-cn.md index 0263b64b7..30c5c9978 100644 --- a/readme-cn.md +++ b/readme-cn.md @@ -307,8 +307,8 @@ go-zero 已被许多公司用于生产部署,接入场景如在线教育、电 ## 10. CNCF 云原生技术全景图
-
-
+
+
-
-
+
+