Skip to content

Commit

Permalink
node/metabase: Do not index homomorphic hashes when missing
Browse files Browse the repository at this point in the history
Should have been done in 9e2e544.
Objects have no homomorphic payload hash when hashing is disabled in the
network settings.

Refs #3058.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
  • Loading branch information
cthulhu-rider committed Feb 28, 2025
1 parent 414d3e9 commit 89621cf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changelog for NeoFS Node
### Fixed
- Zero range denial by `neofs-cli object range|hash` commands (#3182)
- Not all the components needed for write-cache migration were initialized (#3186)
- Homomorphic hash indexes with empty values in meta bucket (#3187)

### Changed

Expand Down
6 changes: 4 additions & 2 deletions pkg/local_object_storage/metabase/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ func putMetadata(tx *bbolt.Tx, cnr cid.ID, id oid.ID, ver version.Version, owner
if err = putPlainAttribute(metaBkt, &keyBuf, id, object.FilterPayloadChecksum, string(pldHash)); err != nil {
return err
}
if err = putPlainAttribute(metaBkt, &keyBuf, id, object.FilterPayloadHomomorphicHash, string(pldHmmHash)); err != nil {
return err
if len(pldHmmHash) > 0 {
if err = putPlainAttribute(metaBkt, &keyBuf, id, object.FilterPayloadHomomorphicHash, string(pldHmmHash)); err != nil {
return err
}
}
if len(splitID) > 0 {
if err = putPlainAttribute(metaBkt, &keyBuf, id, object.FilterSplitID, string(splitID)); err != nil {
Expand Down
17 changes: 17 additions & 0 deletions pkg/local_object_storage/metabase/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,23 @@ func TestPutMetadata(t *testing.T) {
return nil
})
require.NoError(t, err)

t.Run("no homomorphic checksum", func(t *testing.T) {
cnr := cidtest.OtherID(cnr)
var obj object.Object
obj.SetContainerID(cnr)
obj.SetID(id)
obj.SetPayloadChecksum(pldHash) // Put requires

require.NoError(t, db.Put(&obj, nil, nil))

require.NoError(t, db.boltDB.View(func(tx *bbolt.Tx) error {
mb := tx.Bucket(append([]byte{0xFF}, cnr[:]...))
require.NotNil(t, mb, "missing container's meta bucket")
assertAttrPresence(t, mb, id, "$Object:homomorphicHash", "", false)
return nil
}))
})
}

func TestApplyFilter(t *testing.T) {
Expand Down

0 comments on commit 89621cf

Please sign in to comment.