Skip to content

Commit

Permalink
handle restore goto load_error label
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Nov 4, 2024
1 parent f399485 commit 0d43d18
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions src/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,22 @@ void functionsLibCtxClearCurrent(int async) {
}

/* Free the given functions ctx */
void functionsLibCtxFree(functionsLibCtx *functions_lib_ctx) {
functionsLibCtxClear(functions_lib_ctx);
dictRelease(functions_lib_ctx->functions);
dictRelease(functions_lib_ctx->libraries);
dictRelease(functions_lib_ctx->engines_stats);
zfree(functions_lib_ctx);
void functionsLibCtxFree(functionsLibCtx *functions_lib_ctx, int async) {
if (async) {
freeFunctionsAsync(functions_lib_ctx);
} else {
functionsLibCtxClear(functions_lib_ctx);
dictRelease(functions_lib_ctx->functions);
dictRelease(functions_lib_ctx->libraries);
dictRelease(functions_lib_ctx->engines_stats);
zfree(functions_lib_ctx);
}
}

/* Swap the current functions ctx with the given one.
* Free the old functions ctx. */
void functionsLibCtxSwapWithCurrent(functionsLibCtx *new_lib_ctx, int async) {
if (async) {
freeFunctionsAsync(curr_functions_lib_ctx);
} else {
functionsLibCtxFree(curr_functions_lib_ctx);
}
functionsLibCtxFree(curr_functions_lib_ctx, async);
curr_functions_lib_ctx = new_lib_ctx;
}

Expand Down Expand Up @@ -796,7 +796,7 @@ void functionRestoreCommand(client *c) {
addReply(c, shared.ok);
}
if (functions_lib_ctx) {
functionsLibCtxFree(functions_lib_ctx);
functionsLibCtxFree(functions_lib_ctx, server.lazyfree_lazy_user_flush);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ size_t functionsLibCtxFunctionsLen(functionsLibCtx *functions_ctx);
functionsLibCtx *functionsLibCtxGetCurrent(void);
functionsLibCtx *functionsLibCtxCreate(void);
void functionsLibCtxClearCurrent(int async);
void functionsLibCtxFree(functionsLibCtx *lib_ctx);
void functionsLibCtxFree(functionsLibCtx *functions_lib_ctx, int async);
void functionsLibCtxClear(functionsLibCtx *lib_ctx);
void functionsLibCtxSwapWithCurrent(functionsLibCtx *new_lib_ctx, int async);

Expand Down
4 changes: 2 additions & 2 deletions src/lazyfree.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void lazyFreeLuaScripts(void *args[]) {
void lazyFreeFunctionsCtx(void *args[]) {
functionsLibCtx *functions_lib_ctx = args[0];
size_t len = functionsLibCtxFunctionsLen(functions_lib_ctx);
functionsLibCtxFree(functions_lib_ctx);
functionsLibCtxFree(functions_lib_ctx, 0);
atomic_fetch_sub_explicit(&lazyfree_objects, len, memory_order_relaxed);
atomic_fetch_add_explicit(&lazyfreed_objects, len, memory_order_relaxed);
}
Expand Down Expand Up @@ -240,7 +240,7 @@ void freeFunctionsAsync(functionsLibCtx *functions_lib_ctx) {
memory_order_relaxed);
bioCreateLazyFreeJob(lazyFreeFunctionsCtx, 1, functions_lib_ctx);
} else {
functionsLibCtxFree(functions_lib_ctx);
functionsLibCtxFree(functions_lib_ctx, 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,7 @@ void readSyncBulkPayload(connection *conn) {
NULL);

disklessLoadDiscardTempDb(diskless_load_tempDb);
functionsLibCtxFree(temp_functions_lib_ctx);
functionsLibCtxFree(temp_functions_lib_ctx, 0);
serverLog(LL_NOTICE, "PRIMARY <-> REPLICA sync: Discarding temporary DB in background");
} else {
/* Remove the half-loaded data in case we started with an empty replica. */
Expand Down

0 comments on commit 0d43d18

Please sign in to comment.