forked from TrueCloudLab/frostfs-node
[#1664] write-cache: Fix panic on `Delete` operation
If an object is found in the Write-cache and is placed at the end of the in-memory cache, the memory counter update operation tries to dereference the index that is out of the sliced array. Moreover, even if panic does not appear, the counter is updated with the wrong value. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>neofs-adm-fix-update
parent
81684b6f04
commit
da2975a2f9
|
@ -8,6 +8,7 @@ Changelog for NeoFS Node
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Panic on write-cache's `Delete` operation (#1664)
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ func (c *cache) Delete(addr oid.Address) error {
|
||||||
c.mtx.Lock()
|
c.mtx.Lock()
|
||||||
for i := range c.mem {
|
for i := range c.mem {
|
||||||
if saddr == c.mem[i].addr {
|
if saddr == c.mem[i].addr {
|
||||||
|
c.curMemSize -= uint64(len(c.mem[i].data))
|
||||||
copy(c.mem[i:], c.mem[i+1:])
|
copy(c.mem[i:], c.mem[i+1:])
|
||||||
c.mem = c.mem[:len(c.mem)-1]
|
c.mem = c.mem[:len(c.mem)-1]
|
||||||
c.curMemSize -= uint64(len(c.mem[i].data))
|
|
||||||
c.mtx.Unlock()
|
c.mtx.Unlock()
|
||||||
storagelog.Write(c.log, storagelog.AddressField(saddr), storagelog.OpField("in-mem DELETE"))
|
storagelog.Write(c.log, storagelog.AddressField(saddr), storagelog.OpField("in-mem DELETE"))
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue