diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-06-30 15:10:24 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-06-30 15:10:24 +0200 |
commit | 66757997f120e143d3cd1f0d95919572bb1b24cc (patch) | |
tree | 30da222a065c660576f56ee4c7b9dd77df168e30 /node-repository | |
parent | 00313956189a38fb823b0c2a48685b4fd40ee7ac (diff) |
Serialize gc & other writes
Diffstat (limited to 'node-repository')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java index aa2a898d58b..8d97e14fc7c 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java @@ -357,32 +357,33 @@ public class QuestMetricsDb extends AbstractComponent implements MetricsDb { } void gc() { - // 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(); - int partitions = 0; - try { - List<String> removeList = new ArrayList<>(); - for (String dirEntry : dir.list()) { - File partitionDir = new File(dir, dirEntry); - if ( ! partitionDir.isDirectory()) continue; - - partitions++; - DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.of("UTC")); - Instant partitionDay = Instant.from(formatter.parse(dirEntry.substring(0, 10) + "T00:00:00")); - if (partitionDay.isBefore(oldestToKeep)) - removeList.add(dirEntry); + 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(); + int partitions = 0; + try { + List<String> removeList = new ArrayList<>(); + for (String dirEntry : dir.list()) { + File partitionDir = new File(dir, dirEntry); + if (!partitionDir.isDirectory()) continue; + + partitions++; + DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneId.of("UTC")); + Instant partitionDay = Instant.from(formatter.parse(dirEntry.substring(0, 10) + "T00:00:00")); + if (partitionDay.isBefore(oldestToKeep)) + removeList.add(dirEntry); + } + // Remove unless all partitions are old: Removing all partitions "will be supported in the future" + if (removeList.size() < partitions && !removeList.isEmpty()) { + issue("alter table " + name + " drop partition list " + + removeList.stream().map(dir -> "'" + dir + "'").collect(Collectors.joining(",")), + context); + } + } catch (SqlException e) { + log.log(Level.WARNING, "Failed to gc old metrics data in " + dir + " table " + name, e); } - // Remove unless all partitions are old: Removing all partitions "will be supported in the future" - if ( removeList.size() < partitions && ! removeList.isEmpty()) { - issue("alter table " + name + " drop partition list " + - removeList.stream().map(dir -> "'" + dir + "'").collect(Collectors.joining(",")), - context); - } - } - catch (SqlException e) { - log.log(Level.WARNING, "Failed to gc old metrics data in " + dir + " table " + name, e); } } |