tracker server adjust storage status to newer by anyway

pull/48/head
yuqing 2014-08-24 11:10:16 +08:00
parent b638f2ce88
commit 86eef2069d
3 changed files with 41 additions and 4 deletions

View File

@ -1,7 +1,11 @@
Version 5.04 2014-08-19 Version 5.04 2014-08-24
* add fastdfs.spec for build RPM on Linux * add fastdfs.spec for build RPM on Linux
* depend on libfastcommon * depend on libfastcommon
* in multi tracker servers case, when receive higher status like
online / active and the storage status is wait_sync or syncing,
the tracker adjust storage status to newer, and the storage rejoin
to the tracker server
Version 5.03 2014-08-10 Version 5.03 2014-08-10
* network send and recv retry when error EINTR happen * network send and recv retry when error EINTR happen

View File

@ -44,6 +44,7 @@ static pthread_mutex_t reporter_thread_lock;
static pthread_t *report_tids = NULL; static pthread_t *report_tids = NULL;
static int *src_storage_status = NULL; //returned by tracker server static int *src_storage_status = NULL; //returned by tracker server
static signed char *my_report_status = NULL; //returned by tracker server static signed char *my_report_status = NULL; //returned by tracker server
static bool need_rejoin_tracker = false;
static int tracker_heart_beat(ConnectionInfo *pTrackerServer, \ static int tracker_heart_beat(ConnectionInfo *pTrackerServer, \
int *pstat_chg_sync_count, bool *bServerPortChanged); int *pstat_chg_sync_count, bool *bServerPortChanged);
@ -540,6 +541,11 @@ static void *tracker_report_thread_entrance(void *arg)
} }
} }
if (need_rejoin_tracker)
{
need_rejoin_tracker = false;
break;
}
sleep(1); sleep(1);
} }
@ -844,6 +850,21 @@ static int tracker_merge_servers(ConnectionInfo *pTrackerServer, \
FDFS_STORAGE_STATUS_SYNCING)) && \ FDFS_STORAGE_STATUS_SYNCING)) && \
((*ppFound)->server.status > pServer->status)) ((*ppFound)->server.status > pServer->status))
{ {
*(pServer->ip_addr + IP_ADDRESS_SIZE - 1) = '\0';
if (is_local_host_ip(pServer->ip_addr) && \
buff2int(pServer->port) == g_server_port)
{
need_rejoin_tracker = true;
logWarning("file: "__FILE__", line: %d, " \
"tracker response status: %d, " \
"local status: %d, need rejoin " \
"tracker server: %s:%d", \
__LINE__, pServer->status, \
(*ppFound)->server.status, \
pTrackerServer->ip_addr,
pTrackerServer->port);
}
memcpy(pDiffServer++, &((*ppFound)->server), \ memcpy(pDiffServer++, &((*ppFound)->server), \
sizeof(FDFSStorageBrief)); sizeof(FDFSStorageBrief));
} }

View File

@ -4690,9 +4690,7 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
{ {
pServer->id[FDFS_STORAGE_ID_MAX_SIZE - 1] = '\0'; pServer->id[FDFS_STORAGE_ID_MAX_SIZE - 1] = '\0';
pServer->ip_addr[IP_ADDRESS_SIZE - 1] = '\0'; pServer->ip_addr[IP_ADDRESS_SIZE - 1] = '\0';
if (pServer->status == FDFS_STORAGE_STATUS_NONE \ if (pServer->status == FDFS_STORAGE_STATUS_NONE)
|| pServer->status == FDFS_STORAGE_STATUS_ACTIVE \
|| pServer->status == FDFS_STORAGE_STATUS_ONLINE)
{ {
continue; continue;
} }
@ -4708,6 +4706,8 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
tracker_mem_cmp_by_storage_id)) != NULL) tracker_mem_cmp_by_storage_id)) != NULL)
{ {
if ((*ppFound)->status == pServer->status \ if ((*ppFound)->status == pServer->status \
|| (*ppFound)->status == \
FDFS_STORAGE_STATUS_INIT \
|| (*ppFound)->status == \ || (*ppFound)->status == \
FDFS_STORAGE_STATUS_ONLINE \ FDFS_STORAGE_STATUS_ONLINE \
|| (*ppFound)->status == \ || (*ppFound)->status == \
@ -4718,6 +4718,13 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
continue; continue;
} }
logWarning("file: "__FILE__", line: %d, "
"storage server: %s:%d, dest status: %d, "
"my status: %d, should change my status!",
__LINE__, (*ppFound)->ip_addr,
(*ppFound)->storage_port,
pServer->status, (*ppFound)->status);
if (pServer->status == \ if (pServer->status == \
FDFS_STORAGE_STATUS_DELETED FDFS_STORAGE_STATUS_DELETED
|| pServer->status == \ || pServer->status == \
@ -4739,6 +4746,11 @@ int tracker_mem_sync_storages(FDFSGroupInfo *pGroup, \
{ {
//ignore deleted storage server //ignore deleted storage server
} }
else if (pServer->status == FDFS_STORAGE_STATUS_ACTIVE
|| pServer->status == FDFS_STORAGE_STATUS_ONLINE)
{
//ignore online or active storage server
}
else else
{ {
FDFSStorageDetail *pStorageServer; FDFSStorageDetail *pStorageServer;