Skip to content

Commit

Permalink
default object metadata timeout (fix)
Browse files Browse the repository at this point in the history
* when missing in the config
* related commit: 5a7b43c

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Oct 25, 2024
1 parent 1f2f155 commit 315e8d1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ais/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (t *target) Run() error {

tstats := t.statsT.(*stats.Trunner)

core.Tinit(t, tstats, config.Timeout.ObjectMD.D(), true /*run hk*/)
core.Tinit(t, tstats, config, true /*run hk*/)

fatalErr, writeErr := t.checkRestarted(config)
if fatalErr != nil {
Expand Down
2 changes: 1 addition & 1 deletion ais/tgtobj_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestMain(m *testing.M) {
t.htrun.init(config)

t.statsT = mock.NewStatsTracker()
core.Tinit(t, t.statsT, time.Hour, false)
core.Tinit(t, t.statsT, config, false)

bck := meta.NewBck(testBucket, apc.AIS, cmn.NsGlobal)
bmd := newBucketMD()
Expand Down
13 changes: 7 additions & 6 deletions core/lcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
skipEvictThreashold = 20 // likely not running when above
maxEvictThreashold = 60 // never running when above

dfltEvictTime = 2 * time.Hour
maxTimeWithNoEvictions = 16 * time.Hour
)

Expand Down Expand Up @@ -72,12 +73,12 @@ type (
)

// g.lchk
func (lchk *lchk) init(timeout time.Duration) {
func (lchk *lchk) init(config *cmn.Config) {
lchk.running.Store(false)
lchk.timeout = timeout
lchk.timeout = cos.NonZero(config.Timeout.ObjectMD.D(), dfltEvictTime)

lchk.last = time.Now()
hk.Reg("lcache"+hk.NameSuffix, lchk.housekeep, timeout)
hk.Reg("lcache"+hk.NameSuffix, lchk.housekeep, lchk.timeout)
}

// evict bucket
Expand Down Expand Up @@ -237,7 +238,7 @@ func (*term) f(_, value any) bool {
func (lchk *lchk) housekeep(int64) time.Duration {
// refresh
config := cmn.GCO.Get()
lchk.timeout = config.Timeout.ObjectMD.D()
lchk.timeout = cos.NonZero(config.Timeout.ObjectMD.D(), dfltEvictTime)

// concurrent term, uncache-bck, etc.
rc := lchk.rc.Load()
Expand All @@ -257,13 +258,13 @@ func (lchk *lchk) housekeep(int64) time.Duration {

if pct > maxEvictThreashold {
nlog.Warningln("max-evict threshold:", maxEvictThreashold, "- not running")
return min(lchk.timeout>>1, time.Hour)
return min(lchk.timeout>>1, dfltEvictTime>>1)
}
now := time.Now()
if pct > skipEvictThreashold {
if elapsed := now.Sub(lchk.last); elapsed < min(maxTimeWithNoEvictions, max(lchk.timeout, time.Hour)*8) {
nlog.Warningln("skip-evict threshold:", skipEvictThreashold, "elapsed:", elapsed, "- not running")
return min(lchk.timeout>>1, time.Hour)
return min(lchk.timeout>>1, dfltEvictTime>>1)
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/lom.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var (

func Pinit() { bckLocker = newNameLocker() }

func Tinit(t Target, tstats cos.StatsUpdater, timeout time.Duration, runHK bool) {
func Tinit(t Target, tstats cos.StatsUpdater, config *cmn.Config, runHK bool) {
bckLocker = newNameLocker()
T = t
{
Expand All @@ -107,7 +107,7 @@ func Tinit(t Target, tstats cos.StatsUpdater, timeout time.Duration, runHK bool)
g.smm = t.ByteMM()
}
if runHK {
g.lchk.init(timeout)
g.lchk.init(config)
}
for i := range recordSepa {
recdupSepa[i] = recordSepa[i]
Expand Down
2 changes: 1 addition & 1 deletion core/mock/target_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _ core.Target = (*TargetMock)(nil)

func NewTarget(bo meta.Bowner) *TargetMock {
t := &TargetMock{BO: bo}
core.Tinit(t, NewStatsTracker(), time.Hour, false)
core.Tinit(t, NewStatsTracker(), nil /*config*/, false /*run HK*/)
return t
}

Expand Down

0 comments on commit 315e8d1

Please sign in to comment.