From e21ff677e4b00ec956e62ff0ae219331ce981a9c Mon Sep 17 00:00:00 2001 From: HarrisChu <1726587+HarrisChu@users.noreply.github.com> Date: Thu, 7 Apr 2022 13:16:24 +0800 Subject: [PATCH] fix dead lock --- pkg/nebulagraph/client.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/nebulagraph/client.go b/pkg/nebulagraph/client.go index 946e0da..b0f3969 100644 --- a/pkg/nebulagraph/client.go +++ b/pkg/nebulagraph/client.go @@ -277,7 +277,7 @@ func (gc *GraphClient) Execute(stmt string) (common.IGraphResponse, error) { responseTime := int32(time.Since(start) / 1000) // output - if gc.Pool.OutoptCh != nil && len(gc.Pool.OutoptCh) != cap(gc.Pool.OutoptCh) { + if gc.Pool.OutoptCh != nil { o := &output{ timeStamp: start.Unix(), nGQL: stmt, @@ -287,7 +287,11 @@ func (gc *GraphClient) Execute(stmt string) (common.IGraphResponse, error) { rows: rows, errorMsg: codeErr.GetErrorMsg(), } - gc.Pool.OutoptCh <- formatOutput(o) + select { + case gc.Pool.OutoptCh <- formatOutput(o): + // abandon if the output chan is full. + default: + } } return &Response{ResultSet: rs, ResponseTime: responseTime, codeErr: codeErr}, nil