mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Issue #4027: unify comment and modify return value in freeMemoryIfNeeded().
It looks safer to return C_OK from freeMemoryIfNeeded() when clients are paused because returning C_ERR may prevent success of writes. It is possible that there is no difference in practice since clients cannot execute writes while clients are paused, but it looks more correct this way, at least conceptually. Related to PR #4028.
This commit is contained in:
parent
936ade80b2
commit
c9097393bf
@ -380,11 +380,10 @@ int freeMemoryIfNeeded(void) {
|
|||||||
long long delta;
|
long long delta;
|
||||||
int slaves = listLength(server.slaves);
|
int slaves = listLength(server.slaves);
|
||||||
|
|
||||||
/* We cannot free memory while clients are paused as this will require
|
/* When clients are paused the dataset should be static not just from the
|
||||||
* evictions which modify the dataset and will break the guarantee that
|
* POV of clients not being able to write, but also from the POV of
|
||||||
* data will be static while clients are paused. */
|
* expires and evictions of keys not being performed. */
|
||||||
if (clientsArePaused())
|
if (clientsArePaused()) return C_OK;
|
||||||
goto cant_free;
|
|
||||||
|
|
||||||
/* Check if we are over the memory usage limit. If we are not, no need
|
/* Check if we are over the memory usage limit. If we are not, no need
|
||||||
* to subtract the slaves output buffers. We can just return ASAP. */
|
* to subtract the slaves output buffers. We can just return ASAP. */
|
||||||
|
@ -105,8 +105,9 @@ void activeExpireCycle(int type) {
|
|||||||
int dbs_per_call = CRON_DBS_PER_CALL;
|
int dbs_per_call = CRON_DBS_PER_CALL;
|
||||||
long long start = ustime(), timelimit;
|
long long start = ustime(), timelimit;
|
||||||
|
|
||||||
/* We cannot expire keys while clients are paused as the dataset is
|
/* When clients are paused the dataset should be static not just from the
|
||||||
* supposed to be static. */
|
* POV of clients not being able to write, but also from the POV of
|
||||||
|
* expires and evictions of keys not being performed. */
|
||||||
if (clientsArePaused()) return;
|
if (clientsArePaused()) return;
|
||||||
|
|
||||||
if (type == ACTIVE_EXPIRE_CYCLE_FAST) {
|
if (type == ACTIVE_EXPIRE_CYCLE_FAST) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user