Skip to content

Commit 775e6fc

Browse files
gmgigi96ccaffy
authored andcommitted
MGM: Do not bail out in case unmarshalling of FileInspector stats fails
Fixes EOS-6514
1 parent 9ca3943 commit 775e6fc

File tree

1 file changed

+42
-36
lines changed

1 file changed

+42
-36
lines changed

mgm/inspector/FileInspector.cc

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
2222
************************************************************************/
2323

24+
#include "Logging.hh"
2425
#include "common/Path.hh"
2526
#include "common/FileId.hh"
2627
#include "common/IntervalStopwatch.hh"
@@ -1369,43 +1370,48 @@ void FileInspector::QdbHelper::Load(FileInspectorStats& stats)
13691370
{
13701371
std::vector<std::string> members = mQHashStats.hgetall();
13711372

1372-
for (int i = 0; i < members.size() - 1; i += 2) {
1373-
std::string key = members[i];
1374-
std::string value = members[i + 1];
1375-
1376-
if (key == SCAN_STATS_KEY) {
1377-
Unmarshal(value, stats.ScanStats);
1378-
} else if (key == FAULTY_FILES_KEY) {
1379-
Unmarshal(value, stats.FaultyFiles);
1380-
} else if (key == ACCESS_TIME_FILES_KEY) {
1381-
Unmarshal(value, stats.AccessTimeFiles);
1382-
} else if (key == ACCESS_TIME_VOLUME_KEY) {
1383-
Unmarshal(value, stats.AccessTimeVolume);
1384-
} else if (key == BIRTH_TIME_FILES_KEY) {
1385-
Unmarshal(value, stats.BirthTimeFiles);
1386-
} else if (key == BIRTH_TIME_VOLUME_KEY) {
1387-
Unmarshal(value, stats.BirthTimeVolume);
1388-
} else if (key == BIRTH_VS_ACCESS_TIME_FILES_KEY) {
1389-
Unmarshal(value, stats.BirthVsAccessTimeFiles);
1390-
} else if (key == BIRTH_VS_ACCESS_TIME_VOLUME_KEY) {
1391-
Unmarshal(value, stats.BirthVsAccessTimeVolume);
1392-
} else if (key == USER_COSTS_KEY) {
1393-
Unmarshal(value, stats.UserCosts);
1394-
} else if (key == GROUP_COSTS_KEY) {
1395-
Unmarshal(value, stats.GroupCosts);
1396-
} else if (key == TOTAL_COSTS_KEY) {
1397-
Unmarshal(value, stats.TotalCosts);
1398-
} else if (key == USER_BYTES_KEY) {
1399-
Unmarshal(value, stats.UserBytes);
1400-
} else if (key == GROUP_BYTES_KEY) {
1401-
Unmarshal(value, stats.GroupBytes);
1402-
} else if (key == TOTAL_BYTES_KEY) {
1403-
Unmarshal(value, stats.TotalBytes);
1404-
} else if (key == NUM_FAULTY_FILES_KEY) {
1405-
Unmarshal(value, stats.NumFaultyFiles);
1406-
} else if (key == TIME_SCAN_KEY) {
1407-
Unmarshal(value, stats.TimeScan);
1373+
try {
1374+
for (int i = 0; i < members.size() - 1; i += 2) {
1375+
std::string key = members[i];
1376+
std::string value = members[i + 1];
1377+
1378+
if (key == SCAN_STATS_KEY) {
1379+
Unmarshal(value, stats.ScanStats);
1380+
} else if (key == FAULTY_FILES_KEY) {
1381+
Unmarshal(value, stats.FaultyFiles);
1382+
} else if (key == ACCESS_TIME_FILES_KEY) {
1383+
Unmarshal(value, stats.AccessTimeFiles);
1384+
} else if (key == ACCESS_TIME_VOLUME_KEY) {
1385+
Unmarshal(value, stats.AccessTimeVolume);
1386+
} else if (key == BIRTH_TIME_FILES_KEY) {
1387+
Unmarshal(value, stats.BirthTimeFiles);
1388+
} else if (key == BIRTH_TIME_VOLUME_KEY) {
1389+
Unmarshal(value, stats.BirthTimeVolume);
1390+
} else if (key == BIRTH_VS_ACCESS_TIME_FILES_KEY) {
1391+
Unmarshal(value, stats.BirthVsAccessTimeFiles);
1392+
} else if (key == BIRTH_VS_ACCESS_TIME_VOLUME_KEY) {
1393+
Unmarshal(value, stats.BirthVsAccessTimeVolume);
1394+
} else if (key == USER_COSTS_KEY) {
1395+
Unmarshal(value, stats.UserCosts);
1396+
} else if (key == GROUP_COSTS_KEY) {
1397+
Unmarshal(value, stats.GroupCosts);
1398+
} else if (key == TOTAL_COSTS_KEY) {
1399+
Unmarshal(value, stats.TotalCosts);
1400+
} else if (key == USER_BYTES_KEY) {
1401+
Unmarshal(value, stats.UserBytes);
1402+
} else if (key == GROUP_BYTES_KEY) {
1403+
Unmarshal(value, stats.GroupBytes);
1404+
} else if (key == TOTAL_BYTES_KEY) {
1405+
Unmarshal(value, stats.TotalBytes);
1406+
} else if (key == NUM_FAULTY_FILES_KEY) {
1407+
Unmarshal(value, stats.NumFaultyFiles);
1408+
} else if (key == TIME_SCAN_KEY) {
1409+
Unmarshal(value, stats.TimeScan);
1410+
}
14081411
}
1412+
} catch (...) {
1413+
eos_static_warning("msg=\"error unmarshalling FileInspector stats from QDB\"");
1414+
stats = FileInspectorStats(); // Reset stats on error
14091415
}
14101416
}
14111417

0 commit comments

Comments
 (0)