Serialize gc & other writes
@@ -357,6 +357,7 @@ public class QuestMetricsDb extends AbstractComponent implements MetricsDb {
}
void gc() {
+ synchronized (writeLock) {
// We remove full days at once and we want to see at least three days to not every only see weekend data
Instant oldestToKeep = clock.instant().minus(Duration.ofDays(4));
SqlExecutionContext context = newContext();
@@ -380,11 +381,11 @@ public class QuestMetricsDb extends AbstractComponent implements MetricsDb {
removeList.stream().map(dir -> "'" + dir + "'").collect(Collectors.joining(",")),
context);
}
- }
- catch (SqlException e) {
+ } catch (SqlException e) {
log.log(Level.WARNING, "Failed to gc old metrics data in " + dir + " table " + name, e);
}
}
+ }
/**
* Repairs this db on corruption.
