From 41581aae6b7fd8aa29c220aa6568a98113265879 Mon Sep 17 00:00:00 2001 From: yuqing Date: Fri, 14 Aug 2015 17:08:21 +0800 Subject: [PATCH] bug fixed: storage_disk_recovery.c skip the first file (binlog first line) --- HISTORY | 3 ++- fastdfs.spec | 2 +- storage/storage_disk_recovery.c | 43 ++++++++++++++++++++++++++++----- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/HISTORY b/HISTORY index 0857961..f8bf7f4 100644 --- a/HISTORY +++ b/HISTORY @@ -1,7 +1,8 @@ -Version 5.07 2015-08-07 +Version 5.07 2015-08-14 * schedule task add the "second" field * make.sh changed, you must upgrade libfastcommon to V1.20 or later + * bug fixed: storage_disk_recovery.c skip the first file (binlog first line) Version 5.06 2015-05-12 * compile passed in mac OS Darwin diff --git a/fastdfs.spec b/fastdfs.spec index 783f3f9..fe28c5f 100644 --- a/fastdfs.spec +++ b/fastdfs.spec @@ -21,7 +21,7 @@ Requires: %__cp %__mv %__chmod %__grep %__mkdir %__install %__id This package provides tracker & storage of fastdfs %package -n %{FDFSServer} -Requires: libfastcommon >= 1.0.18 +Requires: libfastcommon >= 1.0.20 Summary: fastdfs tracker & storage %package -n %{FDFSTool} diff --git a/storage/storage_disk_recovery.c b/storage/storage_disk_recovery.c index 0d9cc79..2646891 100644 --- a/storage/storage_disk_recovery.c +++ b/storage/storage_disk_recovery.c @@ -497,6 +497,17 @@ static int recovery_reader_init(const char *pBasePath, \ return 0; } +static int recovery_reader_check_init(const char *pBasePath, \ + StorageBinLogReader *pReader) +{ + if (pReader->binlog_fd >= 0 && pReader->binlog_buff.buffer != NULL) + { + return 0; + } + + return recovery_reader_init(pBasePath, pReader); +} + static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pReader, \ ConnectionInfo *pSrcStorage) { @@ -512,6 +523,7 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead int64_t file_size; int64_t total_count; int64_t success_count; + int64_t noent_count; bool bContinueFlag; char local_filename[MAX_PATH_SIZE]; char src_filename[MAX_PATH_SIZE]; @@ -520,6 +532,7 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead count = 0; total_count = 0; success_count = 0; + noent_count = 0; result = 0; logInfo("file: "__FILE__", line: %d, " \ @@ -529,6 +542,10 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead bContinueFlag = true; while (bContinueFlag) { + if ((result=recovery_reader_check_init(pBasePath, pReader)) != 0) + { + break; + } if ((pStorageConn=tracker_connect_server(pSrcStorage, &result)) == NULL) { sleep(5); @@ -605,8 +622,13 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead success_count++; } - else if (result != ENOENT) + else if (result == ENOENT) { + result = 0; + noent_count++; + } + else + { break; } } @@ -673,6 +695,10 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead bContinueFlag = false; break; } + else + { + result = 0; + } } } else @@ -692,25 +718,30 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead logDebug("file: "__FILE__", line: %d, " \ "disk recovery: recover path: %s, " \ "file count: %"PRId64 \ - ", success count: %"PRId64, \ + ", success count: %"PRId64", noent_count: %"PRId64, \ __LINE__, pBasePath, total_count, \ - success_count); + success_count, noent_count); recovery_write_to_mark_file(pBasePath, pReader); count = 0; } } tracker_disconnect_server_ex(pStorageConn, result != 0); + recovery_write_to_mark_file(pBasePath, pReader); + if (bContinueFlag) + { + storage_reader_destroy(pReader); + } + if (count > 0) { - recovery_write_to_mark_file(pBasePath, pReader); count = 0; logInfo("file: "__FILE__", line: %d, " \ "disk recovery: recover path: %s, " \ "file count: %"PRId64 \ - ", success count: %"PRId64, \ - __LINE__, pBasePath, total_count, success_count); + ", success count: %"PRId64", noent_count: %"PRId64, \ + __LINE__, pBasePath, total_count, success_count, noent_count); } else {