Optimize recentlyModified's lock (#15120)

Signed-off-by: xige-16 <xi.ge@zilliz.com>
This commit is contained in:
xige-16 2022-01-10 23:17:36 +08:00 committed by GitHub
parent 828b9d399f
commit 99315ce00e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,7 +92,7 @@ type Segment struct {
once sync.Once // guards enableIndex
enableIndex bool
rmMutex sync.Mutex // guards recentlyModified
rmMutex sync.RWMutex // guards recentlyModified
recentlyModified bool
typeMu sync.Mutex // guards builtIndex
@ -141,8 +141,8 @@ func (s *Segment) setRecentlyModified(modify bool) {
}
func (s *Segment) getRecentlyModified() bool {
s.rmMutex.Lock()
defer s.rmMutex.Unlock()
s.rmMutex.RLock()
defer s.rmMutex.RUnlock()
return s.recentlyModified
}