[#1825] writecache: Flush cache when moving to the DEGRADED mode
Degraded mode allows us to operate without an SSD, thus writecache should be unavailable in this mode. Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
236414df49
commit
8b3b16fe62
5 changed files with 50 additions and 11 deletions
|
@ -50,7 +50,7 @@ func (c *cache) runFlushLoop() {
|
|||
for {
|
||||
select {
|
||||
case <-tt.C:
|
||||
c.flush()
|
||||
c.flushDB()
|
||||
tt.Reset(defaultFlushInterval)
|
||||
case <-c.closeCh:
|
||||
return
|
||||
|
@ -59,7 +59,7 @@ func (c *cache) runFlushLoop() {
|
|||
}()
|
||||
}
|
||||
|
||||
func (c *cache) flush() {
|
||||
func (c *cache) flushDB() {
|
||||
lastKey := []byte{}
|
||||
var m []objectInfo
|
||||
for {
|
||||
|
@ -241,6 +241,10 @@ func (c *cache) Flush(ignoreErrors bool) error {
|
|||
return errMustBeReadOnly
|
||||
}
|
||||
|
||||
return c.flush(ignoreErrors)
|
||||
}
|
||||
|
||||
func (c *cache) flush(ignoreErrors bool) error {
|
||||
var prm common.IteratePrm
|
||||
prm.IgnoreErrors = ignoreErrors
|
||||
prm.LazyHandler = func(addr oid.Address, f func() ([]byte, error)) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue