mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
set initial write time to avoid race condition with delayed chunks
This commit is contained in:
parent
d598c47136
commit
06e6341097
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContinuousDirtyPages struct {
|
type ContinuousDirtyPages struct {
|
||||||
|
@ -81,6 +82,7 @@ func (pages *ContinuousDirtyPages) saveExistingLargestPageToStorage() (hasSavedD
|
||||||
|
|
||||||
func (pages *ContinuousDirtyPages) saveToStorage(reader io.Reader, offset int64, size int64) {
|
func (pages *ContinuousDirtyPages) saveToStorage(reader io.Reader, offset int64, size int64) {
|
||||||
|
|
||||||
|
mtime := time.Now().UnixNano()
|
||||||
pages.writeWaitGroup.Add(1)
|
pages.writeWaitGroup.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer pages.writeWaitGroup.Done()
|
defer pages.writeWaitGroup.Done()
|
||||||
|
@ -94,19 +96,13 @@ func (pages *ContinuousDirtyPages) saveToStorage(reader io.Reader, offset int64,
|
||||||
pages.chunkSaveErrChan <- err
|
pages.chunkSaveErrChan <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
chunk.Mtime = mtime
|
||||||
pages.collection, pages.replication = collection, replication
|
pages.collection, pages.replication = collection, replication
|
||||||
pages.f.addChunks([]*filer_pb.FileChunk{chunk})
|
pages.f.addChunks([]*filer_pb.FileChunk{chunk})
|
||||||
pages.chunkSaveErrChan <- nil
|
pages.chunkSaveErrChan <- nil
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func maxUint64(x, y uint64) uint64 {
|
|
||||||
if x > y {
|
|
||||||
return x
|
|
||||||
}
|
|
||||||
return y
|
|
||||||
}
|
|
||||||
|
|
||||||
func max(x, y int64) int64 {
|
func max(x, y int64) int64 {
|
||||||
if x > y {
|
if x > y {
|
||||||
return x
|
return x
|
||||||
|
|
Loading…
Reference in a new issue