mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix delayed deletion
This commit is contained in:
parent
5c6a166761
commit
b1f083cb60
|
@ -171,17 +171,17 @@ type delayedFile struct {
|
|||
}
|
||||
|
||||
func writeFiles(idChan chan int, fileIdLineChan chan string, s *stats) {
|
||||
deleteChan := make(chan *delayedFile, 100)
|
||||
delayedDeleteChan := make(chan *delayedFile, 100)
|
||||
var waitForDeletions sync.WaitGroup
|
||||
for i := 0; i < 7; i++ {
|
||||
go func() {
|
||||
waitForDeletions.Add(1)
|
||||
for df := range deleteChan {
|
||||
for df := range delayedDeleteChan {
|
||||
if df == nil {
|
||||
break
|
||||
}
|
||||
if df.enterTime.Add(time.Second).Before(time.Now()) {
|
||||
time.Sleep(df.enterTime.Add(time.Second).Sub(time.Now()))
|
||||
if df.enterTime.After(time.Now()) {
|
||||
time.Sleep(df.enterTime.Sub(time.Now()))
|
||||
}
|
||||
fp := df.fp
|
||||
serverLimitChan[fp.Server] <- true
|
||||
|
@ -210,7 +210,7 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stats) {
|
|||
if _, err := fp.Upload(0, *b.server); err == nil {
|
||||
if rand.Intn(100) < *b.deletePercentage {
|
||||
s.total++
|
||||
deleteChan <- &delayedFile{time.Now(), fp}
|
||||
delayedDeleteChan <- &delayedFile{time.Now().Add(time.Second), fp}
|
||||
} else {
|
||||
fileIdLineChan <- fp.Fid
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stats) {
|
|||
break
|
||||
}
|
||||
}
|
||||
close(deleteChan)
|
||||
close(delayedDeleteChan)
|
||||
waitForDeletions.Wait()
|
||||
wait.Done()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue