log more info when fdfs_recv_header / fdfs_recv_response fail

pull/56/merge
yuqing 2017-03-29 16:57:38 +08:00
parent 36ab6337e5
commit a29ebe48ad
13 changed files with 241 additions and 16 deletions

View File

@ -7,6 +7,7 @@ Version 5.10 2017-03-29
* do NOT sync storage server info to tracker leader
* adjust parameter store_server when use_trunk_file is true
* clear sync src id when tracker response ENOENT
* log more info when fdfs_recv_header / fdfs_recv_response fail
Version 5.09 2016-12-29
* bug fixed: list_all_groups expand buffer auto for so many groups

View File

@ -266,6 +266,9 @@ int storage_get_metadata(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_response(pStorageServer, \
&file_buff, 0, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
@ -364,6 +367,9 @@ int storage_query_file_info_ex(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_response(pStorageServer, \
&pInBuff, sizeof(in_buff), &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
@ -490,6 +496,9 @@ int storage_delete_file(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_response(pStorageServer, \
&pBuff, 0, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
@ -584,6 +593,9 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_header(pStorageServer, \
&in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_header fail, result: %d",
__LINE__, result);
break;
}
@ -601,6 +613,9 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_response(pStorageServer, \
file_buff, 0, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
}
@ -614,6 +629,9 @@ int storage_do_download_file_ex(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_header(pStorageServer, \
&in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_header fail, result: %d",
__LINE__, result);
break;
}
@ -973,6 +991,9 @@ int storage_do_upload_file(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_response(pStorageServer, \
&pInBuff, sizeof(in_buff), &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
@ -1229,6 +1250,12 @@ int storage_set_metadata(ConnectionInfo *pTrackerServer, \
pBuff = in_buff;
result = fdfs_recv_response(pStorageServer, \
&pBuff, 0, &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
} while (0);
if (meta_buff != NULL)
@ -1426,6 +1453,9 @@ int storage_client_create_link(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_response(pStorageServer, \
&pInBuff, sizeof(in_buff), &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
@ -1750,6 +1780,9 @@ int storage_do_append_file(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_header(pStorageServer, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_header fail, result: %d",
__LINE__, result);
break;
}
@ -1878,6 +1911,9 @@ int storage_do_modify_file(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_header(pStorageServer, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_header fail, result: %d",
__LINE__, result);
break;
}
@ -2290,6 +2326,9 @@ int storage_truncate_file(ConnectionInfo *pTrackerServer, \
if ((result=fdfs_recv_header(pStorageServer, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_header fail, result: %d",
__LINE__, result);
break;
}

View File

@ -317,6 +317,12 @@ int tracker_list_servers(ConnectionInfo *pTrackerServer, \
pInBuff = (char *)stats;
result = fdfs_recv_response(conn, &pInBuff, \
sizeof(stats), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)
@ -514,6 +520,12 @@ int tracker_list_one_group(ConnectionInfo *pTrackerServer, \
pInBuff = (char *)&src;
result = fdfs_recv_response(conn, \
&pInBuff, sizeof(TrackerGroupStat), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)
@ -588,6 +600,12 @@ int tracker_list_groups(ConnectionInfo *pTrackerServer, \
pInBuff = (char *)stats;
result = fdfs_recv_response(conn, \
&pInBuff, sizeof(stats), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)
@ -699,6 +717,12 @@ int tracker_do_query_storage(ConnectionInfo *pTrackerServer, \
pInBuff = in_buff;
result = fdfs_recv_response(conn, \
&pInBuff, sizeof(in_buff), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)
@ -777,6 +801,12 @@ int tracker_query_storage_list(ConnectionInfo *pTrackerServer, \
pInBuff = in_buff;
result = fdfs_recv_response(conn, \
&pInBuff, sizeof(in_buff), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)
@ -870,6 +900,12 @@ int tracker_query_storage_store_without_group(ConnectionInfo *pTrackerServer,
pInBuff = in_buff;
result = fdfs_recv_response(conn, \
&pInBuff, sizeof(in_buff), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)
@ -947,6 +983,12 @@ int tracker_query_storage_store_with_group(ConnectionInfo *pTrackerServer, \
pInBuff = in_buff;
result = fdfs_recv_response(conn, \
&pInBuff, sizeof(in_buff), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)
@ -1036,6 +1078,12 @@ int tracker_query_storage_store_list_with_group( \
pInBuff = in_buff;
result = fdfs_recv_response(conn, \
&pInBuff, sizeof(in_buff), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)
@ -1198,7 +1246,13 @@ int tracker_delete_storage(TrackerServerGroup *pTrackerGroup, \
{
pInBuff = in_buff;
result = fdfs_recv_response(conn, &pInBuff, 0, &in_bytes);
}
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
tracker_disconnect_server_ex(conn, result != 0 && result != ENOENT);
if (result != 0)
@ -1275,6 +1329,9 @@ int tracker_delete_group(TrackerServerGroup *pTrackerGroup, \
tracker_disconnect_server_ex(conn, result != 0 && result != ENOENT);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
}
@ -1370,6 +1427,9 @@ int tracker_set_trunk_server(TrackerServerGroup *pTrackerGroup, \
}
else
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
return result;
}
}
@ -1430,6 +1490,12 @@ int tracker_get_storage_status(ConnectionInfo *pTrackerServer, \
pInBuff = (char *)pDestBuff;
result = fdfs_recv_response(conn, \
&pInBuff, sizeof(FDFSStorageBrief), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)
@ -1511,6 +1577,12 @@ int tracker_get_storage_id(ConnectionInfo *pTrackerServer, \
{
result = fdfs_recv_response(conn, \
&storage_id, FDFS_STORAGE_ID_MAX_SIZE, &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (new_connection)

View File

@ -153,6 +153,9 @@ static int storage_do_get_group_name(ConnectionInfo *pTrackerServer)
if ((result=fdfs_recv_response(pTrackerServer, \
&pInBuff, FDFS_GROUP_NAME_MAX_LEN, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
return result;
}

View File

@ -97,6 +97,12 @@ static int storage_report_ip_changed(ConnectionInfo *pTrackerServer)
if (result == 0 || result == EALREADY || result == ENOENT)
{
if (result != 0)
{
logWarning("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
return 0;
}
else

View File

@ -249,6 +249,9 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
if ((result=fdfs_recv_response(pStorageServer, \
&pBuff, 0, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
} while (0);
@ -442,6 +445,9 @@ static int storage_sync_modify_file(ConnectionInfo *pStorageServer, \
if ((result=fdfs_recv_response(pStorageServer, \
&pBuff, 0, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
} while (0);
@ -590,6 +596,9 @@ static int storage_sync_truncate_file(ConnectionInfo *pStorageServer, \
if ((result=fdfs_recv_response(pStorageServer, \
&pBuff, 0, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}
} while (0);
@ -658,10 +667,19 @@ static int storage_sync_delete_file(ConnectionInfo *pStorageServer, \
pBuff = in_buff;
result = fdfs_recv_response(pStorageServer, &pBuff, 0, &in_bytes);
if (result == ENOENT)
{
result = 0;
}
if (result != 0)
{
if (result == ENOENT)
{
result = 0;
}
else
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
return result;
}
@ -698,7 +716,14 @@ static int storage_report_my_server_id(ConnectionInfo *pStorageServer)
}
pBuff = in_buff;
return fdfs_recv_response(pStorageServer, &pBuff, 0, &in_bytes);
result = fdfs_recv_response(pStorageServer, &pBuff, 0, &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
return result;
}
/**
@ -917,10 +942,19 @@ static int storage_sync_link_file(ConnectionInfo *pStorageServer, \
pBuff = in_buff;
result = fdfs_recv_response(pStorageServer, &pBuff, 0, &in_bytes);
if (result == ENOENT)
{
result = 0;
}
if (result != 0)
{
if (result == ENOENT)
{
result = 0;
}
else
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
return result;
}

View File

@ -1102,6 +1102,31 @@ static void set_tracker_leader(const int leader_index)
g_tracker_group.leader_index = leader_index;
}
static void get_tracker_leader()
{
int i;
TrackerRunningStatus tracker_status;
ConnectionInfo tracker_server;
for (i=0; i<g_tracker_group.server_count; i++)
{
memcpy(&tracker_server, g_tracker_group.servers + i,
sizeof(ConnectionInfo));
if (fdfs_get_tracker_status(&tracker_server, &tracker_status) == 0)
{
if (tracker_status.if_leader)
{
g_tracker_group.leader_index = i;
logInfo("file: "__FILE__", line: %d, "
"the tracker server leader is #%d. %s:%d",
__LINE__, i, tracker_server.ip_addr,
tracker_server.port);
break;
}
}
}
}
static int tracker_check_response(ConnectionInfo *pTrackerServer, \
bool *bServerPortChanged)
{
@ -1822,6 +1847,11 @@ static int tracker_sync_notify(ConnectionInfo *pTrackerServer, const int tracker
{
if (result == ENOENT)
{
if (g_tracker_group.leader_index == -1)
{
get_tracker_leader();
}
if (tracker_index == g_tracker_group.leader_index)
{
logWarning("file: "__FILE__", line: %d, "
@ -1830,10 +1860,9 @@ static int tracker_sync_notify(ConnectionInfo *pTrackerServer, const int tracker
__LINE__, g_sync_src_id);
*g_sync_src_id = '\0';
storage_write_to_sync_ini_file();
result = 0;
}
}
if (result != 0)
if (result != 0 && result != ENOENT)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_header fail, result: %d",
@ -1852,7 +1881,7 @@ static int tracker_sync_notify(ConnectionInfo *pTrackerServer, const int tracker
return EINVAL;
}
return 0;
return result;
}
int tracker_report_join(ConnectionInfo *pTrackerServer, \
@ -1911,8 +1940,12 @@ int tracker_report_join(ConnectionInfo *pTrackerServer, \
{
for (i=0; i<g_tracker_group.server_count; i++)
{
if (my_report_status[i] != EFAULT)
if (my_report_status[i] == -1)
{
logInfo("file: "__FILE__", line: %d, "
"tracker server: #%d. %s:%d, my_report_status: %d",
__LINE__, i, g_tracker_group.servers[i].ip_addr,
g_tracker_group.servers[i].port, my_report_status[i]);
break;
}
}

View File

@ -66,6 +66,9 @@ static int trunk_client_trunk_do_alloc_space(ConnectionInfo *pTrunkServer, \
if ((result=fdfs_recv_response(pTrunkServer, \
&p, sizeof(FDFSTrunkInfoBuff), &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
return result;
}
@ -176,6 +179,9 @@ static int trunk_client_trunk_confirm_or_free(ConnectionInfo *pTrunkServer,\
if ((result=fdfs_recv_header(pTrunkServer, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_header fail, result: %d",
__LINE__, result);
return result;
}

View File

@ -1381,6 +1381,9 @@ static int trunk_sync_data(TrunkBinLogReader *pReader, \
pBuff = in_buff;
if ((result=fdfs_recv_response(pStorage, &pBuff, 0, &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
return result;
}
@ -1573,9 +1576,13 @@ static void* trunk_sync_thread_entrance(void* arg)
if (reader.binlog_offset == 0)
{
if (fdfs_deal_no_body_cmd(&storage_server, \
STORAGE_PROTO_CMD_TRUNK_TRUNCATE_BINLOG_FILE) != 0)
if ((result=fdfs_deal_no_body_cmd(&storage_server, \
STORAGE_PROTO_CMD_TRUNK_TRUNCATE_BINLOG_FILE)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_deal_no_body_cmd fail, result: %d",
__LINE__, result);
close(storage_server.sock);
trunk_reader_destroy(&reader);
sleep(5);

View File

@ -745,6 +745,12 @@ int fdfs_get_storage_ids_from_tracker_server(ConnectionInfo *pTrackerServer)
response = NULL;
result = fdfs_recv_response(conn, \
&response, 0, &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
}
}
if (result != 0)

View File

@ -3801,6 +3801,9 @@ static int tracker_mem_get_sys_file_piece(ConnectionInfo *pTrackerServer, \
sizeof(in_buff), &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
return result;
}
@ -4868,6 +4871,9 @@ static int _storage_get_trunk_binlog_size(
if ((result=fdfs_recv_response(pStorageServer, \
&pInBuff, sizeof(in_buff), &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
return result;
}
@ -5054,6 +5060,9 @@ static int tracker_mem_do_set_trunk_server(FDFSGroupInfo *pGroup,
pGroup->storage_port,
STORAGE_PROTO_CMD_TRUNK_DELETE_BINLOG_MARKS)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_deal_no_body_cmd_ex fail, result: %d",
__LINE__, result);
return result;
}
}

View File

@ -183,6 +183,9 @@ int fdfs_deal_no_body_cmd(ConnectionInfo *pTrackerServer, const int cmd)
result = fdfs_recv_header(pTrackerServer, &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_header fail, cmd: %d, result: %d",
__LINE__, cmd, result);
return result;
}

View File

@ -64,6 +64,9 @@ static int fdfs_ping_leader(ConnectionInfo *pTrackerServer)
if ((result=fdfs_recv_response(pTrackerServer, &pInBuff, \
sizeof(in_buff), &in_bytes)) != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
return result;
}
@ -282,6 +285,9 @@ static int do_notify_leader_changed(ConnectionInfo *pTrackerServer, \
0, &in_bytes);
if (result != 0)
{
logError("file: "__FILE__", line: %d, "
"fdfs_recv_response fail, result: %d",
__LINE__, result);
break;
}