[#1658] meta: Add logic counter

- Meta now supports (and requires) inc/dec labeled counters
- The new logic counter is incremented on `Put` operations and is
decremented on `Inhume` and `Delete` operations that are performed on
_stored_ objects only
- Allow force counters sync. "Force" mode should be used on metabase resync
and should not be used on a regular meta start

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-09-09 14:33:38 +03:00 committed by LeL
parent d872862710
commit ad47e2a985
7 changed files with 437 additions and 140 deletions

View file

@ -143,9 +143,16 @@ func (db *DB) put(
}
if !isParent {
err = db.updateCounter(tx, 1, true)
err = db.updateCounter(tx, phy, 1, true)
if err != nil {
return fmt.Errorf("could not increase object counter: %w", err)
return fmt.Errorf("could not increase phy object counter: %w", err)
}
// it is expected that putting an unavailable object is
// impossible and should be handled on the higher levels
err = db.updateCounter(tx, logical, 1, true)
if err != nil {
return fmt.Errorf("could not increase logical object counter: %w", err)
}
}