diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-11-03 12:20:41 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-11-03 12:22:19 -0800 |
| commit | 0ae4d7bfdfb1318c71d64ba395c27882f9b3fd6a (patch) | |
| tree | 952a80061ba43058d56e45f95d355bb7b8695738 | |
| parent | 8054ef23103bdfaa2912f4ebf2d3454a11713339 (diff) | |
| download | seaweedfs-0ae4d7bfdfb1318c71d64ba395c27882f9b3fd6a.tar.xz seaweedfs-0ae4d7bfdfb1318c71d64ba395c27882f9b3fd6a.zip | |
lock "addChunks()"
| -rw-r--r-- | weed/filesys/dirty_page.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/weed/filesys/dirty_page.go b/weed/filesys/dirty_page.go index c1b78a220..11089186f 100644 --- a/weed/filesys/dirty_page.go +++ b/weed/filesys/dirty_page.go @@ -15,10 +15,10 @@ type ContinuousDirtyPages struct { intervals *ContinuousIntervals f *File writeWaitGroup sync.WaitGroup + chunkAddLock sync.Mutex chunkSaveErrChan chan error chunkSaveErrChanClosed bool lastErr error - lock sync.Mutex collection string replication string } @@ -117,6 +117,8 @@ func (pages *ContinuousDirtyPages) saveToStorage(reader io.Reader, offset int64, } chunk.Mtime = mtime pages.collection, pages.replication = collection, replication + pages.chunkAddLock.Lock() + defer pages.chunkAddLock.Unlock() pages.f.addChunks([]*filer_pb.FileChunk{chunk}) glog.V(3).Infof("%s saveToStorage [%d,%d)", pages.f.fullpath(), offset, offset+size) } |
