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

Fix/TS expiration handling without network #2937

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

carpawell
Copy link
Member

No description provided.

@carpawell carpawell self-assigned this Sep 12, 2024
@carpawell carpawell changed the title Fix/ts expiration handling without network Fix/TS expiration handling without network Sep 12, 2024
Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 63.63636% with 32 lines in your changes missing coverage. Please review.

Project coverage is 24.01%. Comparing base (4a1bc79) to head (817823d).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
pkg/local_object_storage/metabase/graveyard.go 58.62% 8 Missing and 4 partials ⚠️
pkg/local_object_storage/metabase/version.go 77.27% 4 Missing and 1 partial ⚠️
pkg/services/object/put/local.go 0.00% 4 Missing ⚠️
pkg/local_object_storage/shard/gc.go 57.14% 2 Missing and 1 partial ⚠️
cmd/neofs-lens/internal/meta/list-graveyard.go 0.00% 2 Missing ⚠️
cmd/neofs-node/object.go 0.00% 2 Missing ⚠️
pkg/local_object_storage/shard/control.go 50.00% 1 Missing and 1 partial ⚠️
cmd/neofs-node/storage.go 0.00% 1 Missing ⚠️
pkg/local_object_storage/metabase/iterators.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2937      +/-   ##
==========================================
+ Coverage   23.90%   24.01%   +0.10%     
==========================================
  Files         776      773       -3     
  Lines       45708    45597     -111     
==========================================
+ Hits        10928    10949      +21     
+ Misses      33920    33787     -133     
- Partials      860      861       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@carpawell carpawell marked this pull request as ready for review September 12, 2024 18:44
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@carpawell carpawell force-pushed the fix/TS-expiration-handling-without-network branch from 8831c47 to 8314653 Compare September 12, 2024 21:33
It takes too much of network/disk to handle tombstones expiration and removal,
so it is better to store it when tombstone is being indexed in metabase.
Additional little-endian expiration suffix was added to graveyard values.
Metabase version was increased as it is a non-compatible change. Relates #2929.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
They do not differ from the other objects (e.g. locks do). Initial logic has
changed much, graveyard now allows to handle expired tombstones marks (do not
confuse it with the lists of regular indexes) independently, while disk can be
cleared with the other types of object. Also, add tests for it.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
Graveyard now has tombstone expiration marks in epochs, there is no need to use
any network requests, just drop records if an epoch is big enough.
Closes #2929.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
It may or may not index tombstone's expiration in graveyard.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
@carpawell carpawell force-pushed the fix/TS-expiration-handling-without-network branch from 8314653 to 152150e Compare September 12, 2024 21:34
Migration can be done automatically, let admin's life be a better thing. TS
expiration is taken as the current epoch + 5. It is not critical if TS will live
more. In practice, side effects _may_ be seen only the first 5 hours after an
update, and only returned status code _may_ differ.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
@@ -49,7 +58,7 @@ func checkVersion(tx *bbolt.Tx, initialized bool) error {
return nil
}

func updateVersion(tx *bbolt.Tx, version uint64) error {
func (db *DB) updateVersion(tx *bbolt.Tx, version uint64) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why making it a method if db is never used?

Copy link
Contributor

@cthulhu-rider cthulhu-rider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think it's good to separate commit dropping old implementation from the one changing the approach. Although red diff is pretty, transient state with dead code makes no sense

defer db.modeMtx.RUnlock()

if db.mode.NoMetabase() {
return -1, ErrDegradedMode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont see any sense in negative return, can be zero?

if binary.LittleEndian.Uint64(v[addressKeySize:]) < epoch {
err := c.Delete()
if err != nil {
return fmt.Errorf("cleared %d TS marks in %d epoch and got error: %w", counter, epoch, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id add context to the error outside db handler

k, v := c.First()

for k != nil {
if binary.LittleEndian.Uint64(v[addressKeySize:]) < epoch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd still check v length explicitly to avoid unclear panic, especially since the suffix was not always there

var counter int

err := db.boltDB.Update(func(tx *bbolt.Tx) error {
bkt := tx.Bucket(graveyardBucketName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if bkt == nil?

return res, fmt.Errorf("decode tombstone address from value: %w", err)
}

if len(v) == addressKeySize+8 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> case should be either erroneous or no-problem, silence is bad


func migrateFrom2Version(db *DB, tx *bbolt.Tx) error {
tsExpiration := db.epochState.CurrentEpoch() + objectconfig.DefaultTombstoneLifetime
bkt := tx.Bucket(graveyardBucketName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again can be nil


for k, v := c.First(); k != nil; k, v = c.Next() {
newVal := make([]byte, addressKeySize, addressKeySize+8)
copy(newVal, v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo we should assert len(v) == addressKeySize

pkg/local_object_storage/metabase/version.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants