[#1674] *: Expire entities after the expiration epoch
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
f1572a674b
commit
4afb928ab6
6 changed files with 10 additions and 10 deletions
|
@ -266,7 +266,7 @@ func (v *FormatValidator) ValidateContent(o *object.Object) error {
|
|||
return fmt.Errorf("lock object expiration epoch: %w", err)
|
||||
}
|
||||
|
||||
if currEpoch := v.netState.CurrentEpoch(); lockExp <= currEpoch {
|
||||
if currEpoch := v.netState.CurrentEpoch(); lockExp < currEpoch {
|
||||
return fmt.Errorf("lock object expiration: %d; current: %d", lockExp, currEpoch)
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ func (ap *Processor) filterExpiredSG(cid cid.ID, sgIDs []oid.ID,
|
|||
}
|
||||
|
||||
// filter expired epochs
|
||||
if sg.ExpirationEpoch() > ap.epochSrc.EpochCounter() {
|
||||
if sg.ExpirationEpoch() >= ap.epochSrc.EpochCounter() {
|
||||
coreSG.SetID(sgID)
|
||||
coreSG.SetStorageGroup(*sg)
|
||||
|
||||
|
|
|
@ -107,12 +107,12 @@ func addAttribute(obj *object.Object, key, val string) {
|
|||
|
||||
func checkExpiredObjects(t *testing.T, db *meta.DB, f func(exp, nonExp *objectSDK.Object)) {
|
||||
expObj := generateObject(t)
|
||||
setExpiration(expObj, currEpoch)
|
||||
setExpiration(expObj, currEpoch-1)
|
||||
|
||||
require.NoError(t, metaPut(db, expObj, nil))
|
||||
|
||||
nonExpObj := generateObject(t)
|
||||
setExpiration(nonExpObj, currEpoch+1)
|
||||
setExpiration(nonExpObj, currEpoch)
|
||||
|
||||
require.NoError(t, metaPut(db, nonExpObj, nil))
|
||||
|
||||
|
|
|
@ -112,9 +112,9 @@ func objectStatus(tx *bbolt.Tx, addr oid.Address, currEpoch uint64) uint8 {
|
|||
expirationBucket := tx.Bucket(attributeBucketName(addr.Container(), objectV2.SysAttributeExpEpoch))
|
||||
if expirationBucket != nil {
|
||||
// bucket that contains objects that expire in the current epoch
|
||||
currEpochBkt := expirationBucket.Bucket([]byte(strconv.FormatUint(currEpoch, 10)))
|
||||
if currEpochBkt != nil {
|
||||
if currEpochBkt.Get(rawOID) != nil {
|
||||
prevEpochBkt := expirationBucket.Bucket([]byte(strconv.FormatUint(currEpoch-1, 10)))
|
||||
if prevEpochBkt != nil {
|
||||
if prevEpochBkt.Get(rawOID) != nil {
|
||||
expired = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,10 +61,10 @@ func (db *DB) iterateExpired(tx *bbolt.Tx, epoch uint64, h ExpiredObjectHandler)
|
|||
return nil
|
||||
}
|
||||
|
||||
expiresAt, err := strconv.ParseUint(string(expKey), 10, 64)
|
||||
expiresAfter, err := strconv.ParseUint(string(expKey), 10, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not parse expiration epoch: %w", err)
|
||||
} else if expiresAt >= epoch {
|
||||
} else if expiresAfter >= epoch {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ func (g *ExpirationChecker) handleTS(addr string, ts *object.Object, reqEpoch ui
|
|||
}
|
||||
|
||||
g.cache.Add(addr, epoch)
|
||||
return epoch > reqEpoch
|
||||
return epoch >= reqEpoch
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue