Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/neofs-node/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,14 @@ func newFSChainForObjects(placementSvc *placement.Service, isLocalPubKey func([]
}
}

// ResetContainer drops cached container, if any, so that next Get fetches it
// from the FS chain.
func (x *fsChainForObjects) ResetContainer(id cid.ID) {
if r, ok := x.Source.(interface{ resetContainer(cid.ID) }); ok {
r.resetContainer(id)
}
}

// InContainerInLastTwoEpochs checks whether given public key belongs to any SN
// from the referenced container either in the current or the previous NeoFS
// epoch.
Expand Down
10 changes: 10 additions & 0 deletions pkg/services/object/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ func (s *Server) checkContainerRevision(clientCnrRev uint64, cID cid.ID) error {
return fmt.Errorf("fetching container from FS chain: %w", err)
}

if clientCnrRev > cnr.Revision() {
// server's data may be outdated, try to fetch the newer one
if r, ok := s.fsChain.(interface{ ResetContainer(cid.ID) }); ok {
r.ResetContainer(cID)
if cnr, err = s.fsChain.Get(cID); err != nil {
return fmt.Errorf("fetching container from FS chain: %w", err)
}
}
}

if srvCnrRev := cnr.Revision(); clientCnrRev != srvCnrRev {
return apistatus.NewContainerRevisionMismatch(fmt.Sprintf(
"container revision does not match: requested: %d, server's: %d", clientCnrRev, srvCnrRev))
Expand Down