Skip to content
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

node/object: Improve SEARCH and GET #2722

Merged
merged 3 commits into from
Apr 11, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ For example, `attr>=100` or `attr=` are now processed differently. See `-h` for
- Incorrect handling of notary request leading to inability to collect signatures in some cases (#2715)
- Deadlock in autodeploy routine (#2720)
- SN now validates session tokens attached to objects (#1159)
- Object search server no longer wastes system resources sending empty intermediate messages to the stream (#2722)

### Changed
- Created files are not group writable (#2589)
Expand Down
8 changes: 8 additions & 0 deletions pkg/services/object/get/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (exec *execCtx) processEpoch(epoch uint64) bool {
defer cancel()

exec.status = statusUndefined
mProcessedNodes := make(map[string]struct{})

for {
addrs := traverser.Next()
Expand All @@ -61,6 +62,13 @@ func (exec *execCtx) processEpoch(epoch uint64) bool {
default:
}

strKey := string(addrs[i].PublicKey())
if _, ok = mProcessedNodes[strKey]; ok {
continue
}

mProcessedNodes[strKey] = struct{}{}

// TODO: #1142 consider parallel execution
// TODO: #1142 consider optimization: if status == SPLIT we can continue until
// we reach the best result - split info with linking object ID.
Expand Down
4 changes: 4 additions & 0 deletions pkg/services/object/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,12 @@ func testNodeMatrix(t testing.TB, dim []int) ([][]netmap.NodeInfo, [][]string) {
strconv.Itoa(60000+j),
)

bPubKey := make([]byte, 33)
rand.Read(bPubKey)

var ni netmap.NodeInfo
ni.SetNetworkEndpoints(a)
ni.SetPublicKey(bPubKey)

var na network.AddressGroup

Expand Down
9 changes: 9 additions & 0 deletions pkg/services/object/search/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func (exec *execCtx) processEpoch(epoch uint64) bool {
ctx, cancel := context.WithCancel(exec.context())
defer cancel()

mProcessedNodes := make(map[string]struct{})

for {
addrs := traverser.Next()
if len(addrs) == 0 {
Expand All @@ -56,6 +58,13 @@ func (exec *execCtx) processEpoch(epoch uint64) bool {
var mtx sync.Mutex

for i := range addrs {
strKey := string(addrs[i].PublicKey())
if _, ok = mProcessedNodes[strKey]; ok {
continue
}

mProcessedNodes[strKey] = struct{}{}

wg.Add(1)
go func(i int) {
defer wg.Done()
Expand Down
6 changes: 5 additions & 1 deletion pkg/services/object/search/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ func (exec *execCtx) generateTraverser(cnr cid.ID, epoch uint64) (*placement.Tra
}

func (exec *execCtx) writeIDList(ids []oid.ID) {
err := exec.prm.writer.WriteIDs(ids)
var err error

if len(ids) > 0 {
err = exec.prm.writer.WriteIDs(ids)
}

switch {
default:
Expand Down
4 changes: 4 additions & 0 deletions pkg/services/object/search/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,12 @@ func testNodeMatrix(t testing.TB, dim []int) ([][]netmap.NodeInfo, [][]string) {
strconv.Itoa(60000+j),
)

bPubKey := make([]byte, 33)
rand.Read(bPubKey)

var ni netmap.NodeInfo
ni.SetNetworkEndpoints(a)
ni.SetPublicKey(bPubKey)

var na network.AddressGroup

Expand Down
Loading