diff options
author | Meir Shpilraien (Spielrein) <meir@redis.com> | 2021-12-16 17:58:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-16 17:58:25 +0200 |
commit | 687210f1550cf9048bed5f5539c9411fb22cd3b0 (patch) | |
tree | 6bd085128bbc5203edb46c61c41f0d74c0967b5d /src/lazyfree.c | |
parent | ffbe36fc3ee824407b3818c0a6f861176ce56482 (diff) | |
download | redis-687210f1550cf9048bed5f5539c9411fb22cd3b0.tar.gz |
Add FUNCTION FLUSH command to flush all functions (#9936)
Added `FUNCTION FLUSH` command. The new sub-command allows delete all the functions.
An optional `[SYNC|ASYNC]` argument can be given to control whether or not to flush the
functions synchronously or asynchronously. if not given the default flush mode is chosen by
`lazyfree-lazy-user-flush` configuration values.
Add the missing `functions.tcl` test to the list of tests that are executed in test_helper.tcl,
and call FUNCTION FLUSH in between servers in external mode
Diffstat (limited to 'src/lazyfree.c')
-rw-r--r-- | src/lazyfree.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lazyfree.c b/src/lazyfree.c index 6127abe77..1cc521cbd 100644 --- a/src/lazyfree.c +++ b/src/lazyfree.c @@ -1,6 +1,7 @@ #include "server.h" #include "bio.h" #include "atomicvar.h" +#include "functions.h" static redisAtomic size_t lazyfree_objects = 0; static redisAtomic size_t lazyfreed_objects = 0; @@ -46,6 +47,15 @@ void lazyFreeLuaScripts(void *args[]) { atomicIncr(lazyfreed_objects,len); } +/* Release the functions ctx. */ +void lazyFreeFunctionsCtx(void *args[]) { + functionsCtx *f_ctx = args[0]; + size_t len = functionsLen(f_ctx); + functionsCtxFree(f_ctx); + atomicDecr(lazyfree_objects,len); + atomicIncr(lazyfreed_objects,len); +} + /* Release replication backlog referencing memory. */ void lazyFreeReplicationBacklogRefMem(void *args[]) { list *blocks = args[0]; @@ -193,6 +203,16 @@ void freeLuaScriptsAsync(dict *lua_scripts) { } } +/* Free functions ctx, if the functions ctx contains enough functions, free it in async way. */ +void freeFunctionsAsync(functionsCtx *f_ctx) { + if (functionsLen(f_ctx) > LAZYFREE_THRESHOLD) { + atomicIncr(lazyfree_objects,functionsLen(f_ctx)); + bioCreateLazyFreeJob(lazyFreeFunctionsCtx,1,f_ctx); + } else { + functionsCtxFree(f_ctx); + } +} + /* Free replication backlog referencing buffer blocks and rax index. */ void freeReplicationBacklogRefMemAsync(list *blocks, rax *index) { if (listLength(blocks) > LAZYFREE_THRESHOLD || |