[rrd4j] Error handling for broken rrd4j files (#13955)

* [rrd4j] Error handling for broken rrd4j files

Catch exceptions thrown by getDB(..) and print the name of the affected
database file. This allows to identify a broken rrd4j file.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich 2022-12-15 11:31:20 +01:00 committed by GitHub
parent 04f059c455
commit 6ab0561382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,7 +152,12 @@ public class RRD4jPersistenceService implements QueryablePersistenceService {
} }
final String name = alias == null ? item.getName() : alias; final String name = alias == null ? item.getName() : alias;
RrdDb db = getDB(name); RrdDb db = null;
try {
db = getDB(name);
} catch (Exception e) {
logger.warn("Failed to open rrd4j database '{}' ({})", name, e.getClass().getName());
}
if (db == null) { if (db == null) {
return; return;
} }
@ -249,7 +254,13 @@ public class RRD4jPersistenceService implements QueryablePersistenceService {
public Iterable<HistoricItem> query(FilterCriteria filter) { public Iterable<HistoricItem> query(FilterCriteria filter) {
String itemName = filter.getItemName(); String itemName = filter.getItemName();
RrdDb db = getDB(itemName); RrdDb db = null;
try {
db = getDB(itemName);
} catch (Exception e) {
logger.warn("Failed to open rrd4j database '{}' ({})", itemName, e.getClass().getName());
return List.of();
}
if (db == null) { if (db == null) {
logger.debug("Could not find item '{}' in rrd4j database", itemName); logger.debug("Could not find item '{}' in rrd4j database", itemName);
return List.of(); return List.of();