mirror of
https://github.com/minio/minio.git
synced 2024-12-25 06:35:56 -05:00
fix: crash in globalTierJournal when TierConfig is not initialized (#17791)
This commit is contained in:
parent
b762fbaf21
commit
239ccc9c40
@ -346,7 +346,7 @@ var (
|
|||||||
|
|
||||||
globalTierConfigMgr *TierConfigMgr
|
globalTierConfigMgr *TierConfigMgr
|
||||||
|
|
||||||
globalTierJournal *tierJournal
|
globalTierJournal *TierJournal
|
||||||
|
|
||||||
globalConsoleSrv *restapi.Server
|
globalConsoleSrv *restapi.Server
|
||||||
|
|
||||||
|
@ -362,6 +362,7 @@ func initAllSubsystems(ctx context.Context) {
|
|||||||
|
|
||||||
// Create new ILM tier configuration subsystem
|
// Create new ILM tier configuration subsystem
|
||||||
globalTierConfigMgr = NewTierConfigMgr()
|
globalTierConfigMgr = NewTierConfigMgr()
|
||||||
|
globalTierJournal = NewTierJournal()
|
||||||
|
|
||||||
globalTransitionState = newTransitionState(GlobalContext)
|
globalTransitionState = newTransitionState(GlobalContext)
|
||||||
globalSiteResyncMetrics = newSiteResyncMetrics(GlobalContext)
|
globalSiteResyncMetrics = newSiteResyncMetrics(GlobalContext)
|
||||||
@ -798,14 +799,10 @@ func serverMain(ctx *cli.Context) {
|
|||||||
go func() {
|
go func() {
|
||||||
// Initialize transition tier configuration manager
|
// Initialize transition tier configuration manager
|
||||||
bootstrapTrace("globalTierConfigMgr.Init")
|
bootstrapTrace("globalTierConfigMgr.Init")
|
||||||
err := globalTierConfigMgr.Init(GlobalContext, newObject)
|
if err := globalTierConfigMgr.Init(GlobalContext, newObject); err != nil {
|
||||||
if err != nil {
|
|
||||||
logger.LogIf(GlobalContext, err)
|
logger.LogIf(GlobalContext, err)
|
||||||
} else {
|
} else {
|
||||||
globalTierJournal, err = initTierDeletionJournal(GlobalContext)
|
logger.FatalIf(globalTierJournal.Init(GlobalContext), "Unable to initialize remote tier pending deletes journal")
|
||||||
if err != nil {
|
|
||||||
logger.FatalIf(err, "Unable to initialize remote tier pending deletes journal")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//go:generate msgp -file $GOFILE -unexported
|
//go:generate msgp -file $GOFILE -unexported
|
||||||
//msgp:ignore tierJournal tierDiskJournal walkfn
|
//msgp:ignore TierJournal tierDiskJournal walkfn
|
||||||
|
|
||||||
type tierDiskJournal struct {
|
type tierDiskJournal struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
@ -40,7 +40,8 @@ type tierDiskJournal struct {
|
|||||||
file *os.File // active journal file
|
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
|
*tierDiskJournal // for processing legacy journal entries
|
||||||
*tierMemJournal // for processing new journal entries
|
*tierMemJournal // for processing new journal entries
|
||||||
}
|
}
|
||||||
@ -62,24 +63,28 @@ func newTierDiskJournal() *tierDiskJournal {
|
|||||||
return &tierDiskJournal{}
|
return &tierDiskJournal{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// initTierDeletionJournal intializes an in-memory journal built using a
|
// NewTierJournal initializes tier deletion journal
|
||||||
// buffered channel for new journal entries. It also initializes the on-disk
|
func NewTierJournal() *TierJournal {
|
||||||
// journal only to process existing journal entries made from previous versions.
|
j := &TierJournal{
|
||||||
func initTierDeletionJournal(ctx context.Context) (*tierJournal, error) {
|
tierMemJournal: newTierMemJournal(1000),
|
||||||
j := &tierJournal{
|
|
||||||
tierMemJournal: newTierMemJoural(1000),
|
|
||||||
tierDiskJournal: newTierDiskJournal(),
|
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() {
|
for _, diskPath := range globalEndpoints.LocalDisksPaths() {
|
||||||
j.diskPath = diskPath
|
t.diskPath = diskPath
|
||||||
|
|
||||||
go j.deletePending(ctx) // for existing journal entries from previous MinIO versions
|
go t.deletePending(ctx) // for existing journal entries from previous MinIO versions
|
||||||
go j.processEntries(ctx) // for newer journal entries circa free-versions
|
go t.processEntries(ctx) // for newer journal entries circa free-versions
|
||||||
return j, nil
|
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
|
// rotate rotates the journal. If a read-only journal already exists it does
|
||||||
|
@ -28,7 +28,7 @@ type tierMemJournal struct {
|
|||||||
entries chan jentry
|
entries chan jentry
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTierMemJoural(nevents int) *tierMemJournal {
|
func newTierMemJournal(nevents int) *tierMemJournal {
|
||||||
return &tierMemJournal{
|
return &tierMemJournal{
|
||||||
entries: make(chan jentry, nevents),
|
entries: make(chan jentry, nevents),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user