From edba5fa9798e1a1218355d5f8d32c21462636b2f Mon Sep 17 00:00:00 2001 From: tobbe76 Date: Sun, 24 Nov 2024 13:56:40 +0100 Subject: [PATCH] Use original "Return zst Decoder to sync.pool when finished #770" fix This fix does not suffer from the segfault seen under high load with #771. --- server/grpc_bytestream.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/server/grpc_bytestream.go b/server/grpc_bytestream.go index b24969ca7..de554f128 100644 --- a/server/grpc_bytestream.go +++ b/server/grpc_bytestream.go @@ -365,12 +365,6 @@ func (s *grpcServer) Write(srv bytestream.ByteStream_WriteServer) error { resourceNameChan := make(chan string, 1) cmp := casblob.Identity - var dec *syncpool.DecoderWrapper - defer func() { - if dec != nil { - dec.Close() - } - }() go func() { firstIteration := true @@ -436,8 +430,7 @@ func (s *grpcServer) Write(srv bytestream.ByteStream_WriteServer) error { var rc io.ReadCloser = pr if cmp == casblob.Zstandard { - var ok bool - dec, ok = decoderPool.Get().(*syncpool.DecoderWrapper) + dec, ok := decoderPool.Get().(*syncpool.DecoderWrapper) if !ok { s.accessLogger.Printf("GRPC BYTESTREAM WRITE FAILED: %s", errDecoderPoolFail) recvResult <- errDecoderPoolFail @@ -453,6 +446,7 @@ func (s *grpcServer) Write(srv bytestream.ByteStream_WriteServer) error { } go func() { + defer rc.Close() err := s.cache.Put(srv.Context(), cache.CAS, hash, size, rc) putResult <- err }()