[#1296] writecache: Add count limit
All checks were successful
DCO action / DCO (pull_request) Successful in 3m42s
Tests and linters / Run gofumpt (pull_request) Successful in 4m1s
Pre-commit hooks / Pre-commit (pull_request) Successful in 4m25s
Build / Build Components (1.22) (pull_request) Successful in 4m38s
Build / Build Components (1.21) (pull_request) Successful in 4m40s
Tests and linters / Tests (1.22) (pull_request) Successful in 4m29s
Tests and linters / Tests (1.21) (pull_request) Successful in 4m37s
Tests and linters / Staticcheck (pull_request) Successful in 4m39s
Tests and linters / Tests with -race (pull_request) Successful in 4m49s
Tests and linters / Lint (pull_request) Successful in 5m14s
Tests and linters / gopls check (pull_request) Successful in 5m16s
Vulncheck / Vulncheck (pull_request) Successful in 43s

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-08-06 15:09:12 +03:00
parent 8e51d7849a
commit a2aea60a63
10 changed files with 65 additions and 20 deletions

View file

@ -76,8 +76,7 @@ func (c *cache) Put(ctx context.Context, prm common.PutPrm) (common.PutRes, erro
// putSmall persists small objects to the write-cache database and
// pushes the to the flush workers queue.
func (c *cache) putSmall(obj objectInfo) error {
cacheSize := c.estimateCacheSize()
if c.maxCacheSize < c.incSizeDB(cacheSize) {
if !c.hasEnoughSpaceDB() {
return ErrOutOfSpace
}
@ -107,8 +106,7 @@ func (c *cache) putSmall(obj objectInfo) error {
// putBig writes object to FSTree and pushes it to the flush workers queue.
func (c *cache) putBig(ctx context.Context, addr string, prm common.PutPrm) error {
cacheSz := c.estimateCacheSize()
if c.maxCacheSize < c.incSizeFS(cacheSz) {
if !c.hasEnoughSpaceFS() {
return ErrOutOfSpace
}