Skip to content

Commit

Permalink
Use original "Return zst Decoder to sync.pool when finished #770" fix
Browse files Browse the repository at this point in the history
This fix does not suffer from the segfault seen under high load with #771.
  • Loading branch information
tobbe76 authored and mostynb committed Nov 24, 2024
1 parent a563ac2 commit edba5fa
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions server/grpc_bytestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}()
Expand Down

0 comments on commit edba5fa

Please sign in to comment.