You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2025/06/29 23:54:54 UTC
(skywalking-go) branch main updated: feat: add recover to goroutine to prevent unexpected panics (#226)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-go.git
The following commit(s) were added to refs/heads/main by this push:
new 04d4d36 feat: add recover to goroutine to prevent unexpected panics (#226)
04d4d36 is described below
commit 04d4d36a0c7eec22bc1b65e48efb55a074f9d6a1
Author: youngxhui <yo...@gmail.com>
AuthorDate: Sun Jun 29 16:54:49 2025 -0700
feat: add recover to goroutine to prevent unexpected panics (#226)
Notice, as we can't identify the root cause, this is just a temporary fix, which may cause further issues.
---
CHANGES.md | 1 +
plugins/core/reporter/cds_manager.go | 5 +++++
plugins/core/reporter/grpc/grpc.go | 20 ++++++++++++++++++++
3 files changed, 26 insertions(+)
diff --git a/CHANGES.md b/CHANGES.md
index cd86291..29b9108 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,6 +8,7 @@ Release Notes.
* Support Windows plugin test.
* Support Kafka reporter.
+* Add recover to goroutine to prevent unexpected panics.
#### Plugins
diff --git a/plugins/core/reporter/cds_manager.go b/plugins/core/reporter/cds_manager.go
index 467fe66..54db55c 100644
--- a/plugins/core/reporter/cds_manager.go
+++ b/plugins/core/reporter/cds_manager.go
@@ -65,6 +65,11 @@ func (r *CDSManager) InitCDS(entity *Entity, cdsWatchers []AgentConfigChangeWatc
// fetch config
go func() {
+ defer func() {
+ if err := recover(); err != nil {
+ r.logger.Errorf("CDSManager InitCDS panic err %v", err)
+ }
+ }()
for {
switch r.connManager.GetConnectionStatus(r.serverAddr) {
case ConnectionStatusShutdown:
diff --git a/plugins/core/reporter/grpc/grpc.go b/plugins/core/reporter/grpc/grpc.go
index b2132ef..e41b30a 100644
--- a/plugins/core/reporter/grpc/grpc.go
+++ b/plugins/core/reporter/grpc/grpc.go
@@ -175,6 +175,11 @@ func (r *gRPCReporter) initSendPipeline() {
return
}
go func() {
+ defer func() {
+ if err := recover(); err != nil {
+ r.logger.Errorf("gRPCReporter initSendPipeline trace client Collect panic err %v", err)
+ }
+ }()
StreamLoop:
for {
switch r.connManager.GetConnectionStatus(r.serverAddr) {
@@ -205,6 +210,11 @@ func (r *gRPCReporter) initSendPipeline() {
}
}()
go func() {
+ defer func() {
+ if err := recover(); err != nil {
+ r.logger.Errorf("gRPCReporter initSendPipeline metrics client CollectBatch panic err %v", err)
+ }
+ }()
StreamLoop:
for {
switch r.connManager.GetConnectionStatus(r.serverAddr) {
@@ -236,6 +246,11 @@ func (r *gRPCReporter) initSendPipeline() {
}
}()
go func() {
+ defer func() {
+ if err := recover(); err != nil {
+ r.logger.Errorf("gRPCReporter initSendPipeline log client Collect panic err %v", err)
+ }
+ }()
StreamLoop:
for {
switch r.connManager.GetConnectionStatus(r.serverAddr) {
@@ -303,6 +318,11 @@ func (r *gRPCReporter) check() {
return
}
go func() {
+ defer func() {
+ if err := recover(); err != nil {
+ r.logger.Errorf("gRPCReporter check panic err %v", err)
+ }
+ }()
instancePropertiesSubmitted := false
for {
switch r.connManager.GetConnectionStatus(r.serverAddr) {