从内存刷新到磁盘时无需并发写限制

This commit is contained in:
GoEdgeLab
2024-04-30 21:23:44 +08:00
parent 5890f7a98d
commit 2b35971a66

View File

@@ -616,11 +616,13 @@ func (this *FileStorage) openWriter(key string, expiredAt int64, status int, hea
if isNewCreated && existsFile {
flags |= os.O_TRUNC
}
if !fsutils.WriterLimiter.TryAck() {
if !isFlushing && !fsutils.WriterLimiter.TryAck() {
return nil, ErrServerIsBusy
}
writer, err := os.OpenFile(tmpPath, flags, 0666)
if !isFlushing {
fsutils.WriterLimiter.Release()
}
if err != nil {
if os.IsNotExist(err) {
_ = os.MkdirAll(dir, 0777)