From b1718a60e4e4dbfbc794939343dbad4de40bbe51 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 18 Nov 2020 17:41:27 +0300 Subject: [PATCH] [#176] shard: Fix BlobStor access when data range is zero In previous implementation Shard accessed the BlobStor to get the object header. However, the shard must take headers from the metabase. From now zero length of the requested payload range seens as object header request. In this case shard calls metabase to get the header. Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/shard/get.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/local_object_storage/shard/get.go b/pkg/local_object_storage/shard/get.go index b20a6f895..563e00d4e 100644 --- a/pkg/local_object_storage/shard/get.go +++ b/pkg/local_object_storage/shard/get.go @@ -49,6 +49,9 @@ func (p *GetPrm) WithFullRange() *GetPrm { // // Calling with negative length is equivalent // to getting the full payload range. +// +// Calling with zero length is equivalent +// to getting the object header. func (p *GetPrm) WithRange(off uint64, ln int64) *GetPrm { if p != nil { p.off, p.ln = off, ln @@ -89,6 +92,15 @@ func (s *Shard) Get(prm *GetPrm) (*GetRes, error) { return &GetRes{ obj: res.Object(), }, nil + } else if prm.ln == 0 { + head, err := s.metaBase.Get(prm.addr) + if err != nil { + return nil, err + } + + return &GetRes{ + obj: head, + }, nil } // try to read from WriteCache