diff --git a/agent.go b/agent.go index c43df71a..79e46225 100644 --- a/agent.go +++ b/agent.go @@ -767,8 +767,8 @@ func (a *agentMessageHandler) httpCall(request motan.Request, ck string, httpClu } httpRequest := fasthttp.AcquireRequest() httpResponse := fasthttp.AcquireResponse() + // do not release http response defer fasthttp.ReleaseRequest(httpRequest) - defer fasthttp.ReleaseResponse(httpResponse) httpRequest.Header.Del("Host") httpRequest.SetHost(originalService) httpRequest.URI().SetPath(request.GetMethod()) diff --git a/ha/backupRequestHA.go b/ha/backupRequestHA.go index 8ee949d9..d95fe9dd 100644 --- a/ha/backupRequestHA.go +++ b/ha/backupRequestHA.go @@ -97,10 +97,9 @@ func (br *BackupRequestHA) Call(request motan.Request, loadBalance motan.LoadBal break } // log & clone backup request - pr := request + pr := request.Clone().(motan.Request) if i > 0 { vlog.Infof("[backup request ha] delay %d request id: %d, service: %s, method: %s", delay, request.GetRequestID(), request.GetServiceName(), request.GetMethod()) - pr = request.Clone().(motan.Request) } lastErrorCh = make(chan motan.Response, 1) go func(postRequest motan.Request, endpoint motan.EndPoint, errorCh chan motan.Response) { diff --git a/http/httpProxy.go b/http/httpProxy.go index 33738633..c95cde60 100644 --- a/http/httpProxy.go +++ b/http/httpProxy.go @@ -552,6 +552,7 @@ func MotanRequestToFasthttpRequest(motanRequest core.Request, fasthttpRequest *f } // FasthttpResponseToMotanResponse convert a http response to a motan response +// Notice:: Do not release HttpResponse early using this method // For http mesh server side, the httpServer response to the server agent but client need a motan response // Contrast to request convert, we put all headers to meta, an body maybe just use it with type []byte func FasthttpResponseToMotanResponse(motanResponse core.Response, fasthttpResponse *fasthttp.Response) { diff --git a/log/log.go b/log/log.go index a3b71c2e..34dd8670 100644 --- a/log/log.go +++ b/log/log.go @@ -373,6 +373,12 @@ func (d *defaultLogger) AccessLog(logObject *AccessLogEntity) { } func (d *defaultLogger) doAccessLog(logObject *AccessLogEntity) { + defer func() { + if err := recover(); err != nil { + log.Printf("doAccessLog failed. err:%v, logObject: %+v", err, logObject) + debug.PrintStack() + } + }() if d.accessStructured { d.accessLogger.Info("", zap.String("filterName", logObject.FilterName), diff --git a/meshClient.go b/meshClient.go index 88e93a46..147d0043 100644 --- a/meshClient.go +++ b/meshClient.go @@ -119,8 +119,8 @@ func (c *MeshClient) BaseCall(request core.Request, reply interface{}) core.Resp } httpRequest := fasthttp.AcquireRequest() httpResponse := fasthttp.AcquireResponse() + // do not release http response defer fasthttp.ReleaseRequest(httpRequest) - defer fasthttp.ReleaseResponse(httpResponse) httpRequest.Header.Del("Host") httpRequest.SetHost(request.GetServiceName()) httpRequest.URI().SetPath(request.GetMethod()) diff --git a/provider/httpProvider.go b/provider/httpProvider.go index 106616ba..f4175238 100644 --- a/provider/httpProvider.go +++ b/provider/httpProvider.go @@ -271,7 +271,7 @@ func (h *HTTPProvider) DoTransparentProxy(request motan.Request, t int64, ip str fillHttpException(resp, http.StatusNotFound, t, err.Error()) return resp } - // sets rewrite + // set rewrite httpReq.URI().SetScheme(h.proxySchema) httpReq.URI().SetPath(rewritePath) request.GetAttachments().Range(func(k, v string) bool {