Skip to content

Commit

Permalink
Update level but test case fail
Browse files Browse the repository at this point in the history
Signed-off-by: hwware <[email protected]>
  • Loading branch information
hwware committed Oct 28, 2024
1 parent 7e9fa70 commit c6db98b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/evict.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ int getMaxmemoryState(size_t *total, size_t *logical, size_t *tofree, float *lev

/* Compute the ratio of memory usage. */
if (level) {
*level = (float)mem_used / (float)server.maxmemory_available;
*level = (float)mem_used / (float)server.maxmemory;
}

if (mem_reported <= server.maxmemory_available) return C_OK;
Expand Down Expand Up @@ -729,8 +729,18 @@ int performEvictions(void) {
}
}
/* at this point, the memory is OK, or we have reached the time limit */
if (server.maxmemory_available) {
size_t mem_used = zmalloc_used_memory();
size_t overhead = freeMemoryGetNotCountedMemory();
mem_used = (mem_used > overhead) ? mem_used - overhead : 0;
if (mem_used > server.maxmemory) {
result = EVICT_FAIL;
goto cant_free;
}
}
result = (isEvictionProcRunning) ? EVICT_RUNNING : EVICT_OK;


cant_free:
if (result == EVICT_FAIL) {
/* At this point, we have run out of evictable items. It's possible
Expand Down

0 comments on commit c6db98b

Please sign in to comment.