diff options
author | chenyang8094 <chenyang8094@users.noreply.github.com> | 2022-04-27 13:07:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-27 08:07:52 +0300 |
commit | e24d46004b115adb57c0a67e64081e5f6692188a (patch) | |
tree | 23e27d2980a7b851e7874b5ec311bd3df883143e /src/aof.c | |
parent | 81926254586f64fc6a9b393bf9afb0d2eacc5234 (diff) | |
download | redis-e24d46004b115adb57c0a67e64081e5f6692188a.tar.gz |
Delete renamed new incr when write manifest failed (#10649)
Followup fix for #10616
Diffstat (limited to 'src/aof.c')
-rw-r--r-- | src/aof.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -2517,7 +2517,8 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { if (!bysignal && exitcode == 0) { char tmpfile[256]; long long now = ustime(); - sds new_base_filename; + sds new_base_filepath = NULL; + sds new_incr_filepath = NULL; aofManifest *temp_am; mstime_t latency; @@ -2534,9 +2535,9 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { /* Get a new BASE file name and mark the previous (if we have) * as the HISTORY type. */ - new_base_filename = getNewBaseFileNameAndMarkPreAsHistory(temp_am); + sds new_base_filename = getNewBaseFileNameAndMarkPreAsHistory(temp_am); serverAssert(new_base_filename != NULL); - sds new_base_filepath = makePath(server.aof_dirname, new_base_filename); + new_base_filepath = makePath(server.aof_dirname, new_base_filename); /* Rename the temporary aof file to 'new_base_filename'. */ latencyStartMonitor(latency); @@ -2561,7 +2562,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { sdsfree(temp_incr_aof_name); /* Get next new incr aof name. */ sds new_incr_filename = getNewIncrAofName(temp_am); - sds new_incr_filepath = makePath(server.aof_dirname, new_incr_filename); + new_incr_filepath = makePath(server.aof_dirname, new_incr_filename); latencyStartMonitor(latency); if (rename(temp_incr_filepath, new_incr_filepath) == -1) { serverLog(LL_WARNING, @@ -2579,7 +2580,6 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { latencyEndMonitor(latency); latencyAddSampleIfNeeded("aof-rename", latency); sdsfree(temp_incr_filepath); - sdsfree(new_incr_filepath); } /* Change the AOF file type in 'incr_aof_list' from AOF_FILE_TYPE_INCR @@ -2591,9 +2591,14 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { bg_unlink(new_base_filepath); aofManifestFree(temp_am); sdsfree(new_base_filepath); + if (new_incr_filepath) { + bg_unlink(new_incr_filepath); + sdsfree(new_incr_filepath); + } goto cleanup; } sdsfree(new_base_filepath); + if (new_incr_filepath) sdsfree(new_incr_filepath); /* We can safely let `server.aof_manifest` point to 'temp_am' and free the previous one. */ aofManifestFreeAndUpdate(temp_am); |