From b4c69f79c995032b0a8c53a1ee1fb6819eabadd5 Mon Sep 17 00:00:00 2001 From: cheetah Date: Sun, 2 Jul 2023 09:15:29 -0500 Subject: [PATCH] fixing deadlock+verbose ingress --- main.go | 2 ++ storageserver/storageserver.go | 26 +++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index a9ff783..babba1f 100644 --- a/main.go +++ b/main.go @@ -269,6 +269,8 @@ func ProcessGMA(filePath string) (err error) { return err } dboGMA.Header = header + log.Printf("Name=%s\n", header.Title) + log.Printf("Desc=%s\n", header.Description) // log.Printf("AddonVersion=%d\n", header.AddonVersion) // log.Printf("FormatVersion=%d\n", header.FormatVersion) // log.Printf("FormatVersionDiscardByte=%d\n", header.FormatVersionDiscardByte) diff --git a/storageserver/storageserver.go b/storageserver/storageserver.go index 4ea7bce..94cef95 100644 --- a/storageserver/storageserver.go +++ b/storageserver/storageserver.go @@ -610,8 +610,8 @@ func (p *PoolMaster) Lookup(id string) (exists bool) { } } } - p.WORMLock.Lock() - defer p.WORMLock.Unlock() + p.lock.Lock() + defer p.lock.Unlock() for _, wormPool := range p.WORMPools { // WORM Pools for _, poolItem := range wormPool.items { if poolItem == id { @@ -699,8 +699,8 @@ func (p *PoolMaster) FetchLoadWORM(chunkID string, fileID string, writer io.Writ } func (p *PoolMaster) CleanWORMTemp() (err error) { p.lock.Lock() - p.WORMLock.Lock() - defer p.WORMLock.Unlock() + //p.WORMLock.Lock() + //defer p.WORMLock.Unlock() defer p.lock.Unlock() for _, wormPool := range p.WORMPools { @@ -735,16 +735,17 @@ func (p *PoolMaster) Fetch(id string, writer io.Writer) (err error) { } } } - p.WORMLock.Lock() - defer p.WORMLock.Unlock() + p.lock.Lock() for _, wormPool := range p.WORMPools { for _, poolItem := range wormPool.items { if poolItem == id { fmt.Printf("Fetch WORMPool %s file %s\n", wormPool.PoolID, id) + p.lock.Unlock() return wormPool.Fetch(id, writer) } } } + p.lock.Unlock() for _, fullPool := range p.FullPools { for _, poolItem := range fullPool.items { if poolItem == id { @@ -862,7 +863,7 @@ func (p *PoolMaster) Store(id string, src io.Reader, targetSize int64) (err erro } } pool.itemCount = newItemCount - fmt.Printf("Current Pool %s, Recounted ItemCount = %d\n", pool.PoolID, pool.itemCount) + //fmt.Printf("Current Pool %s, Recounted ItemCount = %d\n", pool.PoolID, pool.itemCount) if pool.itemCount >= PoolMaxItems { pool.ReadOnly = true } @@ -893,8 +894,8 @@ func main() { if len(poolMaster.FullPools) > 0 { poolMaster.lock.Lock() fmt.Printf("Aquiring WORMLock for Regular FullPool Pack\n") - poolMaster.WORMLock.Lock() - fmt.Printf("Aquired WORMLock success for Regular FullPool Pack\n") + //poolMaster.WORMLock.Lock() + //fmt.Printf("Aquired WORMLock success for Regular FullPool Pack\n") var deletedPools []string for _, fullPool := range poolMaster.FullPools { @@ -932,15 +933,18 @@ func main() { } } + //fmt.Printf("unlock WORMLock Regular FullPool Pack\n") + //poolMaster.WORMLock.Unlock() + fmt.Printf("unlock lock Regular FullPool Pack\n") poolMaster.lock.Unlock() - poolMaster.WORMLock.Unlock() - fmt.Printf("unlock WORMLock Regular FullPool Pack\n") } // poolMaster.CleanWORMTemp() time.Sleep(time.Second * 10) } }() + + // Initial packing for _, localPool := range poolMaster.LocalPools { if localPool.ReadOnly {