-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify engine internals #3010
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2baeb79
engine: drop internal blockExec struct
roman-khimov 255c9e5
engine: drop e.execIfNotBlocked()
roman-khimov 9e6f9bb
engine: drop hashedShard type
roman-khimov 209f9ce
engine: drop iterateOverUnsortedShards and iterateOverSortedShards
roman-khimov 99d4320
engine: unify GetRange implementation with Get
roman-khimov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,64 +34,51 @@ func (e *StorageEngine) Head(addr oid.Address, raw bool) (*objectSDK.Object, err | |
} | ||
|
||
var ( | ||
head *objectSDK.Object | ||
siErr *objectSDK.SplitInfoError | ||
|
||
errNotFound apistatus.ObjectNotFound | ||
|
||
outSI *objectSDK.SplitInfo | ||
outError error = errNotFound | ||
shPrm shard.HeadPrm | ||
splitInfo *objectSDK.SplitInfo | ||
) | ||
|
||
var shPrm shard.HeadPrm | ||
shPrm.SetAddress(addr) | ||
shPrm.SetRaw(raw) | ||
|
||
e.iterateOverSortedShards(addr, func(_ int, sh shardWrapper) (stop bool) { | ||
for _, sh := range e.sortedShards(addr) { | ||
res, err := sh.Head(shPrm) | ||
if err != nil { | ||
var siErr *objectSDK.SplitInfoError | ||
|
||
switch { | ||
case shard.IsErrNotFound(err): | ||
return false // ignore, go to next shard | ||
continue // ignore, go to next shard | ||
case errors.As(err, &siErr): | ||
if outSI == nil { | ||
outSI = objectSDK.NewSplitInfo() | ||
if splitInfo == nil { | ||
splitInfo = objectSDK.NewSplitInfo() | ||
} | ||
|
||
util.MergeSplitInfo(siErr.SplitInfo(), outSI) | ||
util.MergeSplitInfo(siErr.SplitInfo(), splitInfo) | ||
|
||
// stop iterating over shards if SplitInfo structure is complete | ||
return !outSI.GetLink().IsZero() && !outSI.GetLastPart().IsZero() | ||
if !splitInfo.GetLink().IsZero() && !splitInfo.GetLastPart().IsZero() { | ||
return nil, logicerr.Wrap(objectSDK.NewSplitInfoError(splitInfo)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
} | ||
continue | ||
case shard.IsErrRemoved(err): | ||
outError = err | ||
|
||
return true // stop, return it back | ||
return nil, err // stop, return it back | ||
case shard.IsErrObjectExpired(err): | ||
var notFoundErr apistatus.ObjectNotFound | ||
|
||
// object is found but should not | ||
// be returned | ||
outError = notFoundErr | ||
|
||
return true | ||
return nil, apistatus.ObjectNotFound{} | ||
default: | ||
e.reportShardError(sh, "could not head object from shard", err) | ||
return false | ||
continue | ||
} | ||
} | ||
|
||
head = res.Object() | ||
|
||
return true | ||
}) | ||
|
||
if outSI != nil { | ||
return nil, logicerr.Wrap(objectSDK.NewSplitInfoError(outSI)) | ||
return res.Object(), nil | ||
} | ||
|
||
if head == nil { | ||
return nil, outError | ||
if splitInfo != nil { | ||
return nil, logicerr.Wrap(objectSDK.NewSplitInfoError(splitInfo)) | ||
} | ||
|
||
return head, nil | ||
return nil, apistatus.ObjectNotFound{} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this line be just
break
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That in fact is one of the things I wanted to discuss. It looks like split info collection we attempt to do here (with iteration-persistent
splitInfo
) is totally useless, we can return immediately upon seeing any split info because that's what we do ultimately anyway. But maybe I'm missing something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split information may or may not have a link object and a last part (it is theoretically ok to have a middle object only, be resynced, etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the comment above --- having a complete split info is beneficial to the caller (even though it gets an error), so this
if
can't be removed even though lacking a proper info we will return whatever is available.Regarding break/return --- both are valid, so it doesn't matter much, post-loop can be extended in which case
return
is better even though currently it duplicates error wrapping a bit.