diff --git a/cmd/globals.go b/cmd/globals.go index 88911ebfe..7d354760f 100644 --- a/cmd/globals.go +++ b/cmd/globals.go @@ -346,7 +346,7 @@ var ( globalTierConfigMgr *TierConfigMgr - globalTierJournal *tierJournal + globalTierJournal *TierJournal globalConsoleSrv *restapi.Server diff --git a/cmd/server-main.go b/cmd/server-main.go index 8b76a50e0..07756c8dc 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -362,6 +362,7 @@ func initAllSubsystems(ctx context.Context) { // Create new ILM tier configuration subsystem globalTierConfigMgr = NewTierConfigMgr() + globalTierJournal = NewTierJournal() globalTransitionState = newTransitionState(GlobalContext) globalSiteResyncMetrics = newSiteResyncMetrics(GlobalContext) @@ -798,14 +799,10 @@ func serverMain(ctx *cli.Context) { go func() { // Initialize transition tier configuration manager bootstrapTrace("globalTierConfigMgr.Init") - err := globalTierConfigMgr.Init(GlobalContext, newObject) - if err != nil { + if err := globalTierConfigMgr.Init(GlobalContext, newObject); err != nil { logger.LogIf(GlobalContext, err) } else { - globalTierJournal, err = initTierDeletionJournal(GlobalContext) - if err != nil { - logger.FatalIf(err, "Unable to initialize remote tier pending deletes journal") - } + logger.FatalIf(globalTierJournal.Init(GlobalContext), "Unable to initialize remote tier pending deletes journal") } }() diff --git a/cmd/tier-journal.go b/cmd/tier-journal.go index 3db7affef..2f8037011 100644 --- a/cmd/tier-journal.go +++ b/cmd/tier-journal.go @@ -32,7 +32,7 @@ import ( ) //go:generate msgp -file $GOFILE -unexported -//msgp:ignore tierJournal tierDiskJournal walkfn +//msgp:ignore TierJournal tierDiskJournal walkfn type tierDiskJournal struct { sync.RWMutex @@ -40,7 +40,8 @@ type tierDiskJournal struct { file *os.File // active journal file } -type tierJournal struct { +// TierJournal holds an in-memory and an on-disk delete journal of tiered content. +type TierJournal struct { *tierDiskJournal // for processing legacy journal entries *tierMemJournal // for processing new journal entries } @@ -62,24 +63,28 @@ func newTierDiskJournal() *tierDiskJournal { return &tierDiskJournal{} } -// initTierDeletionJournal intializes an in-memory journal built using a -// buffered channel for new journal entries. It also initializes the on-disk -// journal only to process existing journal entries made from previous versions. -func initTierDeletionJournal(ctx context.Context) (*tierJournal, error) { - j := &tierJournal{ - tierMemJournal: newTierMemJoural(1000), +// NewTierJournal initializes tier deletion journal +func NewTierJournal() *TierJournal { + j := &TierJournal{ + tierMemJournal: newTierMemJournal(1000), tierDiskJournal: newTierDiskJournal(), } + return j +} +// Init intializes an in-memory journal built using a +// buffered channel for new journal entries. It also initializes the on-disk +// journal only to process existing journal entries made from previous versions. +func (t *TierJournal) Init(ctx context.Context) error { for _, diskPath := range globalEndpoints.LocalDisksPaths() { - j.diskPath = diskPath + t.diskPath = diskPath - go j.deletePending(ctx) // for existing journal entries from previous MinIO versions - go j.processEntries(ctx) // for newer journal entries circa free-versions - return j, nil + go t.deletePending(ctx) // for existing journal entries from previous MinIO versions + go t.processEntries(ctx) // for newer journal entries circa free-versions + return nil } - return nil, errors.New("no local drive found") + return errors.New("no local drive found") } // rotate rotates the journal. If a read-only journal already exists it does diff --git a/cmd/tier-mem-journal.go b/cmd/tier-mem-journal.go index 1de17f1a8..34fbb8ae4 100644 --- a/cmd/tier-mem-journal.go +++ b/cmd/tier-mem-journal.go @@ -28,7 +28,7 @@ type tierMemJournal struct { entries chan jentry } -func newTierMemJoural(nevents int) *tierMemJournal { +func newTierMemJournal(nevents int) *tierMemJournal { return &tierMemJournal{ entries: make(chan jentry, nevents), }