From 25907b23986120a80aa6269f81efb80dba29e28e Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sat, 7 May 2022 22:02:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=80=E7=A1=AC=E7=9B=98=E5=88=B7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=B6=E4=B8=8D=E7=BB=9F=E8=AE=A1maxOpenFiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/storage_file.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index 3863ae1..acdf4de 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -428,7 +428,7 @@ func (this *FileStorage) openWriter(key string, expiredAt int64, status int, siz return nil, ErrFileIsWriting } - if len(sharedWritingFileKeyMap) >= int(maxOpenFiles.Max()) { + if !isFlushing && len(sharedWritingFileKeyMap) >= int(maxOpenFiles.Max()) { sharedWritingFileKeyLocker.Unlock() return nil, ErrTooManyOpenFiles } @@ -534,10 +534,12 @@ func (this *FileStorage) openWriter(key string, expiredAt int64, status int, siz if err != nil { return nil, err } - if time.Since(before) >= maxOpenFilesSlowCost { - maxOpenFiles.Slow() - } else { - maxOpenFiles.Fast() + if !isFlushing { + if time.Since(before) >= maxOpenFilesSlowCost { + maxOpenFiles.Slow() + } else { + maxOpenFiles.Fast() + } } var removeOnFailure = true